diff options
author | Keith Seitz <keiths@redhat.com> | 2020-11-18 12:57:53 -0800 |
---|---|---|
committer | Keith Seitz <keiths@redhat.com> | 2020-11-18 13:59:05 -0800 |
commit | 5b7d45d32a59a27ea302e4d28ef8d595bcd6a5c7 (patch) | |
tree | 51150b9f5a9dbdcc50783119f0db2199d89c356a | |
parent | c44191f8e316f2f4d72d78aaca54a1811840dc70 (diff) | |
download | gdb-5b7d45d32a59a27ea302e4d28ef8d595bcd6a5c7.zip gdb-5b7d45d32a59a27ea302e4d28ef8d595bcd6a5c7.tar.gz gdb-5b7d45d32a59a27ea302e4d28ef8d595bcd6a5c7.tar.bz2 |
Squash coverity warning for REVERSE_INULL in dump_note_entry_p
Coverity detected a "defect" in dump_note_entry_p in linux-tdep.c:
static int
dump_note_entry_p (filter_flags filterflags, const struct smaps_vmflags *v,
int maybe_private_p, int mapping_anon_p, int mapping_file_p,
const char *filename, ULONGEST addr, ULONGEST offset)
{
/* vDSO and vsyscall mappings will end up in the core file. Don't
put them in the NT_FILE note. */
if (strcmp ("[vdso]", filename) == 0
|| strcmp ("[vsyscall]", filename) == 0)
return 0;
/* Otherwise, any other file-based mapping should be placed in the
note. */
return filename != nullptr;
}
Those strcmp's will derefernce `filename' so there is little point
to checking whether it is non-NULL or not; we would have already
segfaulted. It also cannot be nullptr because its value is read directly
from /proc/PID/maps. The "worst" it can be is an empty string.
gdb/ChangeLog
2020-11-18 Keith Seitz <keiths@redhat.com>
* linux-tdep.c (dump_note_entry_p): Return true instead of
checking `filename'.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/linux-tdep.c | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 18c8c0d..1c0029d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-11-18 Keith Seitz <keiths@redhat.com> + + * linux-tdep.c (dump_note_entry_p): Return true instead of + checking `filename'. + 2020-11-18 Tom de Vries <tdevries@suse.de> * debuginfod-support.c (debuginfod_source_query) diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index bacb613..8f7bbd5 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -742,7 +742,7 @@ dump_note_entry_p (filter_flags filterflags, const struct smaps_vmflags *v, /* Otherwise, any other file-based mapping should be placed in the note. */ - return filename != nullptr; + return 1; } /* Implement the "info proc" command. */ |