Skip to contentSkip to conversation

checkpatch bug: space between left parenthesis and asterisk

DISCUSSION Timur Tabi 3 participants 4 messages Oct 30, 2007

lore
Share & tools
lore

Timur Tabi

author
#0 lore raw

I'm running checkpatch.pl (dated 10/17), and it complains about this line:

crc = __be32_to_cpu(* ((__be32 *) ((void *) firmware + calc_size)));

the message I get is:

ERROR: need space before that '*' (ctx:BxW)
#721: FILE: arch/powerpc/sysdev/qe_lib/qe.c:527:

+       crc = __be32_to_cpu(* ((__be32 *) ((void *) firmware + calc_size)));
                            ^

so I add a space, and now I get this:

ERROR: no space after that open parenthesis '('
#721: FILE: arch/powerpc/sysdev/qe_lib/qe.c:527:
+ crc = __be32_to_cpu( * ((__be32 *) ((void *) firmware + calc_size)));

#1 lore raw
Quoted 3 lines · Timur Tabi

I'm running checkpatch.pl (dated 10/17), and it complains about this line:

crc = __be32_to_cpu(* ((__be32 *) ((void *) firmware + calc_size)));

Well, that is a bit of a stinker. Maybe it could be reworked a little to make it easier for humans and checkpatch to understand?

  __be32 *crazy_pointer = (void *)firmware + calc_size;
  crc = be32_to_cpu(*crazy_pointer);

(Does this need to worry about get_unaligned() at all?)

- z

author
#2 lore raw
Quoted 10 lines · Zach Brown
Quoted 3 lines · Timur Tabi

I'm running checkpatch.pl (dated 10/17), and it complains about this line:

crc = __be32_to_cpu(* ((__be32 *) ((void *) firmware + calc_size)));

Well, that is a bit of a stinker. Maybe it could be reworked a little to make it easier for humans and checkpatch to understand?

  __be32 *crazy_pointer = (void *)firmware + calc_size;
  crc = be32_to_cpu(*crazy_pointer);

I admit the code might be convoluted, but it's perfectly valid, and it eliminates the need for "crazy_pointer". I'm much more inclined to ignore the checkpatch error than to redesign my code.

Besides, your argument is a bit of a strawman. The real problem is with checkpatch.

Quoted 1 line

(Does this need to worry about get_unaligned() at all?)

Well, I suppose it's technically possible, but only if my data has been corrupted.

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale
#3 lore raw
In reply to Timur Tabi
Quoted 9 lines · Timur Tabi

I'm running checkpatch.pl (dated 10/17), and it complains about this line:

crc = __be32_to_cpu(* ((__be32 *) ((void *) firmware + calc_size)));

the message I get is:

ERROR: need space before that '*' (ctx:BxW)
#721: FILE: arch/powerpc/sysdev/qe_lib/qe.c:527:
+ crc = __be32_to_cpu(* ((__be32 *) ((void *) firmware + calc_size)));

Hmmm, i've looked back a couple of releases and this seems to get reported correctly. Removing this space is then silent.

ERROR: no space after that '*' (ctx:BxW)
#4: FILE: Z31.c:1:
+ crc = __be32_to_cpu(* ((__be32 *) ((void *) firmware + calc_size)));

What version is checkpatch reported as? Also can I have the entire diff hunk this is from in case its being caused by the context, though that seems unlikely.

Thanks.

-apw