Skip to contentSkip to conversation

net/cxgbe: fix build with clang 3.4.2

PATCH In review Ferruh Yigit 4 participants 6 messages Mar 18, 2020 – Mar 19, 2020 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/cxgbe: fix build with clang 3.4.2

Build error:
.../drivers/net/cxgbe/cxgbe_flow.c:315:2:
error: implicit truncation from 'int' to bitfield changes value from -1 to 7 [-Werror,-Wbitfield-constant-conversion]
CXGBE_FILL_FS(adap->pf, ~0, pf); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../drivers/net/cxgbe/cxgbe_flow.c:25:2:

    note: expanded from macro 'CXGBE_FILL_FS'
        __CXGBE_FILL_FS(v, m, fs, elem, e)
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../drivers/net/cxgbe/cxgbe_flow.c:15:18: note:
    expanded from macro '__CXGBE_FILL_FS'
        (fs)->mask.elem = (__m); \
                        ^ ~~~~~

Commit in fixes line changes 'PF_BITWIDTH' to '3', which makes 'fs->pf' bitfield size '3', changing '~0' to '0x7' to prevent truncation in assignment.

Fixes dcd456abe46f ("net/cxgbe: support flow API for matching all packets on PF")

---
Cc: [email protected]

---
 drivers/net/cxgbe/cxgbe_flow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/cxgbe/cxgbe_flow.c +1 -1
index 13fd78aaf..a46515d3b 100644
@@ -312,7 +312,7 @@ ch_rte_parsetype_pf(const void *dmask __rte_unused,
 
 	CXGBE_FILL_FS(1, 1, pfvf_vld);
 
-	CXGBE_FILL_FS(adap->pf, ~0, pf);
+	CXGBE_FILL_FS(adap->pf, 0x7, pf);
 	return 0;
 }
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 18 lines · Ferruh Yigit

Build error:
.../drivers/net/cxgbe/cxgbe_flow.c:315:2:
error: implicit truncation from 'int' to bitfield changes value from -1 to 7 [-Werror,-Wbitfield-constant-conversion]
CXGBE_FILL_FS(adap->pf, ~0, pf); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../drivers/net/cxgbe/cxgbe_flow.c:25:2:

    note: expanded from macro 'CXGBE_FILL_FS'
        __CXGBE_FILL_FS(v, m, fs, elem, e)
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../drivers/net/cxgbe/cxgbe_flow.c:15:18: note:
    expanded from macro '__CXGBE_FILL_FS'
        (fs)->mask.elem = (__m); \
                        ^ ~~~~~

Commit in fixes line changes 'PF_BITWIDTH' to '3', which makes 'fs->pf' bitfield size '3', changing '~0' to '0x7' to prevent truncation in assignment.

Quoted 5 lines
Fixes dcd456abe46f ("net/cxgbe: support flow API for matching all packets on PF")

Hi Raslan, Xueming,

Can you please confirm the above patch on top of next-net fixes the build issue?

Thanks,
ferruh

#2 lore raw

Many thanks Ferruh.

In dpdk-next-net and dpdk-next-net-intel, the patch verified.

Quoted 45 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Wednesday, March 18, 2020 9:10 PM
To: Raslan Darawsheh <[email protected]>; Zhang, XuemingX <[email protected]>
Cc: Rahul Lakkireddy <[email protected]>; Karra Satwik <[email protected]>; [email protected]
Subject: Re: [PATCH] net/cxgbe: fix build with clang 3.4.2

Quoted 3 lines · Ferruh Yigit

Build error:
.../drivers/net/cxgbe/cxgbe_flow.c:315:2:
error: implicit truncation from 'int' to bitfield changes

value

Quoted 11 lines
    from -1 to 7 [-Werror,-Wbitfield-constant-conversion]
        CXGBE_FILL_FS(adap->pf, ~0, pf);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../drivers/net/cxgbe/cxgbe_flow.c:25:2:
    note: expanded from macro 'CXGBE_FILL_FS'
        __CXGBE_FILL_FS(v, m, fs, elem, e)
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../drivers/net/cxgbe/cxgbe_flow.c:15:18: note:
    expanded from macro '__CXGBE_FILL_FS'
        (fs)->mask.elem = (__m); \
                        ^ ~~~~~
Quoted 1 line

Commit in fixes line changes 'PF_BITWIDTH' to '3', which makes

'fs->pf'

Quoted 9 lines

bitfield size '3', changing '~0' to '0x7' to prevent truncation in assignment.

Fixes dcd456abe46f ("net/cxgbe: support flow API for matching all

packets on PF")

Hi Raslan, Xueming,

Can you please confirm the above patch on top of next-net fixes the build issue?

Thanks,
ferruh

Acked-by on v1 1/1
#3 lore raw
In reply to Ferruh Yigit
Quoted 18 lines · Ferruh Yigit

Build error:
.../drivers/net/cxgbe/cxgbe_flow.c:315:2:
error: implicit truncation from 'int' to bitfield changes value from -1 to 7 [-Werror,-Wbitfield-constant-conversion]
CXGBE_FILL_FS(adap->pf, ~0, pf); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../drivers/net/cxgbe/cxgbe_flow.c:25:2:

    note: expanded from macro 'CXGBE_FILL_FS'
        __CXGBE_FILL_FS(v, m, fs, elem, e)
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../drivers/net/cxgbe/cxgbe_flow.c:15:18: note:
    expanded from macro '__CXGBE_FILL_FS'
        (fs)->mask.elem = (__m); \
                        ^ ~~~~~

Commit in fixes line changes 'PF_BITWIDTH' to '3', which makes 'fs->pf' bitfield size '3', changing '~0' to '0x7' to prevent truncation in assignment.

Quoted 5 lines
Fixes dcd456abe46f ("net/cxgbe: support flow API for matching all packets on PF")

I've tested CLANG compilation with 9.0.1 without this patch, but couldn't hit the above mentioned error.

# clang --version
clang version 9.0.1 (Fedora 9.0.1-2.fc31)

However, after grabbing CLANG 3.4.2, I could see the error.

# clang --version
clang version 3.4.2 (tags/RELEASE_34/dot2-final)

This patch fixes it and the fix is correct too.

Thanks for fixing it.

Quoted 22 lines

---
Cc: [email protected]

---
 drivers/net/cxgbe/cxgbe_flow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/cxgbe/cxgbe_flow.c +1 -1
index 13fd78aaf..a46515d3b 100644
@@ -312,7 +312,7 @@ ch_rte_parsetype_pf(const void *dmask __rte_unused,
 
 	CXGBE_FILL_FS(1, 1, pfvf_vld);
 
-	CXGBE_FILL_FS(adap->pf, ~0, pf);
+	CXGBE_FILL_FS(adap->pf, 0x7, pf);
 	return 0;
 }
 
Signature · 1 line
2.25.1
#4 lore raw

Hi,

Quoted 41 lines

-----Original Message-----
From: Rahul Lakkireddy <[email protected]>
Sent: Wednesday, March 18, 2020 3:48 PM
To: Ferruh Yigit <[email protected]>
Cc: Karra Satwik <[email protected]>; [email protected]; Raslan Darawsheh <[email protected]>; Xueming Zhang <[email protected]>
Subject: Re: [PATCH] net/cxgbe: fix build with clang 3.4.2

Quoted 14 lines · Ferruh Yigit

Build error:
.../drivers/net/cxgbe/cxgbe_flow.c:315:2:
error: implicit truncation from 'int' to bitfield changes value from -1 to 7 [-Werror,-Wbitfield-constant-conversion]
CXGBE_FILL_FS(adap->pf, ~0, pf); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../drivers/net/cxgbe/cxgbe_flow.c:25:2:

    note: expanded from macro 'CXGBE_FILL_FS'
        __CXGBE_FILL_FS(v, m, fs, elem, e)
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../drivers/net/cxgbe/cxgbe_flow.c:15:18: note:
    expanded from macro '__CXGBE_FILL_FS'
        (fs)->mask.elem = (__m); \
                        ^ ~~~~~
Quoted 5 lines

Commit in fixes line changes 'PF_BITWIDTH' to '3', which makes 'fs->pf' bitfield size '3', changing '~0' to '0x7' to prevent truncation in assignment.

Fixes dcd456abe46f ("net/cxgbe: support flow API for matching all packets

on PF")

Quoted 4 lines

I've tested CLANG compilation with 9.0.1 without this patch, but couldn't hit the above mentioned error.

# clang --version
clang version 9.0.1 (Fedora 9.0.1-2.fc31)
Quoted 9 lines

However, after grabbing CLANG 3.4.2, I could see the error.

# clang --version
clang version 3.4.2 (tags/RELEASE_34/dot2-final)

This patch fixes it and the fix is correct too.

Thanks for fixing it.

Working just fine for me as well, thanks for the update

Quoted 26 lines

Review

Quoted 7 lines

---
Cc: [email protected]

---
 drivers/net/cxgbe/cxgbe_flow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/net/cxgbe/cxgbe_flow.c

drivers/net/cxgbe/cxgbe_flow.c ch_rte_parsetype_pf(const void *dmask

Quoted 4 lines

index 13fd78aaf..a46515d3b 100644

drivers/net/cxgbe/cxgbe_flow.c +0 -0
@@ -312,7 +312,7 @@ ch_rte_parsetype_pf(const void *dmask

__rte_unused,

Quoted 11 lines
drivers/net/cxgbe/cxgbe_flow.c +1 -2
 	CXGBE_FILL_FS(1, 1, pfvf_vld);
 
-	CXGBE_FILL_FS(adap->pf, ~0, pf);
+	CXGBE_FILL_FS(adap->pf, 0x7, pf);
 	return 0;
 }
 
--

2.25.1

#5 lore raw
In reply to Rahul Lakkireddy
Quoted 33 lines · Rahul Lakkireddy
Quoted 18 lines · Ferruh Yigit

Build error:
.../drivers/net/cxgbe/cxgbe_flow.c:315:2:
error: implicit truncation from 'int' to bitfield changes value from -1 to 7 [-Werror,-Wbitfield-constant-conversion]
CXGBE_FILL_FS(adap->pf, ~0, pf); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../drivers/net/cxgbe/cxgbe_flow.c:25:2:

    note: expanded from macro 'CXGBE_FILL_FS'
        __CXGBE_FILL_FS(v, m, fs, elem, e)
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../drivers/net/cxgbe/cxgbe_flow.c:15:18: note:
    expanded from macro '__CXGBE_FILL_FS'
        (fs)->mask.elem = (__m); \
                        ^ ~~~~~

Commit in fixes line changes 'PF_BITWIDTH' to '3', which makes 'fs->pf' bitfield size '3', changing '~0' to '0x7' to prevent truncation in assignment.

Quoted 5 lines
Fixes dcd456abe46f ("net/cxgbe: support flow API for matching all packets on PF")

I've tested CLANG compilation with 9.0.1 without this patch, but couldn't hit the above mentioned error.

# clang --version
clang version 9.0.1 (Fedora 9.0.1-2.fc31)

However, after grabbing CLANG 3.4.2, I could see the error.

Quoted 8 lines
# clang --version
clang version 3.4.2 (tags/RELEASE_34/dot2-final)

This patch fixes it and the fix is correct too.

Thanks for fixing it.

Squashed into relevant commit in next-net, thanks.