* [PATCH] lib/fib: remove warning about implicit 64-bit conversion
@ 2024-12-04 2:56 Andre Muezerie
2024-12-04 22:59 ` Stephen Hemminger
2024-12-05 15:38 ` [PATCH v2] " Andre Muezerie
0 siblings, 2 replies; 4+ messages in thread
From: Andre Muezerie @ 2024-12-04 2:56 UTC (permalink / raw)
To: Vladimir Medvedkin; +Cc: dev, Andre Muezerie
MSVC issues the warning below:
../lib/fib/trie.c(341): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits
(was 64-bit shift intended?)
The fix is to cast the result explicitly to ptrdiff_t since it is used
in pointer arithmetic.
Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
lib/fib/trie.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/fib/trie.c b/lib/fib/trie.c
index 4893f6c636..997b7cc338 100644
--- a/lib/fib/trie.c
+++ b/lib/fib/trie.c
@@ -338,7 +338,7 @@ write_edge(struct rte_trie_tbl *dp, const uint8_t *ip_part, uint64_t next_hop,
if (ret < 0)
return ret;
if (edge == LEDGE) {
- write_to_dp((uint8_t *)p + (1 << dp->nh_sz),
+ write_to_dp((uint8_t *)p + (ptrdiff_t)(1 << dp->nh_sz),
next_hop << 1, dp->nh_sz, UINT8_MAX - *ip_part);
} else {
write_to_dp(get_tbl_p_by_idx(dp->tbl8, tbl8_idx *
--
2.47.0.vfs.0.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] lib/fib: remove warning about implicit 64-bit conversion
2024-12-04 2:56 [PATCH] lib/fib: remove warning about implicit 64-bit conversion Andre Muezerie
@ 2024-12-04 22:59 ` Stephen Hemminger
2024-12-05 15:34 ` Andre Muezerie
2024-12-05 15:38 ` [PATCH v2] " Andre Muezerie
1 sibling, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2024-12-04 22:59 UTC (permalink / raw)
To: Andre Muezerie; +Cc: Vladimir Medvedkin, dev
On Tue, 3 Dec 2024 18:56:50 -0800
Andre Muezerie <andremue@linux.microsoft.com> wrote:
> MSVC issues the warning below:
>
> ../lib/fib/trie.c(341): warning C4334: '<<':
> result of 32-bit shift implicitly converted to 64 bits
> (was 64-bit shift intended?)
>
> The fix is to cast the result explicitly to ptrdiff_t since it is used
> in pointer arithmetic.
>
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> ---
> lib/fib/trie.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/fib/trie.c b/lib/fib/trie.c
> index 4893f6c636..997b7cc338 100644
> --- a/lib/fib/trie.c
> +++ b/lib/fib/trie.c
> @@ -338,7 +338,7 @@ write_edge(struct rte_trie_tbl *dp, const uint8_t *ip_part, uint64_t next_hop,
> if (ret < 0)
> return ret;
> if (edge == LEDGE) {
> - write_to_dp((uint8_t *)p + (1 << dp->nh_sz),
> + write_to_dp((uint8_t *)p + (ptrdiff_t)(1 << dp->nh_sz),
> next_hop << 1, dp->nh_sz, UINT8_MAX - *ip_part);
You would be better to use a 64 bit shift or RTE_BIT64 for this.
write_to_dp((uint8_t *)p + ((uintptr_t)1 << dp->nh_sz),
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] lib/fib: remove warning about implicit 64-bit conversion
2024-12-04 22:59 ` Stephen Hemminger
@ 2024-12-05 15:34 ` Andre Muezerie
0 siblings, 0 replies; 4+ messages in thread
From: Andre Muezerie @ 2024-12-05 15:34 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Vladimir Medvedkin, dev
On Wed, Dec 04, 2024 at 02:59:40PM -0800, Stephen Hemminger wrote:
> On Tue, 3 Dec 2024 18:56:50 -0800
> Andre Muezerie <andremue@linux.microsoft.com> wrote:
>
> > MSVC issues the warning below:
> >
> > ../lib/fib/trie.c(341): warning C4334: '<<':
> > result of 32-bit shift implicitly converted to 64 bits
> > (was 64-bit shift intended?)
> >
> > The fix is to cast the result explicitly to ptrdiff_t since it is used
> > in pointer arithmetic.
> >
> > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> > ---
> > lib/fib/trie.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/fib/trie.c b/lib/fib/trie.c
> > index 4893f6c636..997b7cc338 100644
> > --- a/lib/fib/trie.c
> > +++ b/lib/fib/trie.c
> > @@ -338,7 +338,7 @@ write_edge(struct rte_trie_tbl *dp, const uint8_t *ip_part, uint64_t next_hop,
> > if (ret < 0)
> > return ret;
> > if (edge == LEDGE) {
> > - write_to_dp((uint8_t *)p + (1 << dp->nh_sz),
> > + write_to_dp((uint8_t *)p + (ptrdiff_t)(1 << dp->nh_sz),
> > next_hop << 1, dp->nh_sz, UINT8_MAX - *ip_part);
>
> You would be better to use a 64 bit shift or RTE_BIT64 for this.
>
> write_to_dp((uint8_t *)p + ((uintptr_t)1 << dp->nh_sz),
Thanks for the suggestion. I'll update the patch.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] lib/fib: remove warning about implicit 64-bit conversion
2024-12-04 2:56 [PATCH] lib/fib: remove warning about implicit 64-bit conversion Andre Muezerie
2024-12-04 22:59 ` Stephen Hemminger
@ 2024-12-05 15:38 ` Andre Muezerie
1 sibling, 0 replies; 4+ messages in thread
From: Andre Muezerie @ 2024-12-05 15:38 UTC (permalink / raw)
To: dev; +Cc: Andre Muezerie
MSVC issues the warning below:
../lib/fib/trie.c(341): warning C4334: '<<':
result of 32-bit shift implicitly converted to 64 bits
(was 64-bit shift intended?)
The fix is to cast the result explicitly to ptrdiff_t since it is used
in pointer arithmetic.
Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
lib/fib/trie.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/fib/trie.c b/lib/fib/trie.c
index 4893f6c636..959cb8803c 100644
--- a/lib/fib/trie.c
+++ b/lib/fib/trie.c
@@ -338,7 +338,7 @@ write_edge(struct rte_trie_tbl *dp, const uint8_t *ip_part, uint64_t next_hop,
if (ret < 0)
return ret;
if (edge == LEDGE) {
- write_to_dp((uint8_t *)p + (1 << dp->nh_sz),
+ write_to_dp((uint8_t *)p + ((uintptr_t)1 << dp->nh_sz),
next_hop << 1, dp->nh_sz, UINT8_MAX - *ip_part);
} else {
write_to_dp(get_tbl_p_by_idx(dp->tbl8, tbl8_idx *
--
2.47.0.vfs.0.3
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-12-05 15:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-04 2:56 [PATCH] lib/fib: remove warning about implicit 64-bit conversion Andre Muezerie
2024-12-04 22:59 ` Stephen Hemminger
2024-12-05 15:34 ` Andre Muezerie
2024-12-05 15:38 ` [PATCH v2] " Andre Muezerie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).