diff options
author | Manish Goregaokar <manish@mozilla.com> | 2016-06-29 17:09:43 +0530 |
---|---|---|
committer | Manish Goregaokar <manish@mozilla.com> | 2016-06-29 20:07:14 +0530 |
commit | 9bf74fb27dc6e2a9679403d66fe919215e3c2a45 (patch) | |
tree | 95db5b24998feaec1d4364a785807351beee334e | |
parent | 28244707d9e4f35cab1f9069cee1d44b38be095f (diff) | |
download | gdb-9bf74fb27dc6e2a9679403d66fe919215e3c2a45.zip gdb-9bf74fb27dc6e2a9679403d66fe919215e3c2a45.tar.gz gdb-9bf74fb27dc6e2a9679403d66fe919215e3c2a45.tar.bz2 |
Initialize strtok_r's saveptr to NULL
Building gdb with --enable-build-with-cxx=no trips on a warning:
../../binutils-gdb/gdb/rust-lang.c:173:15: error: saveptr may be used
uninitialized in this function [-Werror=maybe-uninitialized]
ret.name = concat (TYPE_NAME (type), "::", token, (char *) NULL);
The problem is that gcc doesn't understand that "tail" can never be
NULL in the call to strtok_r:
name = xstrdup (TYPE_FIELD_NAME (type, 0));
cleanup = make_cleanup (xfree, name);
tail = name + strlen (RUST_ENUM_PREFIX);
...
for (token = strtok_r (tail, "$", &saveptr);
Fix this by always initializing saveptr.
2016-06-29 Manish Goregaokar <manish@mozilla.com>
gdb/ChangeLog:
* rust-lang.c (rust_get_disr_info): Initialize saveptr to NULL.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/rust-lang.c | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e30e099..97b609b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,6 +1,11 @@ 2016-06-29 Manish Goregaokar <manish@mozilla.com> gdb/ChangeLog: + * rust-lang.c (rust_get_disr_info): Initialize saveptr to NULL. + +2016-06-29 Manish Goregaokar <manish@mozilla.com> + +gdb/ChangeLog: * rust-lang.c (rust_get_disr_info): Use strtok_r instead of strsep. 2016-06-28 Yao Qi <yao.qi@linaro.org> diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index c01687a..1849349 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -121,7 +121,7 @@ rust_get_disr_info (struct type *type, const gdb_byte *valaddr, if (strncmp (TYPE_FIELD_NAME (type, 0), RUST_ENUM_PREFIX, strlen (RUST_ENUM_PREFIX)) == 0) { - char *tail, *token, *name, *saveptr; + char *tail, *token, *name, *saveptr = NULL; unsigned long fieldno; struct type *member_type; LONGEST value; |