[PATCH 2/4] Fix gcc-11 compilation warning on symbols.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Without the patch, the following gcc-11 compliation warning is emitted
for symbols.c:

symbols.c: In function 'cmd_p':
symbols.c:7412:38: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
 7412 |                         *(cpuspec-1) = ':';
      |                         ~~~~~~~~~~~~~^~~~~

Signed-off-by: Kazuhito Hagio <k-hagio-ab@xxxxxxx>
---
 symbols.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/symbols.c b/symbols.c
index bee1faf..42c4eb4 100644
--- a/symbols.c
+++ b/symbols.c
@@ -7351,7 +7351,7 @@ cmd_p(void)
 	unsigned radix;
 	int do_load_module_filter;
 	char buf1[BUFSIZE]; 
-	char *cpuspec;
+	char *cpuspec, *p;
 
 	do_load_module_filter = radix = 0;
 
@@ -7386,7 +7386,7 @@ cmd_p(void)
         if (argerrs || !args[optind])
                 cmd_usage(pc->curcmd, SYNOPSIS);
 
-	cpuspec = strrchr(args[optind], ':');
+	p = cpuspec = strrchr(args[optind], ':');
 	if (cpuspec)
 		*cpuspec++ = NULLCHAR;
 
@@ -7409,7 +7409,7 @@ cmd_p(void)
 			      sp->name);
 		else
 			/* maybe a valid C expression (e.g. ':') */
-			*(cpuspec-1) = ':';
+			*p = ':';
 	}
 
 	process_gdb_output(concat_args(buf1, 0, TRUE), radix,
-- 
2.31.1

--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/crash-utility
Contribution Guidelines: https://github.com/crash-utility/crash/wiki




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux