]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Remove redundant NULL tests.
authorChih-Hung Hsieh <chh@google.com>
Wed, 9 Sep 2015 19:32:07 +0000 (12:32 -0700)
committerMark Wielaard <mjw@redhat.com>
Mon, 14 Sep 2015 11:41:12 +0000 (13:41 +0200)
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>
12 files changed:
libdw/ChangeLog
libdw/dwarf_macro_getsrcfiles.c
libdw/dwarf_siblingof.c
libdw/libdw_visit_scopes.c
libdwfl/ChangeLog
libdwfl/dwfl_frame.c
libdwfl/libdwfl.h
libebl/ChangeLog
libebl/ebldwarftoregno.c
libebl/eblinitreg.c
libebl/eblnormalizepc.c
libebl/eblunwind.c

index 96f8d90135c1f255aa9bc9b25726f723731f6176..13beefc79d058bba606bf71ed039dd876c1dbcc3 100644 (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>
 
index cc190437b4635c02bd33ee1c553d19d31d43d65c..3b1794b112f3061ee9271a5cefb7dfbb2afaadf7 100644 (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)
     {
index e598ae4197797b3d29b9db0244be3c56cf64a1be..0dafc179291a300a34ee367a12874dd85619e7e7 100644 (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;
index ac7e8532cdec647e678abfa53dd45f5af1db659f..d0b5134d697b36d91f19145d3795fa339fe7cf0d 100644 (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;
          }
index 0e3b7862ed57495289882bdf98b2ac95dfc70f0b..0ab386fbd93092022ae7a316a1b6391451f87732 100644 (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.
index f6f86c0de6f14b46ede53afdfa551fc705438c30..a91a1d6831d4d8f07b57de613a1f41a513d61d58 100644 (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;
index 1098c833e6f23d0ea0233317aeac320b1f6e3852..aea8b993124a040d9e4b837e75d8cd517c581e33 100644 (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.  */
index 60ae566d1c891e5ad5ed83b36a9f7a194a95b43b..aab085719a1247ff53cd86587a578d88e7e5948a 100644 (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
index 8fb85401000dae54efe89748220a079e99012832..c66449697506cbbb68b7b728dda925801ecdd4dd 100644 (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);
 }
index 5729b3ccdf37f2f40a450c719bb94562f32a574b..8a3fb18a932d829640de92730bb6aff1fc0aa5c2 100644 (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
index a5fea77e5928acc59bbff5f9fc97dafdbbfd2ad9..1629353daf79e2f652cdaeb2e4531f5e1e7c8e75 100644 (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);
 }
index 1251c1b5a2e398d22132e642418152b357d2344b..2970d03e5e1247fbf115d9d94e4466e650cd3035 100644 (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);
 }