Skip to contentSkip to conversation

package/mmc-utils: fix build failure due to a warning and -Werror enabled

PATCH Superseded Giulio Benetti 2 participants 5 messages Sep 18, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/mmc-utils: fix build failure due to a warning and -Werror enabled

Add patch to fix warning that is treated like error:

```
In function '__bswap_32',
    inlined from 'do_rpmb_write_block' at mmc_cmds.c:2293:27:
/home/autobuild/autobuild/instance-15/output-1/host/aarch64-buildroot-linux-gnu/sysroot/usr/include/bits/byteswap.h:52:10: error: 'cnt' may be used uninitialized [-Werror=maybe-uninitialized]
   52 |   return __builtin_bswap32 (__bsx);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~
mmc_cmds.c: In function 'do_rpmb_write_block':
mmc_cmds.c:2270:22: note: 'cnt' was declared here
 2270 |         unsigned int cnt;
      |                      ^~~
cc1: all warnings being treated as errors
```

Patch is pending upstream:
https://patchwork.kernel.org/project/linux-mmc/patch/[email protected]/

Fixes:
http://autobuild.buildroot.net/results/18c4fce5416e5d1ccd95900ccef87d4c045a361e/

---
 ...ds.c-fix-warning-on-uninitialized-cn.patch | 27 +++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 package/mmc-utils/0002-mmc-utils-mmc_cmds.c-fix-warning-on-uninitialized-cn.patch
package/mmc-utils/0002-mmc-utils-mmc_cmds.c-fix-warning-on-uninitialized-cn.patch new file +27 -0
new file mode 100644
index 0000000000..e2f74879a6
@@ -0,0 +1,27 @@
+From bf783bbc2da0348591dd317ccd53bbfc5a57f2f8 Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <[email protected]>
+Date: Sun, 18 Sep 2022 14:10:29 +0200
+Subject: [PATCH] mmc-utils: mmc_cmds.c: fix warning on uninitialized 'cnt'
+
+Signed-off-by: Giulio Benetti <[email protected]>
+[Upstream status: https://patchwork.kernel.org/project/linux-mmc/patch/[email protected]/]
+---
+ mmc_cmds.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/mmc_cmds.c b/mmc_cmds.c
+index 12b7802..777d649 100644
+--- a/mmc_cmds.c
++++ b/mmc_cmds.c
+@@ -2436,7 +2436,7 @@ int do_rpmb_write_block(int nargs, char **argv)
+ 	int ret, dev_fd, key_fd, data_fd;
+ 	unsigned char key[32];
+ 	uint16_t addr;
+-	unsigned int cnt;
++	unsigned int cnt = 0;
+ 	struct rpmb_frame frame_in = {
+ 		.req_resp    = htobe16(MMC_RPMB_WRITE),
+ 		.block_count = htobe16(1)
+-- 
+2.34.1
+
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Giulio, All,

On 2022-09-18 14:53 +0200, Giulio Benetti spake thusly:

Quoted 13 lines

Add patch to fix warning that is treated like error:

```
In function '__bswap_32',
    inlined from 'do_rpmb_write_block' at mmc_cmds.c:2293:27:
/home/autobuild/autobuild/instance-15/output-1/host/aarch64-buildroot-linux-gnu/sysroot/usr/include/bits/byteswap.h:52:10: error: 'cnt' may be used uninitialized [-Werror=maybe-uninitialized]
   52 |   return __builtin_bswap32 (__bsx);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~
mmc_cmds.c: In function 'do_rpmb_write_block':
mmc_cmds.c:2270:22: note: 'cnt' was declared here
 2270 |         unsigned int cnt;
      |                      ^~~
cc1: all warnings being treated as errors
```
Quoted 2 lines

Patch is pending upstream:
https://patchwork.kernel.org/project/linux-mmc/patch/[email protected]/

Arnd requested a different fix, arguing the one you proposed is hiding a compiler warning without fixing the root cause.

Regards,
Yann E. MORIN.

Quoted 48 lines

http://autobuild.buildroot.net/results/18c4fce5416e5d1ccd95900ccef87d4c045a361e/

---
 ...ds.c-fix-warning-on-uninitialized-cn.patch | 27 +++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 package/mmc-utils/0002-mmc-utils-mmc_cmds.c-fix-warning-on-uninitialized-cn.patch
package/mmc-utils/0002-mmc-utils-mmc_cmds.c-fix-warning-on-uninitialized-cn.patch new file +27 -0
new file mode 100644
index 0000000000..e2f74879a6
@@ -0,0 +1,27 @@
+From bf783bbc2da0348591dd317ccd53bbfc5a57f2f8 Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <[email protected]>
+Date: Sun, 18 Sep 2022 14:10:29 +0200
+Subject: [PATCH] mmc-utils: mmc_cmds.c: fix warning on uninitialized 'cnt'
+
+Signed-off-by: Giulio Benetti <[email protected]>
+[Upstream status: https://patchwork.kernel.org/project/linux-mmc/patch/[email protected]/]
+---
+ mmc_cmds.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/mmc_cmds.c b/mmc_cmds.c
+index 12b7802..777d649 100644
+--- a/mmc_cmds.c
++++ b/mmc_cmds.c
+@@ -2436,7 +2436,7 @@ int do_rpmb_write_block(int nargs, char **argv)
+ 	int ret, dev_fd, key_fd, data_fd;
+ 	unsigned char key[32];
+ 	uint16_t addr;
+-	unsigned int cnt;
++	unsigned int cnt = 0;
+ 	struct rpmb_frame frame_in = {
+ 		.req_resp    = htobe16(MMC_RPMB_WRITE),
+ 		.block_count = htobe16(1)
+-- 
+2.34.1
+
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

Hi Arnd,

Quoted 19 lines · Yann E. MORIN

Giulio, All,

On 2022-09-18 14:53 +0200, Giulio Benetti spake thusly:

Quoted 13 lines

Add patch to fix warning that is treated like error:

```
In function '__bswap_32',
     inlined from 'do_rpmb_write_block' at mmc_cmds.c:2293:27:
/home/autobuild/autobuild/instance-15/output-1/host/aarch64-buildroot-linux-gnu/sysroot/usr/include/bits/byteswap.h:52:10: error: 'cnt' may be used uninitialized [-Werror=maybe-uninitialized]
    52 |   return __builtin_bswap32 (__bsx);
       |          ^~~~~~~~~~~~~~~~~~~~~~~~~
mmc_cmds.c: In function 'do_rpmb_write_block':
mmc_cmds.c:2270:22: note: 'cnt' was declared here
  2270 |         unsigned int cnt;
       |                      ^~~
cc1: all warnings being treated as errors
```
Quoted 2 lines

Patch is pending upstream:
https://patchwork.kernel.org/project/linux-mmc/patch/[email protected]/

Quoted 2 lines

Arnd requested a different fix, arguing the one you proposed is hiding a compiler warning without fixing the root cause.

Yes, he's totally right and I've just re-spinned V3 patch:
https://lore.kernel.org/linux-mmc/[email protected]/T/#mce3840c0bf84e1743552aa9428ef9097b613c610

Now I prepare send the V2 Buildroot patch.

Best regards

Signature · 2 lines
Giulio Benetti
Benetti Engineering sas
Quoted 47 lines

Regards,
Yann E. MORIN.

Quoted 44 lines

http://autobuild.buildroot.net/results/18c4fce5416e5d1ccd95900ccef87d4c045a361e/

---
  ...ds.c-fix-warning-on-uninitialized-cn.patch | 27 +++++++++++++++++++
  1 file changed, 27 insertions(+)

create mode 100644 package/mmc-utils/0002-mmc-utils-mmc_cmds.c-fix-warning-on-uninitialized-cn.patch

package/mmc-utils/0002-mmc-utils-mmc_cmds.c-fix-warning-on-uninitialized-cn.patch new file +27 -0
new file mode 100644
index 0000000000..e2f74879a6
@@ -0,0 +1,27 @@
+From bf783bbc2da0348591dd317ccd53bbfc5a57f2f8 Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <[email protected]>
+Date: Sun, 18 Sep 2022 14:10:29 +0200
+Subject: [PATCH] mmc-utils: mmc_cmds.c: fix warning on uninitialized 'cnt'
+
+Signed-off-by: Giulio Benetti <[email protected]>
+[Upstream status: https://patchwork.kernel.org/project/linux-mmc/patch/[email protected]/]
+---
+ mmc_cmds.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/mmc_cmds.c b/mmc_cmds.c
+index 12b7802..777d649 100644
+--- a/mmc_cmds.c
++++ b/mmc_cmds.c
+@@ -2436,7 +2436,7 @@ int do_rpmb_write_block(int nargs, char **argv)
+ 	int ret, dev_fd, key_fd, data_fd;
+ 	unsigned char key[32];
+ 	uint16_t addr;
+-	unsigned int cnt;
++	unsigned int cnt = 0;
+ 	struct rpmb_frame frame_in = {
+ 		.req_resp    = htobe16(MMC_RPMB_WRITE),
+ 		.block_count = htobe16(1)
+--
+2.34.1
+
Signature · 1 line
2.34.1
Quoted 5 lines
Quoted 4 lines

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw
Quoted 1 line · Giulio Benetti

Hi Arnd,

s/Arnd/Yann sorry!

Signature · 2 lines
Giulio Benetti
Benetti Engineering sas
Quoted 23 lines · Yann E. MORIN
Quoted 19 lines

Giulio, All,

On 2022-09-18 14:53 +0200, Giulio Benetti spake thusly:

Quoted 13 lines

Add patch to fix warning that is treated like error:

```
In function '__bswap_32',
     inlined from 'do_rpmb_write_block' at mmc_cmds.c:2293:27:
/home/autobuild/autobuild/instance-15/output-1/host/aarch64-buildroot-linux-gnu/sysroot/usr/include/bits/byteswap.h:52:10: error: 'cnt' may be used uninitialized [-Werror=maybe-uninitialized]
    52 |   return __builtin_bswap32 (__bsx);
       |          ^~~~~~~~~~~~~~~~~~~~~~~~~
mmc_cmds.c: In function 'do_rpmb_write_block':
mmc_cmds.c:2270:22: note: 'cnt' was declared here
  2270 |         unsigned int cnt;
       |                      ^~~
cc1: all warnings being treated as errors
```
Quoted 2 lines

Patch is pending upstream:
https://patchwork.kernel.org/project/linux-mmc/patch/[email protected]/

Quoted 2 lines

Arnd requested a different fix, arguing the one you proposed is hiding a compiler warning without fixing the root cause.

Quoted 6 lines

Yes, he's totally right and I've just re-spinned V3 patch:
https://lore.kernel.org/linux-mmc/[email protected]/T/#mce3840c0bf84e1743552aa9428ef9097b613c610

Now I prepare send the V2 Buildroot patch.

Best regards

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#4 lore raw

PATCH v2 1/1 package/mmc-utils: fix build failure due to a warning and -Werror enabled

In reply to Yann E. MORIN

Add patch to fix warning that is treated like error:

```
In function '__bswap_32',
    inlined from 'do_rpmb_write_block' at mmc_cmds.c:2293:27:
/home/autobuild/autobuild/instance-15/output-1/host/aarch64-buildroot-linux-gnu/sysroot/usr/include/bits/byteswap.h:52:10: error: 'cnt' may be used uninitialized [-Werror=maybe-uninitialized]
   52 |   return __builtin_bswap32 (__bsx);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~
mmc_cmds.c: In function 'do_rpmb_write_block':
mmc_cmds.c:2270:22: note: 'cnt' was declared here
 2270 |         unsigned int cnt;
      |                      ^~~
cc1: all warnings being treated as errors
```

Patch is pending upstream:
https://patchwork.kernel.org/project/linux-mmc/patch/[email protected]/

Fixes:
http://autobuild.buildroot.net/results/18c4fce5416e5d1ccd95900ccef87d4c045a361e/

---
V1->V2:
* change local patch approach after feedback in linux-mmc mailing list

---
 ...ils-fix-warning-on-uninitialized-cnt.patch | 47 +++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 package/mmc-utils/0002-mmc-utils-fix-warning-on-uninitialized-cnt.patch
package/mmc-utils/0002-mmc-utils-fix-warning-on-uninitialized-cnt.patch new file +47 -0
new file mode 100644
index 0000000000..04ba6ea399
@@ -0,0 +1,47 @@
+From 639a80658dfe4302617a3fd22cbae4714efd40b6 Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <[email protected]>
+Date: Sun, 18 Sep 2022 14:10:29 +0200
+Subject: [PATCH] mmc-utils: fix warning on uninitialized 'cnt'
+
+When building following warning shows up:
+```
+In function '__bswap_32',
+    inlined from 'do_rpmb_write_block' at mmc_cmds.c:2293:27:
+/home/autobuild/autobuild/instance-15/output-1/host/aarch64-buildroot-linux-gnu/sysroot/usr/include/bits/byteswap.h:52:10: error: 'cnt' may be used uninitialized [-Werror=maybe-uninitialized]
+   52 |   return __builtin_bswap32 (__bsx);
+      |          ^~~~~~~~~~~~~~~~~~~~~~~~~
+mmc_cmds.c: In function 'do_rpmb_write_block':
+mmc_cmds.c:2270:22: note: 'cnt' was declared here
+2270 |         unsigned int cnt;
+      |                      ^~~
+cc1: all warnings being treated as errors
+```
+This is due to function rpmb_read_counter() that doesn't set its
+argument 'unsigned int *cnt' in all return points. So let's set
+*cnt to 0 in the return point that misses to initialize it.
+
+Signed-off-by: Giulio Benetti <[email protected]>
+[Upstream status: https://patchwork.kernel.org/project/linux-mmc/patch/[email protected]/]
+---
+ mmc_cmds.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/mmc_cmds.c b/mmc_cmds.c
+index 12b7802..4d203ef 100644
+--- a/mmc_cmds.c
++++ b/mmc_cmds.c
+@@ -2238,8 +2238,10 @@ int rpmb_read_counter(int dev_fd, unsigned int *cnt)
+ 	}
+ 
+ 	/* Check RPMB response */
+-	if (frame_out.result != 0)
++	if (frame_out.result != 0) {
++		*cnt = 0;
+ 		return be16toh(frame_out.result);
++	}
+ 
+ 	*cnt = be32toh(frame_out.write_counter);
+ 
+-- 
+2.34.1
+
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot