* 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
` (3 subsequent siblings)
4 siblings, 1 reply; 16+ 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] 16+ 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; 16+ 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] 16+ 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
2025-03-03 22:54 ` [PATCH v3] " Andre Muezerie
` (2 subsequent siblings)
4 siblings, 0 replies; 16+ 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] 16+ messages in thread
* [PATCH v3] 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 ` [PATCH v2] " Andre Muezerie
@ 2025-03-03 22:54 ` Andre Muezerie
2025-03-04 6:49 ` Stephen Hemminger
2025-03-04 10:47 ` Bruce Richardson
2025-03-04 16:48 ` [PATCH v4] " Andre Muezerie
2025-05-16 20:45 ` [PATCH v5 0/2] enable fib to be compiled with MSVC Andre Muezerie
4 siblings, 2 replies; 16+ messages in thread
From: Andre Muezerie @ 2025-03-03 22:54 UTC (permalink / raw)
To: andremue; +Cc: dev, vladimir.medvedkin
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_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..bf9f63eaa2 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.48.1.vfs.0.0
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3] lib/fib: remove warning about implicit 64-bit conversion
2025-03-03 22:54 ` [PATCH v3] " Andre Muezerie
@ 2025-03-04 6:49 ` Stephen Hemminger
2025-03-04 16:51 ` Andre Muezerie
2025-03-04 10:47 ` Bruce Richardson
1 sibling, 1 reply; 16+ messages in thread
From: Stephen Hemminger @ 2025-03-04 6:49 UTC (permalink / raw)
To: Andre Muezerie; +Cc: dev, Medvedkin, Vladimir
[-- Attachment #1: Type: text/plain, Size: 1311 bytes --]
Better to cast the constant (1) to avoid warning,
.
That is what other code does like RTE_BIT macros
On Mon, Mar 3, 2025, 23:55 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 uintptr_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..bf9f63eaa2 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.48.1.vfs.0.0
>
>
[-- Attachment #2: Type: text/html, Size: 1978 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3] lib/fib: remove warning about implicit 64-bit conversion
2025-03-04 6:49 ` Stephen Hemminger
@ 2025-03-04 16:51 ` Andre Muezerie
0 siblings, 0 replies; 16+ messages in thread
From: Andre Muezerie @ 2025-03-04 16:51 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev, Medvedkin, Vladimir
On Mon, Mar 03, 2025 at 10:49:52PM -0800, Stephen Hemminger wrote:
> Better to cast the constant (1) to avoid warning,
> .
> That is what other code does like RTE_BIT macros
Alright, I made that change in v4.
>
> On Mon, Mar 3, 2025, 23:55 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 uintptr_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..bf9f63eaa2 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.48.1.vfs.0.0
> >
> >
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3] lib/fib: remove warning about implicit 64-bit conversion
2025-03-03 22:54 ` [PATCH v3] " Andre Muezerie
2025-03-04 6:49 ` Stephen Hemminger
@ 2025-03-04 10:47 ` Bruce Richardson
2025-03-04 16:52 ` Andre Muezerie
1 sibling, 1 reply; 16+ messages in thread
From: Bruce Richardson @ 2025-03-04 10:47 UTC (permalink / raw)
To: Andre Muezerie; +Cc: dev, vladimir.medvedkin
On Mon, Mar 03, 2025 at 02:54:52PM -0800, Andre Muezerie 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_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..bf9f63eaa2 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),
Might be worth considering using the RTE_PTR_ADD macro too for this line.
/Bruce
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v3] lib/fib: remove warning about implicit 64-bit conversion
2025-03-04 10:47 ` Bruce Richardson
@ 2025-03-04 16:52 ` Andre Muezerie
0 siblings, 0 replies; 16+ messages in thread
From: Andre Muezerie @ 2025-03-04 16:52 UTC (permalink / raw)
To: Bruce Richardson; +Cc: dev, vladimir.medvedkin
On Tue, Mar 04, 2025 at 10:47:28AM +0000, Bruce Richardson wrote:
> On Mon, Mar 03, 2025 at 02:54:52PM -0800, Andre Muezerie 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_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..bf9f63eaa2 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),
>
> Might be worth considering using the RTE_PTR_ADD macro too for this line.
Makes sense. I'm using RTE_PTR_ADD in v4.
Thanks for the suggestion.
>
> /Bruce
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v4] 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
` (2 preceding siblings ...)
2025-03-03 22:54 ` [PATCH v3] " Andre Muezerie
@ 2025-03-04 16:48 ` Andre Muezerie
2025-05-16 20:45 ` [PATCH v5 0/2] enable fib to be compiled with MSVC Andre Muezerie
4 siblings, 0 replies; 16+ messages in thread
From: Andre Muezerie @ 2025-03-04 16:48 UTC (permalink / raw)
To: andremue; +Cc: dev, vladimir.medvedkin
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.
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..f077b65a28 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(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.48.1.vfs.0.0
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v5 0/2] enable fib to be compiled with MSVC
2024-12-04 2:56 [PATCH] lib/fib: remove warning about implicit 64-bit conversion Andre Muezerie
` (3 preceding siblings ...)
2025-03-04 16:48 ` [PATCH v4] " Andre Muezerie
@ 2025-05-16 20:45 ` Andre Muezerie
2025-05-16 20:45 ` [PATCH v5 1/2] lib/fib: remove warning about implicit 64-bit conversion Andre Muezerie
2025-05-16 20:45 ` [PATCH v5 2/2] lib/fib: enable fib to be compiled with MSVC Andre Muezerie
4 siblings, 2 replies; 16+ messages in thread
From: Andre Muezerie @ 2025-05-16 20:45 UTC (permalink / raw)
To: andremue; +Cc: dev, vladimir.medvedkin
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.
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
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v5 1/2] lib/fib: remove warning about implicit 64-bit conversion
2025-05-16 20:45 ` [PATCH v5 0/2] enable fib to be compiled with MSVC Andre Muezerie
@ 2025-05-16 20:45 ` Andre Muezerie
2025-05-17 10:07 ` Morten Brørup
2025-05-17 11:09 ` Stephen Hemminger
2025-05-16 20:45 ` [PATCH v5 2/2] lib/fib: enable fib to be compiled with MSVC Andre Muezerie
1 sibling, 2 replies; 16+ messages in thread
From: Andre Muezerie @ 2025-05-16 20:45 UTC (permalink / raw)
To: andremue; +Cc: dev, vladimir.medvedkin
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.
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 6c20057ac5..24a08b827d 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(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
^ permalink raw reply [flat|nested] 16+ messages in thread
* RE: [PATCH v5 1/2] lib/fib: remove warning about implicit 64-bit conversion
2025-05-16 20:45 ` [PATCH v5 1/2] lib/fib: remove warning about implicit 64-bit conversion Andre Muezerie
@ 2025-05-17 10:07 ` Morten Brørup
2025-05-17 11:09 ` Stephen Hemminger
1 sibling, 0 replies; 16+ messages in thread
From: Morten Brørup @ 2025-05-17 10:07 UTC (permalink / raw)
To: Andre Muezerie; +Cc: dev, vladimir.medvedkin
> From: Andre Muezerie [mailto:andremue@linux.microsoft.com]
> Sent: Friday, 16 May 2025 22.46
>
> 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.
>
> 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 6c20057ac5..24a08b827d 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(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
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v5 1/2] lib/fib: remove warning about implicit 64-bit conversion
2025-05-16 20:45 ` [PATCH v5 1/2] lib/fib: remove warning about implicit 64-bit conversion Andre Muezerie
2025-05-17 10:07 ` Morten Brørup
@ 2025-05-17 11:09 ` Stephen Hemminger
2025-05-17 12:59 ` Morten Brørup
1 sibling, 1 reply; 16+ messages in thread
From: Stephen Hemminger @ 2025-05-17 11:09 UTC (permalink / raw)
To: Andre Muezerie; +Cc: dev, Medvedkin, Vladimir
[-- Attachment #1: Type: text/plain, Size: 1266 bytes --]
Ok.
Wonder if RTE_PTR_ADD should have the cast there instead
On Sat, May 17, 2025, 05:45 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 (1) explicitly to uintptr_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 6c20057ac5..24a08b827d 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(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
>
>
[-- Attachment #2: Type: text/html, Size: 1914 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* RE: [PATCH v5 1/2] lib/fib: remove warning about implicit 64-bit conversion
2025-05-17 11:09 ` Stephen Hemminger
@ 2025-05-17 12:59 ` Morten Brørup
0 siblings, 0 replies; 16+ messages in thread
From: Morten Brørup @ 2025-05-17 12:59 UTC (permalink / raw)
To: Stephen Hemminger, Andre Muezerie; +Cc: dev, Medvedkin, Vladimir
From: Stephen Hemminger [mailto:stephen@networkplumber.org]
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 <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 (1) explicitly to uintptr_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 6c20057ac5..24a08b827d 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(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
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v5 2/2] lib/fib: enable fib to be compiled with MSVC
2025-05-16 20:45 ` [PATCH v5 0/2] enable fib to be compiled with MSVC Andre Muezerie
2025-05-16 20:45 ` [PATCH v5 1/2] lib/fib: remove warning about implicit 64-bit conversion Andre Muezerie
@ 2025-05-16 20:45 ` Andre Muezerie
1 sibling, 0 replies; 16+ messages in thread
From: Andre Muezerie @ 2025-05-16 20:45 UTC (permalink / raw)
To: andremue; +Cc: dev, vladimir.medvedkin
Now that all issues related to fib are addressed it can be enabled
for MSVC.
Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
lib/fib/meson.build | 6 ------
1 file changed, 6 deletions(-)
diff --git a/lib/fib/meson.build b/lib/fib/meson.build
index da82e017a9..6992ccc040 100644
--- a/lib/fib/meson.build
+++ b/lib/fib/meson.build
@@ -2,12 +2,6 @@
# Copyright(c) 2018 Vladimir Medvedkin <medvedkinv@gmail.com>
# 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']
--
2.49.0.vfs.0.3
^ permalink raw reply [flat|nested] 16+ messages in thread