Skip to contentSkip to conversation

checkpatch: ERROR due to * recognized as operator

Qemu-devel Andreas Färber 2 participants 3 messages Feb 9, 2012 – Feb 11, 2012

lore
Share & tools
lore
#0 lore raw

Hello Blue,

I recently stumbled over the following checkpatch.pl false positive:

--8<--

hw/his.c +1 -1
@@ -1,1 +1,1 @@
-    cpu_reset(CPUState *env);
+    cpu_state_reset(CPUState *env);
hw/hers.c +1 -1
@@ -1,1 +1,1 @@
-    cpu_reset(CPUX86State *env);
+    cpu_state_reset(CPUX86State *env);
hw/its.c +1 -1
@@ -1,1 +1,1 @@
-cpu_reset(CPUState *env);
+cpu_state_reset(CPUState *env);
hw/theirs.c +1 -1
@@ -1,2 +1,2 @@
 typedef struct CPUState CPUState;
-cpu_reset(CPUState *env);
+cpu_state_reset(CPUState *env);

--8<--

results in:

ERROR: need consistent spacing around '*' (ctx:WxV) #5: FILE: hw/his.c:1:

+    cpu_state_reset(CPUState *env);
                              ^

ERROR: need consistent spacing around '*' (ctx:WxV) #11: FILE: hw/hers.c:1:

+    cpu_state_reset(CPUX86State *env);
                                 ^

ERROR: need consistent spacing around '*' (ctx:WxV) #17: FILE: hw/its.c:1:

+cpu_state_reset(CPUState *env);
                          ^

ERROR: need consistent spacing around '*' (ctx:WxV) #24: FILE: hw/theirs.c:2:

+cpu_state_reset(CPUState *env);
                          ^

total: 4 errors, 0 warnings, 9 lines checked

So, it seems to interpret the * symbol as multiplication rather than pointer.

Surprisingly, in my real code, using CPUState in place of CPUX86State was actually able to remedy the ERROR but not in this simplified test case. I added some prints around that place and it seems, in the working CPUState case it didn't even enter the op checking code path.

Any ideas?

Regards,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#1 lore raw
Quoted 62 lines · Andreas Färber

Hello Blue,

I recently stumbled over the following checkpatch.pl false positive:

--8<--

hw/his.c +1 -1
@@ -1,1 +1,1 @@
-    cpu_reset(CPUState *env);
+    cpu_state_reset(CPUState *env);
hw/hers.c +1 -1
@@ -1,1 +1,1 @@
-    cpu_reset(CPUX86State *env);
+    cpu_state_reset(CPUX86State *env);
hw/its.c +1 -1
@@ -1,1 +1,1 @@
-cpu_reset(CPUState *env);
+cpu_state_reset(CPUState *env);
hw/theirs.c +1 -2
@@ -1,2 +1,2 @@
  typedef struct CPUState CPUState;
-cpu_reset(CPUState *env);
+cpu_state_reset(CPUState *env);
 
--8<--

results in:

ERROR: need consistent spacing around '*' (ctx:WxV) #5: FILE: hw/his.c:1:
+    cpu_state_reset(CPUState *env);
                             ^

ERROR: need consistent spacing around '*' (ctx:WxV) #11: FILE: hw/hers.c:1:
+    cpu_state_reset(CPUX86State *env);
                                ^

ERROR: need consistent spacing around '*' (ctx:WxV) #17: FILE: hw/its.c:1:
+cpu_state_reset(CPUState *env);
                         ^

ERROR: need consistent spacing around '*' (ctx:WxV) #24: FILE: hw/theirs.c:2:
+cpu_state_reset(CPUState *env);
                         ^

total: 4 errors, 0 warnings, 9 lines checked

So, it seems to interpret the * symbol as multiplication rather than pointer.

Quoted 6 lines

Surprisingly, in my real code, using CPUState in place of CPUX86State was actually able to remedy the ERROR but not in this simplified test case. I added some prints around that place and it seems, in the working CPUState case it didn't even enter the op checking code path.

Any ideas?

IIRC Linux does not use typedefs much, so maybe typedefs combined with #defines confuse checkpatch.pl.

But I don't know why this case would be different to:
typedef long long int64_t;
#define off_t int64_t
void func(off_t *e);

Perhaps using a typedef in place of #define could help but I'd not make such a change just to silence checkpatch.

Quoted 7 lines

Regards,
Andreas

--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

#2 lore raw

Am 11.02.2012 10:26, schrieb Blue Swirl:

Quoted 73 lines · Andreas Färber
Quoted 62 lines

Hello Blue,

I recently stumbled over the following checkpatch.pl false positive:

--8<--

hw/his.c +1 -1
@@ -1,1 +1,1 @@
-    cpu_reset(CPUState *env);
+    cpu_state_reset(CPUState *env);
hw/hers.c +1 -1
@@ -1,1 +1,1 @@
-    cpu_reset(CPUX86State *env);
+    cpu_state_reset(CPUX86State *env);
hw/its.c +1 -1
@@ -1,1 +1,1 @@
-cpu_reset(CPUState *env);
+cpu_state_reset(CPUState *env);
hw/theirs.c +1 -2
@@ -1,2 +1,2 @@
 typedef struct CPUState CPUState;
-cpu_reset(CPUState *env);
+cpu_state_reset(CPUState *env);
 
--8<--

results in:

ERROR: need consistent spacing around '*' (ctx:WxV) #5: FILE: hw/his.c:1:

+    cpu_state_reset(CPUState *env);
                             ^

ERROR: need consistent spacing around '*' (ctx:WxV) #11: FILE: hw/hers.c:1:

+    cpu_state_reset(CPUX86State *env);
                                ^

ERROR: need consistent spacing around '*' (ctx:WxV) #17: FILE: hw/its.c:1:

+cpu_state_reset(CPUState *env);
                         ^

ERROR: need consistent spacing around '*' (ctx:WxV) #24: FILE: hw/theirs.c:2:

+cpu_state_reset(CPUState *env);
                         ^

total: 4 errors, 0 warnings, 9 lines checked

So, it seems to interpret the * symbol as multiplication rather than pointer.

Quoted 6 lines

Surprisingly, in my real code, using CPUState in place of CPUX86State was actually able to remedy the ERROR but not in this simplified test case. I added some prints around that place and it seems, in the working CPUState case it didn't even enter the op checking code path.

Any ideas?

IIRC Linux does not use typedefs much, so maybe typedefs combined with #defines confuse checkpatch.pl.

Quoted 4 lines

But I don't know why this case would be different to:
typedef long long int64_t;
#define off_t int64_t
void func(off_t *e);

I don't think typedefs matter but there was a specific regex for *_t.

Andreas

Quoted 11 lines

Perhaps using a typedef in place of #define could help but I'd not make such a change just to silence checkpatch.

Quoted 7 lines

Regards,
Andreas

--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg