kmalloc returns (void*), don't do type conversions
Subsystems (18)
PATCH 1/1 kmalloc returns (void*), don't do type conversions
Hello everybody,
as requested on http://kernelnewbies.org/KernelJanitors/Todo
here's a first patch that removes type conversion on kmalloc() (which returns a (void*)):
It was done against current linus-git (d40ace0c7b4a329f7d869d0fbf27435543bb2acc, if I'm not mistaken), and looks like that:
list_del(&bss->list);
local->num_bss_info--;
} else {
- bss = (struct hostap_bss_info *)
- kmalloc(sizeof(*bss), GFP_ATOMIC);
+ bss = kmalloc(sizeof(*bss), GFP_ATOMIC);
if (bss == NULL)
return NULL;}
Most of the patch is auto-generated (by a script in
http://kernelnewbies.org/KernelJanitors/Todo/VoidPointerConvs);
but it is hand-changed in some parts to avoid checkpatch warnings:
- line length
- "foo* bar" to "foo *bar"
- space prohibited between function name and open parenthesis '(' (like "sizeof (")
checkpatch didn't give any warnings or errors on this patch.
I tried a "make allyesconfig", but that gave some compile errors
that don't seem related to my changes:
drivers/block/cciss_scsi.c:75: error: ‘MAX_CTLR’ undeclared here (not in a function) drivers/block/cciss_scsi.c:76: error: field name not in record or union initializer
Please tell me if that's the correct approach; I'm sorry that I couldn't find out who the correct maintainer for these changes is.
Regards,
Phil
$ diffstat kmalloc-type-changes.patch arch/cris/arch-v32/mm/intmem.c | 13 +++++-------- arch/ia64/kernel/mca_drv.c | 4 ++-- arch/powerpc/kernel/nvram_64.c | 3 +-- drivers/block/cciss.c | 3 +-- drivers/block/cciss_scsi.c | 3 +-- drivers/block/floppy.c | 3 +-- drivers/i2c/i2c-dev.c | 3 +-- drivers/isdn/capi/capidrv.c | 3 +-- drivers/isdn/hisax/hfc_sx.c | 5 +++-- drivers/media/video/vino.c | 8 ++++---- drivers/message/i2o/i2o_config.c | 3 +-- drivers/mtd/maps/tqm8xxl.c | 2 +- drivers/net/gianfar.c | 6 ++---- drivers/net/s2io.c | 4 ++-- drivers/net/tulip/eeprom.c | 8 ++++---- drivers/net/wireless/hostap/hostap_80211_rx.c | 3 +-- drivers/net/wireless/hostap/hostap_ioctl.c | 3 +-- drivers/net/wireless/ipw2100.c | 10 ++++------ drivers/net/wireless/zd1211rw/zd_chip.c | 2 +- drivers/s390/net/ctcm_mpc.c | 6 ++---- drivers/s390/net/qeth_core_main.c | 4 ++-- drivers/scsi/osst.c | 5 ++--- drivers/usb/storage/isd200.c | 3 +-- fs/befs/btree.c | 4 ++-- fs/ufs/util.c | 3 +-- net/ipv4/igmp.c | 3 +-- net/ipv6/mcast.c | 3 +-- net/sctp/protocol.c | 4 ++-- security/selinux/ss/conditional.c | 4 ++-- 29 files changed, 53 insertions(+), 75 deletions(-)
Remove type conversions that are done on the result of kmalloc() - this is defined as (void*).
drivers/i2c/i2c-dev.c +1 -2
@@ -218,8 +218,7 @@ static noinline int i2cdev_ioctl_rdrw(stif (rdwr_arg.nmsgs >I2C_RDRW_IOCTL_MAX_MSGS )return -EINVAL ; - rdwr_pa = (struct i2c_msg *) -kmalloc (rdwr_arg.nmsgs *sizeof (struct i2c_msg ), + rdwr_pa =kmalloc (rdwr_arg.nmsgs *sizeof (struct i2c_msg ),GFP_KERNEL );if (!rdwr_pa)return -ENOMEM ;
drivers/net/s2io.c +2 -2
@@ -899,7 +899,7 @@ static int init_shared_mem(struct s2io_nwhile (k != rxd_count[nic->rxd_mode]) { ba = &mac_control->rings[i].ba[j][k]; - ba->ba_0_org = (void *)kmalloc + ba->ba_0_org =kmalloc (BUF0_LEN +ALIGN_SIZE ,GFP_KERNEL );if (!ba->ba_0_org)return -ENOMEM ;
@@ -910,7 +910,7 @@ static int init_shared_mem(struct s2io_n tmp &= ~((unsigned long )ALIGN_SIZE ); ba->ba_0 = (void *) tmp; - ba->ba_1_org = (void *)kmalloc + ba->ba_1_org =kmalloc (BUF1_LEN +ALIGN_SIZE ,GFP_KERNEL );if (!ba->ba_1_org)return -ENOMEM ;
drivers/net/wireless/hostap/hostap_ioctl.c +1 -2
@@ -3057,8 +3057,7 @@ static int prism2_ioctl_priv_download(lo p->length > 1024 || !p->pointer)return -EINVAL ; - param = (struct prism2_download_param *) -kmalloc (p->length,GFP_KERNEL ); + param =kmalloc (p->length,GFP_KERNEL );if (param ==NULL )return -ENOMEM ;
drivers/net/wireless/hostap/hostap_80211_rx.c +1 -2
@@ -335,8 +335,7 @@ static struct hostap_bss_info *__hostap_list_del (&bss->list); local->num_bss_info--; }else { - bss = (struct hostap_bss_info *) -kmalloc (sizeof (*bss),GFP_ATOMIC ); + bss =kmalloc (sizeof (*bss),GFP_ATOMIC );if (bss ==NULL )return NULL ; }
drivers/net/wireless/zd1211rw/zd_chip.c +1 -1
@@ -117,7 +117,7 @@ int zd_ioread32v_locked(struct zd_chip */* Allocate a single memory block for values and addresses. */ count16 =2 *count; - a16 = (zd_addr_t *)kmalloc (count16 * (sizeof (zd_addr_t) +sizeof (u16)), + a16 =kmalloc (count16 * (sizeof (zd_addr_t) +sizeof (u16)),GFP_KERNEL );if (!a16) { dev_dbg_f(zd_chip_dev(chip),
drivers/net/wireless/ipw2100.c +4 -6
@@ -3373,8 +3373,7 @@ static int ipw2100_msg_allocate(struct ivoid *v;dma_addr_t p; - priv->msg_buffers = - (struct ipw2100_tx_packet *)kmalloc (IPW_COMMAND_POOL_SIZE * + priv->msg_buffers =kmalloc (IPW_COMMAND_POOL_SIZE *sizeof (struct ipw2100_tx_packet ),GFP_KERNEL );
@@ -4406,8 +4405,7 @@ static int ipw2100_tx_allocate(struct ipreturn err; } - priv->tx_buffers = - (struct ipw2100_tx_packet *)kmalloc (TX_PENDED_QUEUE_LENGTH * + priv->tx_buffers =kmalloc (TX_PENDED_QUEUE_LENGTH *sizeof (struct ipw2100_tx_packet ),GFP_ATOMIC );
@@ -4559,8 +4557,8 @@ static int ipw2100_rx_allocate(struct ip/* * allocate packets */ - priv->rx_buffers = (struct ipw2100_rx_packet *) -kmalloc (RX_QUEUE_LENGTH *sizeof (struct ipw2100_rx_packet ), + priv->rx_buffers =kmalloc (RX_QUEUE_LENGTH * +sizeof (struct ipw2100_rx_packet ),GFP_KERNEL );if (!priv->rx_buffers) {IPW_DEBUG_INFO ("can't allocate rx packet buffer table\n" );
drivers/net/tulip/eeprom.c +4 -4
@@ -121,8 +121,8 @@ static void __devinit tulip_build_fake_m 0x00, 0x06 /* ttm bit map */ }; - tp->mtable = (struct mediatable *) -kmalloc (sizeof (struct mediatable ) +sizeof (struct medialeaf ),GFP_KERNEL ); + tp->mtable =kmalloc (sizeof (struct mediatable ) + +sizeof (struct medialeaf ),GFP_KERNEL );if (tp->mtable ==NULL )return ;/* Horrible, impossible failure. */
@@ -224,8 +223,8 @@ subsequent_board:return ; } - mtable = (struct mediatable *) -kmalloc (sizeof (struct mediatable ) + count*sizeof (struct medialeaf ), + mtable =kmalloc (sizeof (struct mediatable ) + + count*sizeof (struct medialeaf ),GFP_KERNEL );if (mtable ==NULL )return ;/* Horrible, impossible failure. */
drivers/net/gianfar.c +2 -4
@@ -737,8 +737,7 @@ int startup_gfar(struct net_device *dev)gfar_write (®s->rbase0, addr);/* Setup the skbuff rings */ - priv->tx_skbuff = - (struct sk_buff **)kmalloc (sizeof (struct sk_buff *) * + priv->tx_skbuff =kmalloc (sizeof (struct sk_buff *) * priv->tx_ring_size,GFP_KERNEL );if (NULL == priv->tx_skbuff) {
@@ -752,8 +751,7 @@ int startup_gfar(struct net_device *dev)for (i =0 ; i < priv->tx_ring_size; i++) priv->tx_skbuff[i] =NULL ; - priv->rx_skbuff = - (struct sk_buff **)kmalloc (sizeof (struct sk_buff *) * + priv->rx_skbuff =kmalloc (sizeof (struct sk_buff *) * priv->rx_ring_size,GFP_KERNEL );if (NULL == priv->rx_skbuff) {
drivers/s390/net/qeth_core_main.c +2 -2
@@ -634,8 +634,8 @@ static int qeth_setup_channel(struct qetQETH_DBF_TEXT (SETUP ,2 ,"setupch" );for (cnt =0 ; cnt <QETH_CMD_BUFFER_NO ; cnt++) { - channel->iob[cnt].data = (char *) -kmalloc (QETH_BUFSIZE ,GFP_DMA |GFP_KERNEL ); + channel->iob[cnt].data = +kmalloc (QETH_BUFSIZE ,GFP_DMA |GFP_KERNEL );if (channel->iob[cnt].data ==NULL )break ; channel->iob[cnt].state =BUF_STATE_FREE ;
drivers/s390/net/ctcm_mpc.c +2 -4
@@ -696,8 +696,7 @@ static void ctcmpc_send_sweep_resp(struc goto done; } - header = (struct th_sweep *) -kmalloc (sizeof (struct th_sweep ),gfp_type ()); + header =kmalloc (sizeof (struct th_sweep ),gfp_type ());if (!header) {dev_kfree_skb_any (sweep_skb);
@@ -1308,8 +1307,7 @@ static void ctcmpc_unpack_skb(struct chaskb_pull (pskb, new_len);/* point to next PDU */ } }else { - mpcginfo = (struct mpcg_info *) -kmalloc (sizeof (struct mpcg_info ),gfp_type ()); + mpcginfo =kmalloc (sizeof (struct mpcg_info ),gfp_type ());if (mpcginfo ==NULL ) goto done;
drivers/isdn/capi/capidrv.c +1 -2
@@ -469,8 +469,7 @@ static int capidrv_add_ack(struct capidr {struct ncci_datahandle_queue *n, **pp; - n = (struct ncci_datahandle_queue *) -kmalloc (sizeof (struct ncci_datahandle_queue ),GFP_ATOMIC ); + n =kmalloc (sizeof (struct ncci_datahandle_queue ),GFP_ATOMIC );if (!n) {printk (KERN_ERR "capidrv: kmalloc ncci_datahandle failed\n" );return -1 ;
drivers/isdn/hisax/hfc_sx.c +3 -2
@@ -1480,8 +1480,9 @@ setup_hfcsx(struct IsdnCard *card)release_region (cs->hw.hfcsx.base,2 );return (0 ); } -if (!(cs->hw.hfcsx.extra = (void *) -kmalloc (sizeof (struct hfcsx_extra ),GFP_ATOMIC ))) { + cs->hw.hfcsx.extra =kmalloc (sizeof (struct hfcsx_extra ), +GFP_ATOMIC ); +if (!cs->hw.hfcsx.extra)release_region (cs->hw.hfcsx.base,2 );printk (KERN_WARNING "HFC-SX: unable to allocate memory\n" );return (0 );
drivers/scsi/osst.c +2 -3
@@ -5758,8 +5758,7 @@ static int osst_probe(struct device *dev/* if this is the first attach, build the infrastructure */ write_lock (&os_scsi_tapes_lock);if (os_scsi_tapes ==NULL ) { - os_scsi_tapes = - (struct osst_tape **)kmalloc (osst_max_dev *sizeof (struct osst_tape *), -GFP_ATOMIC ); + os_scsi_tapes =kmalloc (osst_max_dev * +sizeof (struct osst_tape *),GFP_ATOMIC );if (os_scsi_tapes ==NULL ) {write_unlock (&os_scsi_tapes_lock);
drivers/block/cciss_scsi.c +1 -2
@@ -535,8 +535,7 @@ cciss_scsi_setup(int cntl_num)struct cciss_scsi_adapter_data_t * shba; ccissscsi[cntl_num].ndevices =0 ; - shba = (struct cciss_scsi_adapter_data_t *) -kmalloc (sizeof (*shba),GFP_KERNEL ); + shba =kmalloc (sizeof (*shba),GFP_KERNEL );if (shba ==NULL )return ; shba->scsi_host =NULL ;
drivers/block/floppy.c +1 -2
@@ -3194,8 +3194,7 @@ static inline int raw_cmd_copyin(int cmd *rcmd =NULL ;while (1 ) { - ptr = (struct floppy_raw_cmd *) -kmalloc (sizeof (struct floppy_raw_cmd ),GFP_USER ); + ptr =kmalloc (sizeof (struct floppy_raw_cmd ),GFP_USER );if (!ptr)return -ENOMEM ; *rcmd = ptr;
drivers/block/cciss.c +1 -2
@@ -1073,8 +1073,7 @@ static int cciss_ioctl(struct inode *inoreturn -EINVAL ;if (!capable (CAP_SYS_RAWIO ))return -EPERM ; - ioc = (BIG_IOCTL_Command_struct *) -kmalloc (sizeof (*ioc),GFP_KERNEL ); + ioc =kmalloc (sizeof (*ioc),GFP_KERNEL );if (!ioc) { status = -ENOMEM ; goto cleanup1;
drivers/media/video/vino.c +4 -4
@@ -848,8 +848,8 @@ static int vino_allocate_buffer(struct v size, count);/* allocate memory for table with virtual (page) addresses */ - fb->desc_table.virtual = (unsigned long *) -kmalloc (count *sizeof (unsigned long ),GFP_KERNEL ); + fb->desc_table.virtual =kmalloc (count * +sizeof (unsigned long ),GFP_KERNEL );if (!fb->desc_table.virtual)return -ENOMEM ;
@@ -935,8 +934,8 @@ static int vino_prepare_user_buffer(stru size, count);/* allocate memory for table with virtual (page) addresses */ - fb->desc_table.virtual = (unsigned long *) -kmalloc (count *sizeof (unsigned long ),GFP_KERNEL ); + fb->desc_table.virtual =kmalloc (count * +sizeof (unsigned long ),GFP_KERNEL );if (!fb->desc_table.virtual)return -ENOMEM ;
drivers/message/i2o/i2o_config.c +1 -2
@@ -1053,8 +1053,7 @@ static int i2o_cfg_ioctl(struct inode *istatic int cfg_open (struct inode *inode,struct file *file) { -struct i2o_cfg_info *tmp = - (struct i2o_cfg_info *)kmalloc (sizeof (struct i2o_cfg_info ), +struct i2o_cfg_info *tmp =kmalloc (sizeof (struct i2o_cfg_info ),GFP_KERNEL );unsigned long flags;
drivers/usb/storage/isd200.c +1 -2
@@ -1496,8 +1496,7 @@ static int isd200_init_info(struct us_daelse { info->id = (struct hd_driveid *)kzalloc (sizeof (struct hd_driveid ),GFP_KERNEL ); - info->RegsBuf = (unsigned char *) -kmalloc (sizeof (info->ATARegs),GFP_KERNEL ); + info->RegsBuf =kmalloc (sizeof (info->ATARegs),GFP_KERNEL ); info->srb.sense_buffer =kmalloc (SCSI_SENSE_BUFFERSIZE ,GFP_KERNEL );if (!info->id || !info->RegsBuf || !info->srb.sense_buffer) {
drivers/mtd/maps/tqm8xxl.c +1 -1
@@ -141,7 +141,7 @@ int __init init_tqm_mtd(void) goto error_mem; } - map_banks[idx]->name = (char *)kmalloc (16 ,GFP_KERNEL ); + map_banks[idx]->name =kmalloc (16 ,GFP_KERNEL );if (!map_banks[idx]->name) { ret = -ENOMEM ;
net/sctp/protocol.c +2 -2
@@ -1188,8 +1188,8 @@ SCTP_STATIC __init int sctp_init(void)/* Allocate and initialize the endpoint hash table. */ sctp_ep_hashsize =64 ; - sctp_ep_hashtable = (struct sctp_hashbucket *) -kmalloc (64 *sizeof (struct sctp_hashbucket ),GFP_KERNEL ); + sctp_ep_hashtable =kmalloc (64 * +sizeof (struct sctp_hashbucket ),GFP_KERNEL );if (!sctp_ep_hashtable) {printk (KERN_ERR "SCTP: Failed endpoint_hash alloc.\n" ); status = -ENOMEM ;
net/ipv6/mcast.c +1 -2
@@ -2044,8 +2044,7 @@ static int sf_setstate(struct ifmcaddr6 &psf->sf_addr))break ;if (!dpsf) { - dpsf = (struct ip6_sf_list *) -kmalloc (sizeof (*dpsf),GFP_ATOMIC ); + dpsf =kmalloc (sizeof (*dpsf),GFP_ATOMIC );if (!dpsf)continue ; *dpsf = *psf;
net/ipv4/igmp.c +1 -2
@@ -1638,8 +1638,7 @@ static int sf_setstate(struct ip_mc_listif (dpsf->sf_inaddr == psf->sf_inaddr)break ;if (!dpsf) { - dpsf = (struct ip_sf_list *) -kmalloc (sizeof (*dpsf),GFP_ATOMIC ); + dpsf =kmalloc (sizeof (*dpsf),GFP_ATOMIC );if (!dpsf)continue ; *dpsf = *psf;
fs/ufs/util.c +1 -2
@@ -26,8 +26,7 @@ struct ufs_buffer_head * _ubh_bread_ (st count = size >> uspi->s_fshift;if (count >UFS_MAXFRAG )return NULL ; - ubh = (struct ufs_buffer_head *) -kmalloc (sizeof (struct ufs_buffer_head ),GFP_KERNEL ); + ubh =kmalloc (sizeof (struct ufs_buffer_head ),GFP_KERNEL );if (!ubh)return NULL ; ubh->fragment = fragment;
fs/befs/btree.c +2 -2
@@ -436,8 +436,8 @@ befs_btree_read(struct super_block *sb, goto error; } -if ((this_node = (befs_btree_node *) -kmalloc (sizeof (befs_btree_node),GFP_NOFS )) ==NULL ) { + this_node =kmalloc (sizeof (befs_btree_node),GFP_NOFS ); +if (!this_node) {befs_error (sb,"befs_btree_read() failed to allocate %u " "bytes of memory" ,sizeof (befs_btree_node)); goto error;
security/selinux/ss/conditional.c +2 -2
@@ -171,8 +171,8 @@ void cond_policydb_destroy(struct policyint cond_init_bool_indexes (struct policydb *p) {kfree (p->bool_val_to_struct); - p->bool_val_to_struct = (struct cond_bool_datum **) -kmalloc (p->p_bools.nprim *sizeof (struct cond_bool_datum *),GFP_KERNEL ); + p->bool_val_to_struct =kmalloc (p->p_bools.nprim * +sizeof (struct cond_bool_datum *),GFP_KERNEL );if (!p->bool_val_to_struct)return -1 ;return 0 ;
arch/powerpc/kernel/nvram_64.c +1 -2
@@ -527,8 +527,7 @@ static int nvram_scan_partitions(void) "detected: 0-length partition\n"); goto out; } - tmp_part = (struct nvram_partition *) -kmalloc (sizeof (struct nvram_partition ),GFP_KERNEL ); + tmp_part =kmalloc (sizeof (struct nvram_partition ),GFP_KERNEL ); err = -ENOMEM ;if (!tmp_part) {printk (KERN_ERR "nvram_scan_partitions: kmalloc failed\n" );
arch/cris/arch-v32/mm/intmem.c +5 -8
@@ -33,8 +33,8 @@ static void crisv32_intmem_init(void) {static int initiated =0 ;if (!initiated) { -struct intmem_allocation * alloc = - (struct intmem_allocation *)kmalloc (sizeof *alloc,GFP_KERNEL ); +struct intmem_allocation *alloc = +kmalloc (sizeof (*alloc),GFP_KERNEL );INIT_LIST_HEAD (&intmem_allocations); intmem_virtual =ioremap (MEM_INTMEM_START +RESERVED_SIZE ,MEM_INTMEM_SIZE -RESERVED_SIZE );
@@ -62,9 +61,8 @@ void* crisv32_intmem_alloc(unsigned sizeif (allocation->status ==STATUS_FREE && allocation->size >= size + alignment) {if (allocation->size > size + alignment) { -struct intmem_allocation * alloc = - (struct intmem_allocation *) -kmalloc (sizeof *alloc,GFP_ATOMIC ); +struct intmem_allocation *alloc = +kmalloc (sizeof (*alloc),GFP_ATOMIC ); alloc->status =STATUS_FREE ; alloc->size = allocation->size - size - alignment;
@@ -74,8 +71,6 @@ void* crisv32_intmem_alloc(unsigned sizeif (alignment) {struct intmem_allocation *tmp; - tmp = (struct intmem_allocation *) -kmalloc (sizeof *tmp, -GFP_ATOMIC ); + tmp =kmalloc (sizeof (*tmp),GFP_ATOMIC ); tmp->offset = allocation->offset; tmp->size = alignment;
arch/ia64/kernel/mca_drv.c +2 -2
@@ -348,8 +348,8 @@ init_record_index_pools(void)/* - 3 - */ slidx_pool.max_idx = (rec_max_size/sect_min_size) *2 +1 ; - slidx_pool.buffer = (slidx_list_t *) -kmalloc (slidx_pool.max_idx *sizeof (slidx_list_t),GFP_KERNEL ); + slidx_pool.buffer =kmalloc (slidx_pool.max_idx * +sizeof (slidx_list_t),GFP_KERNEL );return slidx_pool.buffer ?0 : -ENOMEM ; }
Hi Phillip,
Quoted 4 lines · Philipp Marek
I tried a "make allyesconfig", but that gave some compile errors
that don't seem related to my changes:
drivers/block/cciss_scsi.c:75: error: ‘MAX_CTLR’ undeclared here (not in a function)drivers/block/cciss_scsi.c:76: error: field name not in record or union initializer
You probably should write another email regarding this.
Quoted 2 lines
Please tell me if that's the correct approach; I'm sorry that I couldn't find out who the correct maintainer for these changes is.
Added the trivial tree maintainer to CC. Jesper?
Quoted 23 lines
$ diffstat kmalloc-type-changes.patch arch/cris/arch-v32/mm/intmem.c | 13 +++++-------- arch/ia64/kernel/mca_drv.c | 4 ++-- arch/powerpc/kernel/nvram_64.c | 3 +-- drivers/block/cciss.c | 3 +-- drivers/block/cciss_scsi.c | 3 +-- drivers/block/floppy.c | 3 +-- drivers/i2c/i2c-dev.c | 3 +-- drivers/isdn/capi/capidrv.c | 3 +-- drivers/isdn/hisax/hfc_sx.c | 5 +++-- drivers/media/video/vino.c | 8 ++++---- drivers/message/i2o/i2o_config.c | 3 +-- drivers/mtd/maps/tqm8xxl.c | 2 +- drivers/net/gianfar.c | 6 ++---- drivers/net/s2io.c | 4 ++-- drivers/net/tulip/eeprom.c | 8 ++++---- drivers/net/wireless/hostap/hostap_80211_rx.c | 3 +-- drivers/net/wireless/hostap/hostap_ioctl.c | 3 +-- drivers/net/wireless/ipw2100.c | 10 ++++------ drivers/net/wireless/zd1211rw/zd_chip.c | 2 +- drivers/s390/net/ctcm_mpc.c | 6 ++---- drivers/s390/net/qeth_core_main.c | 4 ++-- drivers/scsi/osst.c | 5 ++---
Quoted 8 lines
drivers/usb/storage/isd200.c | 3 +-- fs/befs/btree.c | 4 ++-- fs/ufs/util.c | 3 +-- net/ipv4/igmp.c | 3 +-- net/ipv6/mcast.c | 3 +-- net/sctp/protocol.c | 4 ++-- security/selinux/ss/conditional.c | 4 ++-- 29 files changed, 53 insertions(+), 75 deletions(-)
You can include the diffstat in the patch as comment. And please don't attach patches, include them inline. See Documentation/SubmittingPatches.
Quoted 2 lines
Remove type conversions that are done on the result of
kmalloc()- this is defined as (void*).
How about:
Remove unneeded explicit casting from kmalloc() return values.
Quoted 1 line
Signed-off-by [email protected]
Better use: Real Name <user@domain>
Hope that helps,
Hannes
Quoted 1 line · Johannes Weiner
Added the trivial tree maintainer to CC. Jesper?
Sorry, it's [email protected].
2008/5/21 Johannes Weiner <[email protected]>:
Quoted 11 lines
Hi Phillip,
Quoted 4 lines · Philipp Marek
I tried a "make allyesconfig", but that gave some compile errors
that don't seem related to my changes:
drivers/block/cciss_scsi.c:75: error: 'MAX_CTLR' undeclared here (not in a function)drivers/block/cciss_scsi.c:76: error: field name not in record or union initializerYou probably should write another email regarding this.
I agree, keep things seperate. One mail with patch to fix casts, another to report build breakage.
Quoted 5 lines
Quoted 2 lines
Please tell me if that's the correct approach; I'm sorry that I couldn't find out who the correct maintainer for these changes is.
Added the trivial tree maintainer to CC. Jesper?
Thank you, I'll keep an eye on this patch.
Philipp: Johannes makes some good points, please address his comments and re-submit the patch with [email protected] on Cc: if it draws no negative comments it looks good to me to add to the trivial tree.
Signature · 3 lines
Jesper Juhl <[email protected]> Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html Plain text mails only, please http://www.expita.com/nomime.html
Quoted 10 lines · On Thursday 22 May 2008 Jesper Juhl wrote:
2008/5/21 Johannes Weiner <[email protected]>:
Quoted 9 lines
Hi Phillip,
Quoted 5 lines · Philipp Marek
I tried a "make allyesconfig", but that gave some compile errors that don't seem related to my changes:
drivers/block/cciss_scsi.c:75: error: 'MAX_CTLR' undeclared here
(not in a function)drivers/block/cciss_scsi.c:76: error: field name not in record or union initializer
Quoted 4 lines
Quoted 1 line
You probably should write another email regarding this.
I agree, keep things seperate. One mail with patch to fix casts, another to report build breakage.
Sorry, I didn't make myself understood.
A "make allyesconfig ; make" goes through (for amd64); just testing every file for itself ("make drivers/block/cciss_scsi.o") gives errors - partly because they're for the wrong architecture, or some other mismatches.
Please note that the first version had a bug (missing "{") which is corrected here.
Quoted 2 lines
Quoted 1 line
Added the trivial tree maintainer to CC. Jesper?
Thank you, I'll keep an eye on this patch.
I didn't think that these changes were "trivial" - I'd have taken this category for comment updates and suchlike.
But I'm ok with that :-)
Quoted 3 lines
Philipp: Johannes makes some good points, please address his comments and re-submit the patch with [email protected] on Cc: if it draws no negative comments it looks good to me to add to the trivial tree.
Here you are.
I've got 57 other patches that deal with (void*)-returning functions getting casted; diffstat says
151 files changed, 301 insertions(+), 368 deletions(-)
Should I just send them (as a whole) to trivial@ like this patch, or should I cut them for different maintainers?
Regards,
Phil
---
Remove unneeded explicit casting from kmalloc() return values.
drivers/i2c/i2c-dev.c +1 -2
@@ -218,8 +218,7 @@ static noinline int i2cdev_ioctl_rdrw(stif (rdwr_arg.nmsgs >I2C_RDRW_IOCTL_MAX_MSGS )return -EINVAL ; - rdwr_pa = (struct i2c_msg *) -kmalloc (rdwr_arg.nmsgs *sizeof (struct i2c_msg ), + rdwr_pa =kmalloc (rdwr_arg.nmsgs *sizeof (struct i2c_msg ),GFP_KERNEL );if (!rdwr_pa)return -ENOMEM ;
drivers/net/s2io.c +2 -2
@@ -899,7 +899,7 @@ static int init_shared_mem(struct s2io_nwhile (k != rxd_count[nic->rxd_mode]) { ba = &mac_control->rings[i].ba[j][k]; - ba->ba_0_org = (void *)kmalloc + ba->ba_0_org =kmalloc (BUF0_LEN +ALIGN_SIZE ,GFP_KERNEL );if (!ba->ba_0_org)return -ENOMEM ;
@@ -910,7 +910,7 @@ static int init_shared_mem(struct s2io_n tmp &= ~((unsigned long )ALIGN_SIZE ); ba->ba_0 = (void *) tmp; - ba->ba_1_org = (void *)kmalloc + ba->ba_1_org =kmalloc (BUF1_LEN +ALIGN_SIZE ,GFP_KERNEL );if (!ba->ba_1_org)return -ENOMEM ;
drivers/net/wireless/hostap/hostap_ioctl.c +1 -2
@@ -3057,8 +3057,7 @@ static int prism2_ioctl_priv_download(lo p->length > 1024 || !p->pointer)return -EINVAL ; - param = (struct prism2_download_param *) -kmalloc (p->length,GFP_KERNEL ); + param =kmalloc (p->length,GFP_KERNEL );if (param ==NULL )return -ENOMEM ;
drivers/net/wireless/hostap/hostap_80211_rx.c +1 -2
@@ -335,8 +335,7 @@ static struct hostap_bss_info *__hostap_list_del (&bss->list); local->num_bss_info--; }else { - bss = (struct hostap_bss_info *) -kmalloc (sizeof (*bss),GFP_ATOMIC ); + bss =kmalloc (sizeof (*bss),GFP_ATOMIC );if (bss ==NULL )return NULL ; }
drivers/net/wireless/zd1211rw/zd_chip.c +1 -1
@@ -117,7 +117,7 @@ int zd_ioread32v_locked(struct zd_chip */* Allocate a single memory block for values and addresses. */ count16 =2 *count; - a16 = (zd_addr_t *)kmalloc (count16 * (sizeof (zd_addr_t) +sizeof (u16)), + a16 =kmalloc (count16 * (sizeof (zd_addr_t) +sizeof (u16)),GFP_KERNEL );if (!a16) { dev_dbg_f(zd_chip_dev(chip),
drivers/net/wireless/ipw2100.c +4 -6
@@ -3373,8 +3373,7 @@ static int ipw2100_msg_allocate(struct ivoid *v;dma_addr_t p; - priv->msg_buffers = - (struct ipw2100_tx_packet *)kmalloc (IPW_COMMAND_POOL_SIZE * + priv->msg_buffers =kmalloc (IPW_COMMAND_POOL_SIZE *sizeof (struct ipw2100_tx_packet ),GFP_KERNEL );
@@ -4406,8 +4405,7 @@ static int ipw2100_tx_allocate(struct ipreturn err; } - priv->tx_buffers = - (struct ipw2100_tx_packet *)kmalloc (TX_PENDED_QUEUE_LENGTH * + priv->tx_buffers =kmalloc (TX_PENDED_QUEUE_LENGTH *sizeof (struct ipw2100_tx_packet ),GFP_ATOMIC );
@@ -4559,8 +4557,8 @@ static int ipw2100_rx_allocate(struct ip/* * allocate packets */ - priv->rx_buffers = (struct ipw2100_rx_packet *) -kmalloc (RX_QUEUE_LENGTH *sizeof (struct ipw2100_rx_packet ), + priv->rx_buffers =kmalloc (RX_QUEUE_LENGTH * +sizeof (struct ipw2100_rx_packet ),GFP_KERNEL );if (!priv->rx_buffers) {IPW_DEBUG_INFO ("can't allocate rx packet buffer table\n" );
drivers/net/tulip/eeprom.c +4 -4
@@ -121,8 +121,8 @@ static void __devinit tulip_build_fake_m 0x00, 0x06 /* ttm bit map */ }; - tp->mtable = (struct mediatable *) -kmalloc (sizeof (struct mediatable ) +sizeof (struct medialeaf ),GFP_KERNEL ); + tp->mtable =kmalloc (sizeof (struct mediatable ) + +sizeof (struct medialeaf ),GFP_KERNEL );if (tp->mtable ==NULL )return ;/* Horrible, impossible failure. */
@@ -224,8 +223,8 @@ subsequent_board:return ; } - mtable = (struct mediatable *) -kmalloc (sizeof (struct mediatable ) + count*sizeof (struct medialeaf ), + mtable =kmalloc (sizeof (struct mediatable ) + + count*sizeof (struct medialeaf ),GFP_KERNEL );if (mtable ==NULL )return ;/* Horrible, impossible failure. */
drivers/net/gianfar.c +2 -4
@@ -737,8 +737,7 @@ int startup_gfar(struct net_device *dev)gfar_write (®s->rbase0, addr);/* Setup the skbuff rings */ - priv->tx_skbuff = - (struct sk_buff **)kmalloc (sizeof (struct sk_buff *) * + priv->tx_skbuff =kmalloc (sizeof (struct sk_buff *) * priv->tx_ring_size,GFP_KERNEL );if (NULL == priv->tx_skbuff) {
@@ -752,8 +751,7 @@ int startup_gfar(struct net_device *dev)for (i =0 ; i < priv->tx_ring_size; i++) priv->tx_skbuff[i] =NULL ; - priv->rx_skbuff = - (struct sk_buff **)kmalloc (sizeof (struct sk_buff *) * + priv->rx_skbuff =kmalloc (sizeof (struct sk_buff *) * priv->rx_ring_size,GFP_KERNEL );if (NULL == priv->rx_skbuff) {
drivers/s390/net/qeth_core_main.c +2 -2
@@ -634,8 +634,8 @@ static int qeth_setup_channel(struct qetQETH_DBF_TEXT (SETUP ,2 ,"setupch" );for (cnt =0 ; cnt <QETH_CMD_BUFFER_NO ; cnt++) { - channel->iob[cnt].data = (char *) -kmalloc (QETH_BUFSIZE ,GFP_DMA |GFP_KERNEL ); + channel->iob[cnt].data = +kmalloc (QETH_BUFSIZE ,GFP_DMA |GFP_KERNEL );if (channel->iob[cnt].data ==NULL )break ; channel->iob[cnt].state =BUF_STATE_FREE ;
drivers/s390/net/ctcm_mpc.c +2 -4
@@ -696,8 +696,7 @@ static void ctcmpc_send_sweep_resp(struc goto done; } - header = (struct th_sweep *) -kmalloc (sizeof (struct th_sweep ),gfp_type ()); + header =kmalloc (sizeof (struct th_sweep ),gfp_type ());if (!header) {dev_kfree_skb_any (sweep_skb);
@@ -1308,8 +1307,7 @@ static void ctcmpc_unpack_skb(struct chaskb_pull (pskb, new_len);/* point to next PDU */ } }else { - mpcginfo = (struct mpcg_info *) -kmalloc (sizeof (struct mpcg_info ),gfp_type ()); + mpcginfo =kmalloc (sizeof (struct mpcg_info ),gfp_type ());if (mpcginfo ==NULL ) goto done;
drivers/isdn/capi/capidrv.c +1 -2
@@ -469,8 +469,7 @@ static int capidrv_add_ack(struct capidr {struct ncci_datahandle_queue *n, **pp; - n = (struct ncci_datahandle_queue *) -kmalloc (sizeof (struct ncci_datahandle_queue ),GFP_ATOMIC ); + n =kmalloc (sizeof (struct ncci_datahandle_queue ),GFP_ATOMIC );if (!n) {printk (KERN_ERR "capidrv: kmalloc ncci_datahandle failed\n" );return -1 ;
drivers/isdn/hisax/hfc_sx.c +3 -2
@@ -1480,8 +1480,9 @@ setup_hfcsx(struct IsdnCard *card)release_region (cs->hw.hfcsx.base,2 );return (0 ); } -if (!(cs->hw.hfcsx.extra = (void *) -kmalloc (sizeof (struct hfcsx_extra ),GFP_ATOMIC ))) { + cs->hw.hfcsx.extra =kmalloc (sizeof (struct hfcsx_extra ), +GFP_ATOMIC ); +if (!cs->hw.hfcsx.extra) {release_region (cs->hw.hfcsx.base,2 );printk (KERN_WARNING "HFC-SX: unable to allocate memory\n" );return (0 );
drivers/scsi/osst.c +2 -3
@@ -5758,8 +5758,7 @@ static int osst_probe(struct device *dev/* if this is the first attach, build the infrastructure */ write_lock (&os_scsi_tapes_lock);if (os_scsi_tapes ==NULL ) { - os_scsi_tapes = - (struct osst_tape **)kmalloc (osst_max_dev *sizeof (struct osst_tape *), -GFP_ATOMIC ); + os_scsi_tapes =kmalloc (osst_max_dev * +sizeof (struct osst_tape *),GFP_ATOMIC );if (os_scsi_tapes ==NULL ) {write_unlock (&os_scsi_tapes_lock);
drivers/block/cciss_scsi.c +1 -2
@@ -535,8 +535,7 @@ cciss_scsi_setup(int cntl_num)struct cciss_scsi_adapter_data_t * shba; ccissscsi[cntl_num].ndevices =0 ; - shba = (struct cciss_scsi_adapter_data_t *) -kmalloc (sizeof (*shba),GFP_KERNEL ); + shba =kmalloc (sizeof (*shba),GFP_KERNEL );if (shba ==NULL )return ; shba->scsi_host =NULL ;
drivers/block/floppy.c +1 -2
@@ -3194,8 +3194,7 @@ static inline int raw_cmd_copyin(int cmd *rcmd =NULL ;while (1 ) { - ptr = (struct floppy_raw_cmd *) -kmalloc (sizeof (struct floppy_raw_cmd ),GFP_USER ); + ptr =kmalloc (sizeof (struct floppy_raw_cmd ),GFP_USER );if (!ptr)return -ENOMEM ; *rcmd = ptr;
drivers/block/cciss.c +1 -2
@@ -1073,8 +1073,7 @@ static int cciss_ioctl(struct inode *inoreturn -EINVAL ;if (!capable (CAP_SYS_RAWIO ))return -EPERM ; - ioc = (BIG_IOCTL_Command_struct *) -kmalloc (sizeof (*ioc),GFP_KERNEL ); + ioc =kmalloc (sizeof (*ioc),GFP_KERNEL );if (!ioc) { status = -ENOMEM ; goto cleanup1;
drivers/media/video/vino.c +4 -4
@@ -848,8 +848,8 @@ static int vino_allocate_buffer(struct v size, count);/* allocate memory for table with virtual (page) addresses */ - fb->desc_table.virtual = (unsigned long *) -kmalloc (count *sizeof (unsigned long ),GFP_KERNEL ); + fb->desc_table.virtual =kmalloc (count * +sizeof (unsigned long ),GFP_KERNEL );if (!fb->desc_table.virtual)return -ENOMEM ;
@@ -935,8 +934,8 @@ static int vino_prepare_user_buffer(stru size, count);/* allocate memory for table with virtual (page) addresses */ - fb->desc_table.virtual = (unsigned long *) -kmalloc (count *sizeof (unsigned long ),GFP_KERNEL ); + fb->desc_table.virtual =kmalloc (count * +sizeof (unsigned long ),GFP_KERNEL );if (!fb->desc_table.virtual)return -ENOMEM ;
drivers/message/i2o/i2o_config.c +1 -2
@@ -1053,8 +1053,7 @@ static int i2o_cfg_ioctl(struct inode *istatic int cfg_open (struct inode *inode,struct file *file) { -struct i2o_cfg_info *tmp = - (struct i2o_cfg_info *)kmalloc (sizeof (struct i2o_cfg_info ), +struct i2o_cfg_info *tmp =kmalloc (sizeof (struct i2o_cfg_info ),GFP_KERNEL );unsigned long flags;
drivers/usb/storage/isd200.c +1 -2
@@ -1496,8 +1496,7 @@ static int isd200_init_info(struct us_daelse { info->id = (struct hd_driveid *)kzalloc (sizeof (struct hd_driveid ),GFP_KERNEL ); - info->RegsBuf = (unsigned char *) -kmalloc (sizeof (info->ATARegs),GFP_KERNEL ); + info->RegsBuf =kmalloc (sizeof (info->ATARegs),GFP_KERNEL ); info->srb.sense_buffer =kmalloc (SCSI_SENSE_BUFFERSIZE ,GFP_KERNEL );if (!info->id || !info->RegsBuf || !info->srb.sense_buffer) {
drivers/mtd/maps/tqm8xxl.c +1 -1
@@ -141,7 +141,7 @@ int __init init_tqm_mtd(void) goto error_mem; } - map_banks[idx]->name = (char *)kmalloc (16 ,GFP_KERNEL ); + map_banks[idx]->name =kmalloc (16 ,GFP_KERNEL );if (!map_banks[idx]->name) { ret = -ENOMEM ;
net/sctp/protocol.c +2 -2
@@ -1188,8 +1188,8 @@ SCTP_STATIC __init int sctp_init(void)/* Allocate and initialize the endpoint hash table. */ sctp_ep_hashsize =64 ; - sctp_ep_hashtable = (struct sctp_hashbucket *) -kmalloc (64 *sizeof (struct sctp_hashbucket ),GFP_KERNEL ); + sctp_ep_hashtable =kmalloc (64 * +sizeof (struct sctp_hashbucket ),GFP_KERNEL );if (!sctp_ep_hashtable) {printk (KERN_ERR "SCTP: Failed endpoint_hash alloc.\n" ); status = -ENOMEM ;
net/ipv6/mcast.c +1 -2
@@ -2044,8 +2044,7 @@ static int sf_setstate(struct ifmcaddr6 &psf->sf_addr))break ;if (!dpsf) { - dpsf = (struct ip6_sf_list *) -kmalloc (sizeof (*dpsf),GFP_ATOMIC ); + dpsf =kmalloc (sizeof (*dpsf),GFP_ATOMIC );if (!dpsf)continue ; *dpsf = *psf;
net/ipv4/igmp.c +1 -2
@@ -1638,8 +1638,7 @@ static int sf_setstate(struct ip_mc_listif (dpsf->sf_inaddr == psf->sf_inaddr)break ;if (!dpsf) { - dpsf = (struct ip_sf_list *) -kmalloc (sizeof (*dpsf),GFP_ATOMIC ); + dpsf =kmalloc (sizeof (*dpsf),GFP_ATOMIC );if (!dpsf)continue ; *dpsf = *psf;
fs/ufs/util.c +1 -2
@@ -26,8 +26,7 @@ struct ufs_buffer_head * _ubh_bread_ (st count = size >> uspi->s_fshift;if (count >UFS_MAXFRAG )return NULL ; - ubh = (struct ufs_buffer_head *) -kmalloc (sizeof (struct ufs_buffer_head ),GFP_KERNEL ); + ubh =kmalloc (sizeof (struct ufs_buffer_head ),GFP_KERNEL );if (!ubh)return NULL ; ubh->fragment = fragment;
fs/befs/btree.c +2 -2
@@ -436,8 +436,8 @@ befs_btree_read(struct super_block *sb, goto error; } -if ((this_node = (befs_btree_node *) -kmalloc (sizeof (befs_btree_node),GFP_NOFS )) ==NULL ) { + this_node =kmalloc (sizeof (befs_btree_node),GFP_NOFS ); +if (!this_node) {befs_error (sb,"befs_btree_read() failed to allocate %u " "bytes of memory" ,sizeof (befs_btree_node)); goto error;
security/selinux/ss/conditional.c +2 -2
@@ -171,8 +171,8 @@ void cond_policydb_destroy(struct policyint cond_init_bool_indexes (struct policydb *p) {kfree (p->bool_val_to_struct); - p->bool_val_to_struct = (struct cond_bool_datum **) -kmalloc (p->p_bools.nprim *sizeof (struct cond_bool_datum *),GFP_KERNEL ); + p->bool_val_to_struct =kmalloc (p->p_bools.nprim * +sizeof (struct cond_bool_datum *),GFP_KERNEL );if (!p->bool_val_to_struct)return -1 ;return 0 ;
arch/powerpc/kernel/nvram_64.c +1 -2
@@ -527,8 +527,7 @@ static int nvram_scan_partitions(void) "detected: 0-length partition\n"); goto out; } - tmp_part = (struct nvram_partition *) -kmalloc (sizeof (struct nvram_partition ),GFP_KERNEL ); + tmp_part =kmalloc (sizeof (struct nvram_partition ),GFP_KERNEL ); err = -ENOMEM ;if (!tmp_part) {printk (KERN_ERR "nvram_scan_partitions: kmalloc failed\n" );
arch/cris/arch-v32/mm/intmem.c +5 -8
@@ -33,8 +33,8 @@ static void crisv32_intmem_init(void) {static int initiated =0 ;if (!initiated) { -struct intmem_allocation * alloc = - (struct intmem_allocation *)kmalloc (sizeof *alloc,GFP_KERNEL ); +struct intmem_allocation *alloc = +kmalloc (sizeof (*alloc),GFP_KERNEL );INIT_LIST_HEAD (&intmem_allocations); intmem_virtual =ioremap (MEM_INTMEM_START +RESERVED_SIZE ,MEM_INTMEM_SIZE -RESERVED_SIZE );
@@ -62,9 +61,8 @@ void* crisv32_intmem_alloc(unsigned sizeif (allocation->status ==STATUS_FREE && allocation->size >= size + alignment) {if (allocation->size > size + alignment) { -struct intmem_allocation * alloc = - (struct intmem_allocation *) -kmalloc (sizeof *alloc,GFP_ATOMIC ); +struct intmem_allocation *alloc = +kmalloc (sizeof (*alloc),GFP_ATOMIC ); alloc->status =STATUS_FREE ; alloc->size = allocation->size - size - alignment;
@@ -74,8 +71,6 @@ void* crisv32_intmem_alloc(unsigned sizeif (alignment) {struct intmem_allocation *tmp; - tmp = (struct intmem_allocation *) -kmalloc (sizeof *tmp, -GFP_ATOMIC ); + tmp =kmalloc (sizeof (*tmp),GFP_ATOMIC ); tmp->offset = allocation->offset; tmp->size = alignment;
arch/ia64/kernel/mca_drv.c +2 -2
@@ -348,8 +348,8 @@ init_record_index_pools(void)/* - 3 - */ slidx_pool.max_idx = (rec_max_size/sect_min_size) *2 +1 ; - slidx_pool.buffer = (slidx_list_t *) -kmalloc (slidx_pool.max_idx *sizeof (slidx_list_t),GFP_KERNEL ); + slidx_pool.buffer =kmalloc (slidx_pool.max_idx * +sizeof (slidx_list_t),GFP_KERNEL );return slidx_pool.buffer ?0 : -ENOMEM ; }