Skip to contentSkip to conversation

trivial: amba-clcd.c preferred form of passing size of structure

PATCH In review anish 2 participants 2 messages May 18, 2011 – May 23, 2011 Framebuffer layer

lore
Share & tools
lore

anish

author
#0 lore raw

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

The preferred form for passing a size of a struct is the following:

         p = kmalloc(sizeof(*p), ...);

Please refer Documentation/Codingstyle chapter 14

---
 drivers/video/amba-clcd.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/video/amba-clcd.c +1 -1
index 5fc983c..cb7ec86 100644
@@ -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;
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 6 lines · anish

The preferred form for passing a size of a struct is the following:

         p = kmalloc(sizeof(*p), ...);

Please refer Documentation/Codingstyle chapter 14

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..