[patch 1/2] trivial: amba-clcd.c preferred form of passing size of structure

Subsystems: framebuffer layer, the rest

STALE5616d

2 messages, 2 authors, 2011-05-23 · open the first message on its own page

[patch 1/2] trivial: amba-clcd.c preferred form of passing size of structure

From: anish <hidden>
Date: 2011-05-18 18:07:17

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 [off-list ref]

---
 drivers/video/amba-clcd.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/video/amba-clcd.c b/drivers/video/amba-clcd.c
index 5fc983c..cb7ec86 100644
--- a/drivers/video/amba-clcd.c
+++ b/drivers/video/amba-clcd.c
@@ -549,7 +549,7 @@ static int clcdfb_probe(struct amba_device *dev, const struct amba_id *id)
 		goto out;
 	}
 
-	fb = kzalloc(sizeof(struct clcd_fb), GFP_KERNEL);
+	fb = kzalloc(sizeof(*fb), GFP_KERNEL);
 	if (!fb) {
 		printk(KERN_INFO "CLCD: could not allocate new clcd_fb struct\n");
 		ret = -ENOMEM;
-- 
1.7.0.4



Re: [patch 1/2] trivial: amba-clcd.c preferred form of passing size of structure

From: Paul Mundt <hidden>
Date: 2011-05-23 07:13:30

On Wed, May 18, 2011 at 11:37:06PM +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 [off-list ref]
That's pretty subjective, and ultimately depends on the author. I
personally prefer to have it written out, but then I don't randomly
change my structure types around either, so the "bug" alluded to isn't
really an issue. I'm not sure I buy the impaired readability argument,
either..
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help