2011-05-15 03:25:06

by anish singh

[permalink] [raw]
Subject: [PATCH 2/3] preferred form for passing a size to memory allocation routines

The preferred form for passing a size of a struct is the following:
p = kmalloc(sizeof(*p), ...);
Please refer Documentation/Codingstyle chapter 14
Signed-off-by: anish kumar<[email protected]>
---
drivers/staging/sm7xx/smtcfb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/sm7xx/smtcfb.c
b/drivers/staging/sm7xx/smtcfb.c
index c1b8228..d1dd387 100644
--- a/drivers/staging/sm7xx/smtcfb.c
+++ b/drivers/staging/sm7xx/smtcfb.c
@@ -684,7 +684,7 @@ static struct smtcfb_info *smtc_alloc_fb_info(struct
pci_dev *dev,
{
struct smtcfb_info *sfb;

- sfb = kzalloc(sizeof(struct smtcfb_info), GFP_KERNEL);
+ sfb = kzalloc(sizeof(*sfb), GFP_KERNEL);

if (!sfb)
return NULL;
--
1.7.0.4



2011-05-15 09:37:25

by jiaweiwei

[permalink] [raw]
Subject: Re: [PATCH 2/3] preferred form for passing a size to memory allocation routines

On Sat, May 14, 2011 at 11:25:04PM +0530, anish wrote:
> The preferred form for passing a size of a struct is the following:
> p = kmalloc(sizeof(*p), ...);
> Please refer Documentation/Codingstyle chapter 14
> Signed-off-by: anish kumar<[email protected]>
> - sfb = kzalloc(sizeof(struct smtcfb_info), GFP_KERNEL);
> + sfb = kzalloc(sizeof(*sfb), GFP_KERNEL);
Hi anish,
Good catch ;)
Acked-by: Harry Wei <[email protected]>

2011-05-16 15:49:39

by anish singh

[permalink] [raw]
Subject: [PATCH 2/3] preferred form for passing a size to memory allocation routines[staging sm7xx]

The preferred form for passing a size of a struct is the following:
p = kmalloc(sizeof(*p), ...);
Please refer Documentation/Codingstyle chapter 14
Signed-off-by: anish kumar<[email protected]>
Acked-by: Harry Wei <[email protected]>
---
drivers/staging/sm7xx/smtcfb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/sm7xx/smtcfb.c b/drivers/staging/sm7xx/smtcfb.c
index 1aca0cb..c41d2f7 100644
--- a/drivers/staging/sm7xx/smtcfb.c
+++ b/drivers/staging/sm7xx/smtcfb.c
@@ -714,7 +714,7 @@ static struct smtcfb_info *smtc_alloc_fb_info(struct pci_dev *dev,
{
struct smtcfb_info *sfb;

- sfb = kzalloc(sizeof(struct smtcfb_info), GFP_KERNEL);
+ sfb = kzalloc(sizeof(*sfb), GFP_KERNEL);

if (!sfb)
return NULL;
--
1.7.0.4