lib/fib: remove warning about implicit 64-bit conversion
PATCH 1/1 lib/fib: remove warning about implicit 64-bit conversion
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.
--- lib/fib/trie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/fib/trie.c +1 -1
@@ -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 *
Signature · 1 line
2.47.0.vfs.0.3
Quoted 19 lines · On Tue, 3 Dec 2024 18:56:50 -0800 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_tsince it is used in pointer arithmetic.Signed-off-by Andre Muezerie <[email protected]>--- lib/fib/trie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/fib/trie.c +0
-0
lib/fib/trie.c write_edge(struct rte_trie_tbl *dp, const uint8_t *ip_part, uint64_t next_hop, · line 342
Quoted 6 lines
lib/fib/trie.c +1
-1@@ -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),
Quoted 31 lines · Stephen Hemminger
Quoted 19 lines · On Tue, 3 Dec 2024 18:56:50 -0800 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_tsince it is used in pointer arithmetic.Signed-off-by Andre Muezerie <[email protected]>--- lib/fib/trie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/fib/trie.c +0
-0lib/fib/trie.c write_edge(struct rte_trie_tbl *dp, const uint8_t *ip_part, uint64_t next_hop, · line 342
Quoted 6 lines
lib/fib/trie.c +1
-1@@ -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_BIT64for this.
Quoted 1 line
write_to_dp((uint8_t *)p + ((uintptr_t)1 << dp->nh_sz),
Thanks for the suggestion. I'll update the patch.
PATCH v2 1/1 lib/fib: remove warning about implicit 64-bit conversion
In reply to Andre MuezerieMSVC 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.
--- lib/fib/trie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/fib/trie.c +1 -1
@@ -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 *
Signature · 1 line
2.47.0.vfs.0.3
PATCH v3 1/1 lib/fib: remove warning about implicit 64-bit conversion
In reply to Andre MuezerieMSVC 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 uintptr_t since it is used in pointer arithmetic.
--- lib/fib/trie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/fib/trie.c +1 -1
@@ -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 *
Signature · 1 line
2.48.1.vfs.0.0
Better to cast the constant (1) to avoid warning,
.
That is what other code does like RTE_BIT macros
Quoted 34 lines · On Mon, Mar 3, 2025, 23:55 Andre Muezerie <[email protected]> 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
uintptr_tsince it is used in pointer arithmetic.Signed-off-by Andre Muezerie <[email protected]>--- lib/fib/trie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/fib/trie.c +1
-1@@ -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.48.1.vfs.0.0
Quoted 3 lines · Stephen Hemminger
Better to cast the constant (1) to avoid warning,
.
That is what other code does likeRTE_BITmacros
Alright, I made that change in v4.
Quoted 38 lines
Quoted 34 lines · On Mon, Mar 3, 2025, 23:55 Andre Muezerie <[email protected]> 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
uintptr_tsince it is used in pointer arithmetic.Signed-off-by Andre Muezerie <[email protected]>--- lib/fib/trie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/fib/trie.c +1
-1@@ -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.48.1.vfs.0.0
Quoted 19 lines · 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
uintptr_tsince it is used in pointer arithmetic.Signed-off-by Andre Muezerie <[email protected]>--- lib/fib/trie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/fib/trie.c +0
-0
lib/fib/trie.c write_edge(struct rte_trie_tbl *dp, const uint8_t *ip_part, uint64_t next_hop, · line 341
Quoted 5 lines
lib/fib/trie.c +1
-1@@ -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),
Might be worth considering using the RTE_PTR_ADD macro too for this line.
/Bruce
Quoted 15 lines · Bruce Richardson
Quoted 14 lines · 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
uintptr_tsince it is used in pointer arithmetic.Signed-off-by Andre Muezerie <[email protected]>--- lib/fib/trie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines
lib/fib/trie.c write_edge(struct rte_trie_tbl *dp, const uint8_t *ip_part, uint64_t next_hop, · line 341
Quoted 10 lines
lib/fib/trie.c +1
-1@@ -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),Might be worth considering using the
RTE_PTR_ADDmacro too for this line.
Makes sense. I'm using RTE_PTR_ADD in v4.
Thanks for the suggestion.
Quoted 2 lines
/Bruce
PATCH v4 1/1 lib/fib: remove warning about implicit 64-bit conversion
In reply to Andre MuezerieMSVC 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 (1) explicitly to uintptr_t since it is used in pointer arithmetic.
--- lib/fib/trie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/fib/trie.c +1 -1
@@ -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 (RTE_PTR_ADD (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 *
Signature · 1 line
2.48.1.vfs.0.0
v5 cover enable fib to be compiled with MSVC
In reply to Andre MuezerieThis patchset addresses the issues in lib/fib that were preventing compilation with MSVC. The first patch removes a warning about implicit 64-bit conversion, and the second patch enables the compilation of fib with MSVC.
v5:
- enabled fib to be compiled with MSVC
Andre Muezerie (2):
lib/fib: remove warning about implicit 64-bit conversion lib/fib: enable fib to be compiled with MSVC
lib/fib/meson.build | 6 ------ lib/fib/trie.c | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-)
--
2.49.0.vfs.0.3
PATCH v5 1/2 lib/fib: remove warning about implicit 64-bit conversion
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 (1) explicitly to uintptr_t since it is used in pointer arithmetic.
--- lib/fib/trie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/fib/trie.c +1 -1
@@ -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 (RTE_PTR_ADD (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 *
Signature · 1 line
2.49.0.vfs.0.3
Quoted 34 lines
From: Andre Muezerie [mailto:[email protected]]
Sent: Friday, 16 May 2025 22.46MSVC 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 (1) explicitly to
uintptr_tsince it is used in pointer arithmetic.Signed-off-by Andre Muezerie <[email protected]>--- lib/fib/trie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/fib/trie.c +1
-1@@ -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(RTE_PTR_ADD(p, (uintptr_t)(1) << dp- >nh_sz), next_hop << 1, dp->nh_sz, UINT8_MAX -
*ip_part);lib/fib/trie.c +0
-1}else { write_to_dp(get_tbl_p_by_idx(dp->tbl8, tbl8_idx * --
Quoted 1 line
2.49.0.vfs.0.3
Ok.
Wonder if RTE_PTR_ADD should have the cast there instead
Quoted 34 lines · On Sat, May 17, 2025, 05:45 Andre Muezerie <[email protected]> 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 (1) explicitly to
uintptr_tsince it is used in pointer arithmetic.Signed-off-by Andre Muezerie <[email protected]>--- lib/fib/trie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/fib/trie.c +1
-1@@ -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(RTE_PTR_ADD(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.49.0.vfs.0.3
From: Stephen Hemminger [mailto:[email protected]]
Sent: Saturday, 17 May 2025 13.10
Ok.
Wonder if RTE_PTR_ADD should have the cast there instead
Morten: Considered the same; but prefer not. It will suppress warnings like this, which may be real.
On Sat, May 17, 2025, 05:45 Andre Muezerie <[email protected]> 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 (1) explicitly to uintptr_t since it is used in pointer arithmetic.
---
lib/fib/trie.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
lib/fib/trie.c +0 -0
@@ -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(RTE_PTR_ADD(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 *
Signature · 1 line
2.49.0.vfs.0.3
PATCH v5 2/2 lib/fib: enable fib to be compiled with MSVC
In reply to Andre MuezerieNow that all issues related to fib are addressed it can be enabled for MSVC.
--- lib/fib/meson.build | 6 ------ 1 file changed, 6 deletions(-)
lib/fib/meson.build +0 -6
@@ -2,12 +2,6 @@ # Copyright(c) 2018 Vladimir Medvedkin <[email protected]> # Copyright(c) 2019 Intel Corporation -if is_ms_compiler - build = false - reason = 'not supported building with Visual Studio Toolset' - subdir_done() -endif - sources = files('rte_fib.c', 'rte_fib6.c', 'dir24_8.c', 'trie.c') headers = files('rte_fib.h', 'rte_fib6.h') deps += ['rib']
Signature · 1 line
2.49.0.vfs.0.3
Re: [PATCH v5 0/2] enable fib to be compiled with MSVC
In reply to Andre MuezerieQuoted 5 lines · Andre Muezerie
This patchset addresses the issues in lib/fib that were preventing compilation with MSVC. The first patch removes a warning about implicit 64-bit conversion, and the second patch enables the compilation of fib with MSVC.
Series applied, thanks.
Signature · 1 line
David Marchand