Skip to content

Commit

Permalink
net: fix sparse warnings in SNMP_UPD_PO_STATS(_BH)
Browse files Browse the repository at this point in the history
ptr used to be a non __percpu pointer (result of a this_cpu_ptr
assignment, 7d720c3 ("percpu: add __percpu sparse annotations to
net")). Since d25398d ("net: avoid reloads in SNMP_UPD_PO_STATS"),
that's no longer the case, SNMP_UPD_PO_STATS uses this_cpu_add and ptr
is now __percpu.

Silence sparse warnings by preserving the original type and
annotation, and remove the out-of-date comment.

warning: incorrect type in initializer (different address spaces)
   expected unsigned long long *ptr
   got unsigned long long [noderef] <asn:3>*<noident>
warning: incorrect type in initializer (different address spaces)
   expected void const [noderef] <asn:3>*__vpp_verify
   got unsigned long long *<noident>
warning: incorrect type in initializer (different address spaces)
   expected void const [noderef] <asn:3>*__vpp_verify
   got unsigned long long *<noident>

Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Sabrina Dubroca authored and David S. Miller committed Sep 19, 2014
1 parent fb5690d commit 54003f1
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions include/net/snmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,15 @@ struct linux_xfrm_mib {

#define SNMP_ADD_STATS(mib, field, addend) \
this_cpu_add(mib->mibs[field], addend)
/*
* Use "__typeof__(*mib) *ptr" instead of "__typeof__(mib) ptr"
* to make @ptr a non-percpu pointer.
*/
#define SNMP_UPD_PO_STATS(mib, basefield, addend) \
do { \
__typeof__(*mib->mibs) *ptr = mib->mibs; \
__typeof__((mib->mibs) + 0) ptr = mib->mibs; \
this_cpu_inc(ptr[basefield##PKTS]); \
this_cpu_add(ptr[basefield##OCTETS], addend); \
} while (0)
#define SNMP_UPD_PO_STATS_BH(mib, basefield, addend) \
do { \
__typeof__(*mib->mibs) *ptr = mib->mibs; \
__typeof__((mib->mibs) + 0) ptr = mib->mibs; \
__this_cpu_inc(ptr[basefield##PKTS]); \
__this_cpu_add(ptr[basefield##OCTETS], addend); \
} while (0)
Expand Down

0 comments on commit 54003f1

Please sign in to comment.