libsubcmd: Silence compiler warning
PATCH 1/1 libsubcmd: Silence compiler warning
From: Eder Zulian <[email protected]>
[ Upstream commit 7a4ffec9fd54ea27395e24dff726dbf58e2fe06b ]
Initialize the pointer 'o' in options__order to NULL to prevent a compiler warning/error which is observed when compiling with the '-Og' option, but is not emitted by the compiler with the current default compilation options.
For example, when compiling libsubcmd with
$ make "EXTRA_CFLAGS=-Og" -C tools/lib/subcmd/ clean all
Clang version 17.0.6 and GCC 13.3.1 fail to compile parse-options.c due to following error:
parse-options.c: In function ‘options__order’:
parse-options.c:832:9: error: ‘o’ may be used uninitialized [-Werror=maybe-uninitialized]
832 | memcpy(&ordered[nr_opts], o, sizeof(*o));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
parse-options.c:810:30: note: ‘o’ was declared here
810 | const struct option *o, *p = opts;
| ^cc1: all warnings being treated as errors
--- tools/lib/subcmd/parse-options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/subcmd/parse-options.c +1 -1
@@ -807,7 +807,7 @@ static int option__cmp(const void *va, const void *vb)static struct option *options__order (const struct option *opts) {int nr_opts =0 , nr_group =0 , nr_parent =0 , len; -const struct option *o, *p = opts; +const struct option *o =NULL , *p = opts;struct option *opt, *ordered =NULL , *group;/* flatten the options that have parents */
Signature · 1 line
2.34.1
[ Sasha's backport helper bot ]
Hi,
✅ All tests passed successfully. No issues detected. No action required from the submitter.
The upstream commit SHA1 provided is correct: 7a4ffec9fd54ea27395e24dff726dbf58e2fe06b
WARNING: Author mismatch between patch and upstream commit:
Backport author: [email protected]
Commit author: Eder Zulian<[email protected]>
Status in newer kernel trees:
6.13.y | Present (exact SHA1)
Note: The patch differs from the upstream commit:
---
1: 7a4ffec9fd54e ! 1: eada5c1cb53ec libsubcmd: Silence compiler warning
@@ Metadata
## Commit message ##
libsubcmd: Silence compiler warning
+ [ Upstream commit 7a4ffec9fd54ea27395e24dff726dbf58e2fe06b ]
+
Initialize the pointer 'o' in options__order to NULL to prevent a compiler warning/error which is observed when compiling with the '-Og' option, but is not emitted by the compiler with the current default
@@ Commit message
+ Signed-off-by: Bin Lan <[email protected]>
+ Signed-off-by: He Zhe <[email protected]>
## tools/lib/subcmd/parse-options.c ##
@@ tools/lib/subcmd/parse-options.c: static int option__cmp(const void *va, const void *vb)
---
Results of testing on various branches:
| Branch | Patch Apply | Build Test | |---------------------------|-------------|------------| | stable/linux-6.12.y | Success | Success |