Skip to content

Commit 54e1f08

Browse files
ecsvdavem330
authored andcommitted
ipv6: Annotate ipv6_addr_is_* bitwise pointer casts
The sparse commit 6002ded74587 ("add a flag to warn on casts to/from bitwise pointers") introduced a check for non-direct casts from/to restricted datatypes (when -Wbitwise-pointer is enabled). This triggered a warning in the 64 bit optimized ipv6_addr_is_*() functions because sparse doesn't know that the buffer already points to some data in the correct bitwise integer format. But these were correct and can therefore be marked with __force to signalize sparse an intended cast to a specific bitwise type. Signed-off-by: Sven Eckelmann <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1f1c1d7 commit 54e1f08

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

include/net/addrconf.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ static inline void addrconf_addr_solict_mult(const struct in6_addr *addr,
437437
static inline bool ipv6_addr_is_ll_all_nodes(const struct in6_addr *addr)
438438
{
439439
#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
440-
__be64 *p = (__be64 *)addr;
440+
__be64 *p = (__force __be64 *)addr;
441441
return ((p[0] ^ cpu_to_be64(0xff02000000000000UL)) | (p[1] ^ cpu_to_be64(1))) == 0UL;
442442
#else
443443
return ((addr->s6_addr32[0] ^ htonl(0xff020000)) |
@@ -449,7 +449,7 @@ static inline bool ipv6_addr_is_ll_all_nodes(const struct in6_addr *addr)
449449
static inline bool ipv6_addr_is_ll_all_routers(const struct in6_addr *addr)
450450
{
451451
#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
452-
__be64 *p = (__be64 *)addr;
452+
__be64 *p = (__force __be64 *)addr;
453453
return ((p[0] ^ cpu_to_be64(0xff02000000000000UL)) | (p[1] ^ cpu_to_be64(2))) == 0UL;
454454
#else
455455
return ((addr->s6_addr32[0] ^ htonl(0xff020000)) |
@@ -466,7 +466,7 @@ static inline bool ipv6_addr_is_isatap(const struct in6_addr *addr)
466466
static inline bool ipv6_addr_is_solict_mult(const struct in6_addr *addr)
467467
{
468468
#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
469-
__be64 *p = (__be64 *)addr;
469+
__be64 *p = (__force __be64 *)addr;
470470
return ((p[0] ^ cpu_to_be64(0xff02000000000000UL)) |
471471
((p[1] ^ cpu_to_be64(0x00000001ff000000UL)) &
472472
cpu_to_be64(0xffffffffff000000UL))) == 0UL;
@@ -481,7 +481,7 @@ static inline bool ipv6_addr_is_solict_mult(const struct in6_addr *addr)
481481
static inline bool ipv6_addr_is_all_snoopers(const struct in6_addr *addr)
482482
{
483483
#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
484-
__be64 *p = (__be64 *)addr;
484+
__be64 *p = (__force __be64 *)addr;
485485

486486
return ((p[0] ^ cpu_to_be64(0xff02000000000000UL)) |
487487
(p[1] ^ cpu_to_be64(0x6a))) == 0UL;

0 commit comments

Comments
 (0)