Skip to contentSkip to conversation

iio: Use parens with sizeof

PATCH In review Joe Simmons-Talbott 3 participants 5 messages Jul 17, 2022 – Jul 31, 2022 IIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: Use parens with sizeof

Prefer 'sizeof(var)' over 'sizeof var' as reported by checkpatch.pl.

---
 drivers/iio/industrialio-trigger.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/industrialio-trigger.c +2 -2
index f504ed351b3e..88bccb0676c8 100644
@@ -368,7 +368,7 @@ struct iio_poll_func
 	va_list vargs;
 	struct iio_poll_func *pf;
 
-	pf = kmalloc(sizeof *pf, GFP_KERNEL);
+	pf = kmalloc(sizeof(*pf), GFP_KERNEL);
 	if (pf == NULL)
 		return NULL;
 	va_start(vargs, fmt);
@@ -560,7 +560,7 @@ struct iio_trigger *viio_trigger_alloc(struct device *parent,
 	struct iio_trigger *trig;
 	int i;
 
-	trig = kzalloc(sizeof *trig, GFP_KERNEL);
+	trig = kzalloc(sizeof(*trig), GFP_KERNEL);
 	if (!trig)
 		return NULL;
 
Signature · 1 line
2.35.3
#1 lore raw
Quoted 1 line · Joe Simmons-Talbott

Prefer 'sizeof(var)' over 'sizeof var' as reported by checkpatch.pl.

unrelated trivia:

drivers/iio/industrialio-trigger.c

Quoted 1 line
drivers/iio/industrialio-trigger.c +0 -0

[]

Quoted 10 lines
drivers/iio/industrialio-trigger.c +1 -1
@@ -368,7 +368,7 @@ struct iio_poll_func
 	va_list vargs;
 	struct iio_poll_func *pf;
 
-	pf = kmalloc(sizeof *pf, GFP_KERNEL);
+	pf = kmalloc(sizeof(*pf), GFP_KERNEL);
 	if (pf == NULL)
 		return NULL;
 	va_start(vargs, fmt);

drivers/iio/industrialio-trigger.c struct iio_trigger *viio_trigger_alloc(struct device *parent, · line 565

Quoted 7 lines
drivers/iio/industrialio-trigger.c +1 -1
@@ -560,7 +560,7 @@ struct iio_trigger *viio_trigger_alloc(struct device *parent,
 	struct iio_trigger *trig;
 	int i;
 
-	trig = kzalloc(sizeof *trig, GFP_KERNEL);
+	trig = kzalloc(sizeof(*trig), GFP_KERNEL);
 	if (!trig)
 		return NULL;

It'd be nice to be consistent with the allocation return test.

Please pick one of:

	if (ptr == NULL)
or
	if (!ptr)		// my preference
#2 lore raw
Quoted 27 lines · Joe Perches
Quoted 1 line · Joe Simmons-Talbott

Prefer 'sizeof(var)' over 'sizeof var' as reported by checkpatch.pl.

unrelated trivia:

drivers/iio/industrialio-trigger.c

Quoted 1 line
drivers/iio/industrialio-trigger.c +0 -0

[]

Quoted 10 lines
drivers/iio/industrialio-trigger.c +1 -1
@@ -368,7 +368,7 @@ struct iio_poll_func
 	va_list vargs;
 	struct iio_poll_func *pf;
 
-	pf = kmalloc(sizeof *pf, GFP_KERNEL);
+	pf = kmalloc(sizeof(*pf), GFP_KERNEL);
 	if (pf == NULL)
 		return NULL;
 	va_start(vargs, fmt);

drivers/iio/industrialio-trigger.c struct iio_trigger *viio_trigger_alloc(struct device *parent, · line 565

Quoted 7 lines
drivers/iio/industrialio-trigger.c +1 -1
@@ -560,7 +560,7 @@ struct iio_trigger *viio_trigger_alloc(struct device *parent,
 	struct iio_trigger *trig;
 	int i;
 
-	trig = kzalloc(sizeof *trig, GFP_KERNEL);
+	trig = kzalloc(sizeof(*trig), GFP_KERNEL);
 	if (!trig)
 		return NULL;

It'd be nice to be consistent with the allocation return test.

Quoted 6 lines

Please pick one of:

	if (ptr == NULL)
or
	if (!ptr)		// my preference

I'm happy to submit a patch for that. Do you want me to include a
Suggested-by: tag?

Thanks,
Joe

#3 lore raw
Quoted 30 lines · Joe Simmons-Talbott
Quoted 29 lines · Joe Perches
Quoted 1 line · Joe Simmons-Talbott

Prefer 'sizeof(var)' over 'sizeof var' as reported by checkpatch.pl.

unrelated trivia:

drivers/iio/industrialio-trigger.c

Quoted 1 line
drivers/iio/industrialio-trigger.c +0 -0

[]

Quoted 10 lines
drivers/iio/industrialio-trigger.c +1 -1
@@ -368,7 +368,7 @@ struct iio_poll_func
 	va_list vargs;
 	struct iio_poll_func *pf;
 
-	pf = kmalloc(sizeof *pf, GFP_KERNEL);
+	pf = kmalloc(sizeof(*pf), GFP_KERNEL);
 	if (pf == NULL)
 		return NULL;
 	va_start(vargs, fmt);

drivers/iio/industrialio-trigger.c struct iio_trigger *viio_trigger_alloc(struct device *parent, · line 565

Quoted 7 lines
drivers/iio/industrialio-trigger.c +1 -1
@@ -560,7 +560,7 @@ struct iio_trigger *viio_trigger_alloc(struct device *parent,
 	struct iio_trigger *trig;
 	int i;
 
-	trig = kzalloc(sizeof *trig, GFP_KERNEL);
+	trig = kzalloc(sizeof(*trig), GFP_KERNEL);
 	if (!trig)
 		return NULL;

It'd be nice to be consistent with the allocation return test.

Please pick one of:

Quoted 7 lines
Quoted 4 lines
	if (ptr == NULL)
or
	if (!ptr)		// my preference

I'm happy to submit a patch for that. Do you want me to include a
Suggested-by: tag?

Not really.

maintainer
#4 lore raw
In reply to Joe Simmons-Talbott
Quoted 3 lines · On Sun, 17 Jul 2022 11:34:38 -0400 Joe Simmons-Talbott <[email protected]>…

Prefer 'sizeof(var)' over 'sizeof var' as reported by checkpatch.pl.

Applied to the togreg branch of iio.git and pushed out as testing to let 0-day take a poke at it.

oops. Email got stuck in my outbox when I went away for a week.

Thanks,

Jonathan

Quoted 26 lines
---
 drivers/iio/industrialio-trigger.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/industrialio-trigger.c +2 -2
index f504ed351b3e..88bccb0676c8 100644
@@ -368,7 +368,7 @@ struct iio_poll_func
 	va_list vargs;
 	struct iio_poll_func *pf;
 
-	pf = kmalloc(sizeof *pf, GFP_KERNEL);
+	pf = kmalloc(sizeof(*pf), GFP_KERNEL);
 	if (pf == NULL)
 		return NULL;
 	va_start(vargs, fmt);
@@ -560,7 +560,7 @@ struct iio_trigger *viio_trigger_alloc(struct device *parent,
 	struct iio_trigger *trig;
 	int i;
 
-	trig = kzalloc(sizeof *trig, GFP_KERNEL);
+	trig = kzalloc(sizeof(*trig), GFP_KERNEL);
 	if (!trig)
 		return NULL;