Remove redundant NULL tests.

GCC6 and Clang give warnings on redundant NULL tests of parameters
that are declared with __nonnull_attribute__.

Signed-off-by: Chih-Hung Hsieh <chh@google.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
This commit is contained in:
Chih-Hung Hsieh
2015-09-09 12:32:07 -07:00
committed by Mark Wielaard
parent 879850950b
commit 2d982861e5
12 changed files with 41 additions and 20 deletions
+7
View File
@@ -1,3 +1,10 @@
2015-09-09 Chih-Hung Hsieh <chh@google.com>
* dwarf_macro_getsrcfiles.c (dwarf_macro_getsrcfiles): Remove
redundant NULL tests on parameters declared with __nonnull_attribute__.
* dwarf_siblingof.c (dwarf_siblingof): Likewise.
* libdw_visit_scopes.c (__libdw_visit_scopes): Likewise.
2015-09-04 Chih-Hung Hsieh <chh@google.com>
Mark Wielaard <mjw@redhat.com>
+1 -3
View File
@@ -36,9 +36,7 @@ int
dwarf_macro_getsrcfiles (Dwarf *dbg, Dwarf_Macro *macro,
Dwarf_Files **files, size_t *nfiles)
{
if (macro == NULL)
return -1;
/* macro is declared NN */
Dwarf_Macro_Op_Table *const table = macro->table;
if (table->files == NULL)
{
+1 -2
View File
@@ -45,8 +45,7 @@ dwarf_siblingof (die, result)
if (die == NULL)
return -1;
if (result == NULL)
return -1;
/* result is declared NN */
if (result != die)
result->addr = NULL;
+6 -8
View File
@@ -138,24 +138,22 @@ __libdw_visit_scopes (depth, root, imports, previsit, postvisit, arg)
child.prune = false;
if (previsit != NULL)
{
int result = (*previsit) (depth + 1, &child, arg);
if (result != DWARF_CB_OK)
return result;
}
/* previsit is declared NN */
int result = (*previsit) (depth + 1, &child, arg);
if (result != DWARF_CB_OK)
return result;
if (!child.prune && may_have_scopes (&child.die)
&& INTUSE(dwarf_haschildren) (&child.die))
{
int result = recurse ();
result = recurse ();
if (result != DWARF_CB_OK)
return result;
}
if (postvisit != NULL)
{
int result = (*postvisit) (depth + 1, &child, arg);
result = (*postvisit) (depth + 1, &child, arg);
if (result != DWARF_CB_OK)
return result;
}
+8
View File
@@ -1,3 +1,11 @@
2015-09-09 Chih-Hung Hsieh <chh@google.com>
Mark Wielaard <mjw@redhat.com>
* dwfl_frame.c (dwfl_attach_state): Remove redundant NULL tests
on parameters declared with __nonnull_attribute__.
* libdwfl.h (dwfl_module_getelf): Don't mark first argument as
nonnull.
2015-09-08 Mark Wielaard <mjw@redhat.com>
* libdwflP.h (struct __libdwfl_pid_arg): Add elf and elf_fd.
+2 -1
View File
@@ -143,7 +143,8 @@ dwfl_attach_state (Dwfl *dwfl, Elf *elf, pid_t pid,
/* Reset any previous error, we are just going to try again. */
dwfl->attacherr = DWFL_E_NOERROR;
if (thread_callbacks == NULL || thread_callbacks->next_thread == NULL
/* thread_callbacks is declared NN */
if (thread_callbacks->next_thread == NULL
|| thread_callbacks->set_initial_registers == NULL)
{
dwfl->attacherr = DWFL_E_INVALID_ARGUMENT;
+1 -1
View File
@@ -423,7 +423,7 @@ extern int dwfl_validate_address (Dwfl *dwfl,
with the difference between addresses within the loaded module
and those in symbol tables or Dwarf information referring to it. */
extern Elf *dwfl_module_getelf (Dwfl_Module *, GElf_Addr *bias)
__nonnull_attribute__ (1, 2);
__nonnull_attribute__ (2);
/* Return the number of symbols in the module's symbol table,
or -1 for errors. */
+8
View File
@@ -1,3 +1,11 @@
2015-09-09 Chih-Hung Hsieh <chh@google.com>
* ebldwarftoregno.c (ebl_dwarf_to_regno): Remove redundant NULL tests
on parameters declared with __nonnull_attribute__.
* eblinitreg.c (ebl_frame_nregs): Likewise.
* eblnormalizepc.c (ebl_normalize_pc): Likewise.
* eblunwind.c (ebl_unwind): Likewise.
2015-09-04 Chih-Hung Hsieh <chh@google.com>
* eblopenbackend.c (ebl_openbackend_machine): Replace K&R function
+1 -2
View File
@@ -35,7 +35,6 @@
bool
ebl_dwarf_to_regno (Ebl *ebl, unsigned *regno)
{
if (ebl == NULL)
return false;
/* ebl is declared NN */
return ebl->dwarf_to_regno == NULL ? true : ebl->dwarf_to_regno (ebl, regno);
}
+2 -1
View File
@@ -47,7 +47,8 @@ ebl_set_initial_registers_tid (Ebl *ebl, pid_t tid,
size_t
ebl_frame_nregs (Ebl *ebl)
{
return ebl == NULL ? 0 : ebl->frame_nregs;
/* ebl is declared NN */
return ebl->frame_nregs;
}
GElf_Addr
+2 -1
View File
@@ -35,6 +35,7 @@
void
ebl_normalize_pc (Ebl *ebl, Dwarf_Addr *pc)
{
if (ebl != NULL && ebl->normalize_pc != NULL)
/* ebl is declared NN */
if (ebl->normalize_pc != NULL)
ebl->normalize_pc (ebl, pc);
}
+2 -1
View File
@@ -37,7 +37,8 @@ ebl_unwind (Ebl *ebl, Dwarf_Addr pc, ebl_tid_registers_t *setfunc,
ebl_tid_registers_get_t *getfunc, ebl_pid_memory_read_t *readfunc,
void *arg, bool *signal_framep)
{
if (ebl == NULL || ebl->unwind == NULL)
/* ebl is declared NN */
if (ebl->unwind == NULL)
return false;
return ebl->unwind (ebl, pc, setfunc, getfunc, readfunc, arg, signal_framep);
}