You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
some kmalloc/memset ->kzalloc (tree wide)
Transform some calls to kmalloc/memset to a single kzalloc (or kcalloc). Here is a short excerpt of the semantic patch performing this transformation: @@ type T2; expression x; identifier f,fld; expression E; expression E1,E2; expression e1,e2,e3,y; statement S; @@ x = - kmalloc + kzalloc (E1,E2) ... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\) - memset((T2)x,0,E1); @@ expression E1,E2,E3; @@ - kzalloc(E1 * E2,E3) + kcalloc(E1,E2,E3) [akpm@linux-foundation.org: get kcalloc args the right way around] Signed-off-by: Yoann Padioleau <padator@wanadoo.fr> Cc: Richard Henderson <rth@twiddle.net> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Acked-by: Russell King <rmk@arm.linux.org.uk> Cc: Bryan Wu <bryan.wu@analog.com> Acked-by: Jiri Slaby <jirislaby@gmail.com> Cc: Dave Airlie <airlied@linux.ie> Acked-by: Roland Dreier <rolandd@cisco.com> Cc: Jiri Kosina <jkosina@suse.cz> Acked-by: Dmitry Torokhov <dtor@mail.ru> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Acked-by: Mauro Carvalho Chehab <mchehab@infradead.org> Acked-by: Pierre Ossman <drzeus-list@drzeus.cx> Cc: Jeff Garzik <jeff@garzik.org> Cc: "David S. Miller" <davem@davemloft.net> Acked-by: Greg KH <greg@kroah.com> Cc: James Bottomley <James.Bottomley@steeleye.com> Cc: "Antonino A. Daplas" <adaplas@pol.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
3b5ad0797c
commit
dd00cc486a
@@ -365,10 +365,9 @@ static struct macio_dev * macio_add_one_device(struct macio_chip *chip,
|
||||
if (np == NULL)
|
||||
return NULL;
|
||||
|
||||
dev = kmalloc(sizeof(*dev), GFP_KERNEL);
|
||||
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
|
||||
if (!dev)
|
||||
return NULL;
|
||||
memset(dev, 0, sizeof(*dev));
|
||||
|
||||
dev->bus = &chip->lbus;
|
||||
dev->media_bay = in_bay;
|
||||
|
||||
@@ -1053,10 +1053,9 @@ static int smu_open(struct inode *inode, struct file *file)
|
||||
struct smu_private *pp;
|
||||
unsigned long flags;
|
||||
|
||||
pp = kmalloc(sizeof(struct smu_private), GFP_KERNEL);
|
||||
pp = kzalloc(sizeof(struct smu_private), GFP_KERNEL);
|
||||
if (pp == 0)
|
||||
return -ENOMEM;
|
||||
memset(pp, 0, sizeof(struct smu_private));
|
||||
spin_lock_init(&pp->lock);
|
||||
pp->mode = smu_file_commands;
|
||||
init_waitqueue_head(&pp->wait);
|
||||
|
||||
@@ -318,10 +318,9 @@ static struct i2c_client *attach_i2c_chip(int id, const char *name)
|
||||
if (adap == NULL)
|
||||
return NULL;
|
||||
|
||||
clt = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
|
||||
clt = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
|
||||
if (clt == NULL)
|
||||
return NULL;
|
||||
memset(clt, 0, sizeof(struct i2c_client));
|
||||
|
||||
clt->addr = (id >> 1) & 0x7f;
|
||||
clt->adapter = adap;
|
||||
|
||||
@@ -431,9 +431,8 @@ do_probe( struct i2c_adapter *adapter, int addr, int kind )
|
||||
| I2C_FUNC_SMBUS_WRITE_BYTE) )
|
||||
return 0;
|
||||
|
||||
if( !(cl=kmalloc(sizeof(*cl), GFP_KERNEL)) )
|
||||
if( !(cl=kzalloc(sizeof(*cl), GFP_KERNEL)) )
|
||||
return -ENOMEM;
|
||||
memset( cl, 0, sizeof(struct i2c_client) );
|
||||
|
||||
cl->addr = addr;
|
||||
cl->adapter = adapter;
|
||||
|
||||
@@ -117,10 +117,9 @@ static struct wf_lm75_sensor *wf_lm75_create(struct i2c_adapter *adapter,
|
||||
DBG("wf_lm75: creating %s device at address 0x%02x\n",
|
||||
ds1775 ? "ds1775" : "lm75", addr);
|
||||
|
||||
lm = kmalloc(sizeof(struct wf_lm75_sensor), GFP_KERNEL);
|
||||
lm = kzalloc(sizeof(struct wf_lm75_sensor), GFP_KERNEL);
|
||||
if (lm == NULL)
|
||||
return NULL;
|
||||
memset(lm, 0, sizeof(struct wf_lm75_sensor));
|
||||
|
||||
/* Usual rant about sensor names not beeing very consistent in
|
||||
* the device-tree, oh well ...
|
||||
|
||||
Reference in New Issue
Block a user