Fix build with GCC 8: strncpy ->strcpy
authorYao Qi <yao.qi@linaro.org>
Wed, 22 Nov 2017 12:22:11 +0000 (12:22 +0000)
committerYao Qi <yao.qi@linaro.org>
Wed, 22 Nov 2017 12:22:11 +0000 (12:22 +0000)
Recent gcc 8 trunk emits the warning below,

../../binutils-gdb/gdb/python/py-gdb-readline.c:79:15: error: ‘char* strncpy(char*, const char*, size_t)’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
       strncpy (q, p, n);
       ~~~~~~~~^~~~~~~~~
../../binutils-gdb/gdb/python/py-gdb-readline.c:73:14: note: length computed here
   n = strlen (p);
       ~~~~~~~^~~

gdb:

2017-11-22  Yao Qi  <yao.qi@linaro.org>

* python/py-gdb-readline.c (gdbpy_readline_wrapper): Use strcpy.

gdb/ChangeLog
gdb/python/py-gdb-readline.c

index a9e7528a87a9027c6c92d91f7089c3db898ff0d2..63ae72e59fd9e0bb29d65dd5885fe7c228a29c32 100644 (file)
@@ -1,3 +1,7 @@
+2017-11-22  Yao Qi  <yao.qi@linaro.org>
+
+       * python/py-gdb-readline.c (gdbpy_readline_wrapper): Use strcpy.
+
 2017-11-22  Yao Qi  <yao.qi@linaro.org>
 
        * cli/cli-decode.c (help_list): Use memcpy instead of strncpy.
index a02fa8ce6f11a616b9f194f99497761b8cca25d1..ab14b8c8e8baf2485c6cdefc96d5f27227cd00c4 100644 (file)
@@ -76,7 +76,7 @@ gdbpy_readline_wrapper (FILE *sys_stdin, FILE *sys_stdout,
   q = (char *) PyMem_RawMalloc (n + 2);
   if (q != NULL)
     {
-      strncpy (q, p, n);
+      strcpy (q, p);
       q[n] = '\n';
       q[n + 1] = '\0';
     }
This page took 0.035451 seconds and 4 git commands to generate.