public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* Re: [PATCH] Fix type warnings from clang compiler.
@ 2015-09-09 11:32 Mark Wielaard
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Wielaard @ 2015-09-09 11:32 UTC (permalink / raw)
  To: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 778 bytes --]

On Tue, 2015-09-08 at 15:14 -0700, Chih-hung Hsieh wrote:
> The 4 split patches looked good to me.

Thanks. I pushed them to master.

> Yes, the labs should be llabs to work on 32-bit systems.

OK, I also pushed the attached to fix that.

> About removing the NULL tests of parameters declared with NN,
> I don't mind removing them. I was extra careful not to remove
> any check in case some code could call those functions with
> NULL parameter and without the NN declaration.
> 
> Please let me know if you need me to prepare another patch
> to remove those unnecessary NULL tests

Yes, that would be nice. Lets fix this properly by making sure the
nonnull annotations are correct and to not do any unnecessary NULL
checks in that case.

Thanks,

Mark

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-libdwfl-Replace-abs-with-llabs-for-int64_t-values.patch --]
[-- Type: text/x-patch, Size: 1308 bytes --]

From 4169187fe3abfda5b7df3eb39ab6bc15d08e13a1 Mon Sep 17 00:00:00 2001
From: Chih-Hung Hsieh <chh@google.com>
Date: Fri, 4 Sep 2015 12:04:11 -0700
Subject: [PATCH] libdwfl: Replace abs with llabs for int64_t values.

Signed-off-by: Chih-Hung Hsieh <chh@google.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
 libdwfl/ChangeLog      | 4 ++++
 libdwfl/frame_unwind.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 3e36aa7..2c76369 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,7 @@
+2015-09-04  Chih-Hung Hsieh  <chh@google.com
+
+	* frame_unwind.c (expr_eval): Use llabs instead of abs.
+
 2015-08-14  Dodji Seketeli  <dodji@seketeli.org>
 
 	* find-debuginfo.c (find_debuginfo_in_path): Try to locate the
diff --git a/libdwfl/frame_unwind.c b/libdwfl/frame_unwind.c
index 16cebd0..bd100b8 100644
--- a/libdwfl/frame_unwind.c
+++ b/libdwfl/frame_unwind.c
@@ -342,7 +342,7 @@ expr_eval (Dwfl_Frame *state, Dwarf_Frame *frame, const Dwarf_Op *ops,
 	      return false;						\
 	    }								\
 	  break;
-	UNOP (DW_OP_abs, abs ((int64_t) val1))
+	UNOP (DW_OP_abs, llabs ((int64_t) val1))
 	UNOP (DW_OP_neg, -(int64_t) val1)
 	UNOP (DW_OP_not, ~val1)
 #undef UNOP
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix type warnings from clang compiler.
@ 2015-09-10 12:13 Mark Wielaard
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Wielaard @ 2015-09-10 12:13 UTC (permalink / raw)
  To: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 477 bytes --]

On Wed, 2015-09-09 at 14:12 -0700, Chih-hung Hsieh wrote:
> From 336dca81578cfec85a5be45642ff408b85c15400 Mon Sep 17 00:00:00 2001
> From: Chih-Hung Hsieh <chh@google.com>
> Date: Wed, 9 Sep 2015 13:59:19 -0700
> Subject: [PATCH] Initialize variable before use.
> 
> Some compiler does not know that error function never returns.
> 
> Signed-off-by: Chih-Hung Hsieh <chh@google.com>

Applied since those initializations aren't on a critical path.

Thanks,

Mark

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix type warnings from clang compiler.
@ 2015-09-09 21:12 Chih-Hung Hsieh
  0 siblings, 0 replies; 6+ messages in thread
From: Chih-Hung Hsieh @ 2015-09-09 21:12 UTC (permalink / raw)
  To: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 1019 bytes --]

Mark,

Thank you very much for pushing those fixes.
I have attached the remaining changes in the attached 2 files.



On Wed, Sep 9, 2015 at 4:32 AM, Mark Wielaard <mjw@redhat.com> wrote:

> On Tue, 2015-09-08 at 15:14 -0700, Chih-hung Hsieh wrote:
> > The 4 split patches looked good to me.
>
> Thanks. I pushed them to master.
>
> > Yes, the labs should be llabs to work on 32-bit systems.
>
> OK, I also pushed the attached to fix that.
>
> > About removing the NULL tests of parameters declared with NN,
> > I don't mind removing them. I was extra careful not to remove
> > any check in case some code could call those functions with
> > NULL parameter and without the NN declaration.
> >
> > Please let me know if you need me to prepare another patch
> > to remove those unnecessary NULL tests
>
> Yes, that would be nice. Lets fix this properly by making sure the
> nonnull annotations are correct and to not do any unnecessary NULL
> checks in that case.
>
> Thanks,
>
> Mark
>

[-- Attachment #2: attachment.html --]
[-- Type: text/html, Size: 1485 bytes --]

[-- Attachment #3: 0001-Remove-redundant-NULL-tests.patch --]
[-- Type: application/octet-stream, Size: 6425 bytes --]

From 862bacf11cacc734f854f81b64edde23465228c7 Mon Sep 17 00:00:00 2001
From: Chih-Hung Hsieh <chh@google.com>
Date: Wed, 9 Sep 2015 12:32:07 -0700
Subject: [PATCH] Remove redundant NULL tests.

Clang gives warning on redundant NULL tests of parameters
that are declared with __nonnull_attribute__.

Signed-off-by: Chih-Hung Hsieh <chh@google.com>
---
 libdw/ChangeLog                 | 7 +++++++
 libdw/dwarf_macro_getsrcfiles.c | 4 +---
 libdw/dwarf_siblingof.c         | 3 +--
 libdw/libdw_visit_scopes.c      | 2 +-
 libdwfl/ChangeLog               | 6 ++++++
 libdwfl/dwfl_frame.c            | 3 ++-
 libdwfl/dwfl_module_getelf.c    | 4 +---
 libebl/ChangeLog                | 8 ++++++++
 libebl/ebldwarftoregno.c        | 3 +--
 libebl/eblinitreg.c             | 3 ++-
 libebl/eblnormalizepc.c         | 3 ++-
 libebl/eblunwind.c              | 3 ++-
 12 files changed, 34 insertions(+), 15 deletions(-)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 96f8d90..13beefc 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -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>
 
diff --git a/libdw/dwarf_macro_getsrcfiles.c b/libdw/dwarf_macro_getsrcfiles.c
index cc19043..3b1794b 100644
--- a/libdw/dwarf_macro_getsrcfiles.c
+++ b/libdw/dwarf_macro_getsrcfiles.c
@@ -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)
     {
diff --git a/libdw/dwarf_siblingof.c b/libdw/dwarf_siblingof.c
index e598ae4..0dafc17 100644
--- a/libdw/dwarf_siblingof.c
+++ b/libdw/dwarf_siblingof.c
@@ -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;
diff --git a/libdw/libdw_visit_scopes.c b/libdw/libdw_visit_scopes.c
index ac7e853..4a9b08e 100644
--- a/libdw/libdw_visit_scopes.c
+++ b/libdw/libdw_visit_scopes.c
@@ -138,7 +138,7 @@ __libdw_visit_scopes (depth, root, imports, previsit, postvisit, arg)
 
 	child.prune = false;
 
-	if (previsit != NULL)
+	/* previsit is declared NN */
 	  {
 	    int result = (*previsit) (depth + 1, &child, arg);
 	    if (result != DWARF_CB_OK)
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 2c76369..852da47 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,9 @@
+2015-09-09  Chih-Hung Hsieh  <chh@google.com>
+
+	* dwfl_frame.c (dwfl_attach_state): Remove redundant NULL tests
+	on parameters declared with __nonnull_attribute__.
+	* dwfl_module_getelf.c (dwfl_module_getelf): Likewise.
+
 2015-09-04  Chih-Hung Hsieh  <chh@google.com
 
 	* frame_unwind.c (expr_eval): Use llabs instead of abs.
diff --git a/libdwfl/dwfl_frame.c b/libdwfl/dwfl_frame.c
index f6f86c0..a91a1d6 100644
--- a/libdwfl/dwfl_frame.c
+++ b/libdwfl/dwfl_frame.c
@@ -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;
diff --git a/libdwfl/dwfl_module_getelf.c b/libdwfl/dwfl_module_getelf.c
index f20fb04..080647e 100644
--- a/libdwfl/dwfl_module_getelf.c
+++ b/libdwfl/dwfl_module_getelf.c
@@ -31,9 +31,7 @@
 Elf *
 dwfl_module_getelf (Dwfl_Module *mod, GElf_Addr *loadbase)
 {
-  if (mod == NULL)
-    return NULL;
-
+  /* mod is declared NN */
   __libdwfl_getelf (mod);
   if (mod->elferr == DWFL_E_NOERROR)
     {
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index 60ae566..aab0857 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -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
diff --git a/libebl/ebldwarftoregno.c b/libebl/ebldwarftoregno.c
index 8fb8540..c664496 100644
--- a/libebl/ebldwarftoregno.c
+++ b/libebl/ebldwarftoregno.c
@@ -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);
 }
diff --git a/libebl/eblinitreg.c b/libebl/eblinitreg.c
index 5729b3c..8a3fb18 100644
--- a/libebl/eblinitreg.c
+++ b/libebl/eblinitreg.c
@@ -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
diff --git a/libebl/eblnormalizepc.c b/libebl/eblnormalizepc.c
index a5fea77..1629353 100644
--- a/libebl/eblnormalizepc.c
+++ b/libebl/eblnormalizepc.c
@@ -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);
 }
diff --git a/libebl/eblunwind.c b/libebl/eblunwind.c
index 1251c1b..2970d03 100644
--- a/libebl/eblunwind.c
+++ b/libebl/eblunwind.c
@@ -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);
 }
-- 
2.6.0.rc0.131.gf624c3d


[-- Attachment #4: 0001-Initialize-variable-before-use.patch --]
[-- Type: application/octet-stream, Size: 1508 bytes --]

From 336dca81578cfec85a5be45642ff408b85c15400 Mon Sep 17 00:00:00 2001
From: Chih-Hung Hsieh <chh@google.com>
Date: Wed, 9 Sep 2015 13:59:19 -0700
Subject: [PATCH] Initialize variable before use.

Some compiler does not know that error function never returns.

Signed-off-by: Chih-Hung Hsieh <chh@google.com>
---
 src/ChangeLog | 6 ++++++
 src/readelf.c | 3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index fb92807..238c416 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2015-09-09  Chih-Hung Hsieh  <chh@google.com>
+
+	* readelf.c (print_debug_exception_table): Initialize variable before
+	it is used, because compiler does not know that error never returns.
+	(dump_arhive_index): Likewise.
+
 2015-09-04  Chih-Hung Hsieh  <chh@google.com>
 
 	* elflint.c (check_group): Replace %Z length modifier with %z.
diff --git a/src/readelf.c b/src/readelf.c
index 8e64400..33274f3 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -7910,6 +7910,7 @@ print_debug_exception_table (Dwfl_Module *dwflmod __attribute__ ((unused)),
 	  dsize = 8;
 	  break;
 	default:
+	  dsize = 0;
 	  error (1, 0, gettext ("invalid TType encoding"));
 	}
 
@@ -9567,7 +9568,7 @@ dump_archive_index (Elf *elf, const char *fname)
 	{
 	  as_off = s->as_off;
 
-	  Elf *subelf;
+	  Elf *subelf = NULL;
 	  if (unlikely (elf_rand (elf, as_off) == 0)
 	      || unlikely ((subelf = elf_begin (-1, ELF_C_READ_MMAP, elf))
 			   == NULL))
-- 
2.6.0.rc0.131.gf624c3d


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix type warnings from clang compiler.
@ 2015-09-08 22:14 Chih-Hung Hsieh
  0 siblings, 0 replies; 6+ messages in thread
From: Chih-Hung Hsieh @ 2015-09-08 22:14 UTC (permalink / raw)
  To: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 3795 bytes --]

The 4 split patches looked good to me.

About the init value of enctype in tests/varlocs.c, yes,
clang does not seem to know that error(EXIT_FAILURE, ...) won't return.

Yes, the labs should be llabs to work on 32-bit systems.

About removing the NULL tests of parameters declared with NN,
I don't mind removing them. I was extra careful not to remove
any check in case some code could call those functions with
NULL parameter and without the NN declaration.

Please let me know if you need me to prepare another patch
to remove those unnecessary NULL tests or replace abs() with llabs().
Thanks.


On Mon, Sep 7, 2015 at 3:32 PM, Mark Wielaard <mjw@redhat.com> wrote:

> Hi,
>
> I split this out in individual patches. Some are clearly good to get
> cleaned up and get in immediately. But some might need some discussion
> first. The four I think are fine and would like to commit are attached.
>
> On Fri, 2015-09-04 at 12:04 -0700, Chih-Hung Hsieh wrote:
> > * Replace K&R function definition with prototypes to match their
> > declarations.
> >   Clang gives errors of: promoted type 'int' of K&R function parameter
> > is not compatible with the parameter type
>
> This is OK. I would like to get rid of the K&R function definitions in
> general. They can hide some issues (see also below). We should probably
> use gcc -Wold-style-definition to find them all.
>
> I am not really sure why just these few get flagged. Most cases seem to
> be flagged because there are no explicit prototypes. In the backends
> case the _init functions are properly called through the ebl_bhinit_t in
> openbackend. There are no explicit prototypes for these functions
> though.
>
> In the libasm FCT and UFCT case the various addintXX.c files include the
> asm_addint8.c file to generate the various variants, the files don't
> include any definitions.
>
> In the case of asm_begin, dwarf_next_cfi, __libdw_intern_next_unit,
> __libdw_findcu I that the warning is because they all have a 'bool'
> argument that might be promoted differently in pre-ansi code?
>
> I don't understand why there is a complaint about
> ebl_openbackend_machine () and ebl_check_st_other_bits (). Those do look
> fine to me with a declaration from libebl.h which is included. The issue
> might again be that the last arguments might be promoted differently.
>
> If we want to get rid of the K&R function definitions then lets start
> with these. I reformatted them a little so they confirm with the GNU
> coding standards we use.
>
> > * Add const declaration to locs, which was passed a const.
> >  Clang gives errors of: passing 'const Elf_Data *' to parameter of
> > type 'Elf_Data *' discards qualifiers
>
> Good. This was also caused by a K&R function definition. I changed it
> also to a new style definition and gcc warns about this too.
>
> > * Avoid clang errors of: comparison of nonnull parameter ... equal to a
> null pointer is false
> >   on first encounter [-Werror,-Wtautological-pointer-compare]
> >   The parameter was declared as non-null.
>
> If they are marked as nonnull arguments then I think we should just
> remove the NULL checks. Casting away to get rid of the warning seems the
> wrong approach.
>
> > * Replace abs with labs for int64 values.
>
> Nice catch. But labs is for longs, which might on some arches be only 32
> bits. Should we be using llabs?
>
> > * Remove unused static variables.
>
> This is fine. They are clearly unused.
> BTW this is gcc bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28901
>
> > * Init local variable before use, where static analysis failed.
>
> OK, because it is just test code. But in general it seems bad to
> unnecessary initialize variables.
>
> Thanks,
>
> Mark
>

[-- Attachment #2: attachment.html --]
[-- Type: text/html, Size: 4675 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix type warnings from clang compiler.
@ 2015-09-07 22:32 Mark Wielaard
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Wielaard @ 2015-09-07 22:32 UTC (permalink / raw)
  To: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 2976 bytes --]

Hi,

I split this out in individual patches. Some are clearly good to get
cleaned up and get in immediately. But some might need some discussion
first. The four I think are fine and would like to commit are attached.

On Fri, 2015-09-04 at 12:04 -0700, Chih-Hung Hsieh wrote:
> * Replace K&R function definition with prototypes to match their
> declarations.
>   Clang gives errors of: promoted type 'int' of K&R function parameter
> is not compatible with the parameter type

This is OK. I would like to get rid of the K&R function definitions in
general. They can hide some issues (see also below). We should probably
use gcc -Wold-style-definition to find them all.

I am not really sure why just these few get flagged. Most cases seem to
be flagged because there are no explicit prototypes. In the backends
case the _init functions are properly called through the ebl_bhinit_t in
openbackend. There are no explicit prototypes for these functions
though.

In the libasm FCT and UFCT case the various addintXX.c files include the
asm_addint8.c file to generate the various variants, the files don't
include any definitions.

In the case of asm_begin, dwarf_next_cfi, __libdw_intern_next_unit,
__libdw_findcu I that the warning is because they all have a 'bool'
argument that might be promoted differently in pre-ansi code?

I don't understand why there is a complaint about
ebl_openbackend_machine () and ebl_check_st_other_bits (). Those do look
fine to me with a declaration from libebl.h which is included. The issue
might again be that the last arguments might be promoted differently.

If we want to get rid of the K&R function definitions then lets start
with these. I reformatted them a little so they confirm with the GNU
coding standards we use.

> * Add const declaration to locs, which was passed a const.
>  Clang gives errors of: passing 'const Elf_Data *' to parameter of
> type 'Elf_Data *' discards qualifiers

Good. This was also caused by a K&R function definition. I changed it
also to a new style definition and gcc warns about this too.

> * Avoid clang errors of: comparison of nonnull parameter ... equal to a null pointer is false
>   on first encounter [-Werror,-Wtautological-pointer-compare]
>   The parameter was declared as non-null.

If they are marked as nonnull arguments then I think we should just
remove the NULL checks. Casting away to get rid of the warning seems the
wrong approach.

> * Replace abs with labs for int64 values.

Nice catch. But labs is for longs, which might on some arches be only 32
bits. Should we be using llabs?

> * Remove unused static variables.

This is fine. They are clearly unused.
BTW this is gcc bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28901

> * Init local variable before use, where static analysis failed.

OK, because it is just test code. But in general it seems bad to
unnecessary initialize variables.

Thanks,

Mark

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Replace-some-K-R-function-definitions-with-ansi-C-de.patch --]
[-- Type: text/x-patch, Size: 14524 bytes --]

From aa1c2ca808a267a5a3c372de5461c1f67f9a8869 Mon Sep 17 00:00:00 2001
From: Chih-Hung Hsieh <chh@google.com>
Date: Fri, 4 Sep 2015 12:04:11 -0700
Subject: [PATCH 1/4] Replace some K&R function definitions with ansi-C
 definitions.

Signed-off-by: Chih-Hung Hsieh <chh@google.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
 backends/ChangeLog      | 16 ++++++++++++++++
 backends/aarch64_init.c |  9 ++++-----
 backends/alpha_init.c   |  9 ++++-----
 backends/arm_init.c     |  9 ++++-----
 backends/i386_init.c    |  9 ++++-----
 backends/ia64_init.c    |  9 ++++-----
 backends/ppc64_init.c   |  9 ++++-----
 backends/ppc_init.c     |  9 ++++-----
 backends/s390_init.c    |  9 ++++-----
 backends/sh_init.c      |  9 ++++-----
 backends/sparc_init.c   |  9 ++++-----
 backends/tilegx_init.c  |  9 ++++-----
 backends/x86_64_init.c  |  9 ++++-----
 libasm/ChangeLog        |  7 +++++++
 libasm/asm_addint8.c    |  4 +---
 libasm/asm_adduint8.c   |  4 +---
 libasm/asm_begin.c      |  5 +----
 libdw/ChangeLog         |  6 ++++++
 libdw/dwarf_next_cfi.c  | 13 ++++++-------
 libdw/libdw_findcu.c    |  9 ++-------
 libebl/ChangeLog        |  6 ++++++
 libebl/eblopenbackend.c |  3 +--
 libebl/eblstother.c     |  4 +---
 23 files changed, 96 insertions(+), 89 deletions(-)

diff --git a/backends/ChangeLog b/backends/ChangeLog
index 4accedc..2059d86 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,19 @@
+2015-09-04  Chih-Hung Hsieh  <chh@google.com>
+
+	* aarch64_init.c (aarch64_init): Replace K&R function definition
+	with ansi-C definitions.
+	* alpha_init.c (alpha_init): Likewise.
+	* arm_init.c (arm_init): Likewise.
+	* i386_init.c (i386_init): Likewise.
+	* ia64_init.c (ia64_init): Likewise.
+	* ppc64_init.c (ppc64_init): Likewise.
+	* ppc_init.c (ppc_init): Likewise.
+	* s390_init.c (s390_init): Likewise.
+	* sh_init.c (sh_init): Likewise.
+	* sparc_init.c (sparc_init): Likewise.
+	* tilegx_init.c (tilegx_init): Likewise.
+	* x86_64_init.c (x86_64_init): Likewise.
+
 2015-09-03  Mark Wielaard  <mjw@redhat.com>
 
 	* sparc_regs.c (sparc_register_info): Use ebl->class not ebl->machine.
diff --git a/backends/aarch64_init.c b/backends/aarch64_init.c
index b0fd17a..6395f11 100644
--- a/backends/aarch64_init.c
+++ b/backends/aarch64_init.c
@@ -39,11 +39,10 @@
 
 
 const char *
-aarch64_init (elf, machine, eh, ehlen)
-     Elf *elf __attribute__ ((unused));
-     GElf_Half machine __attribute__ ((unused));
-     Ebl *eh;
-     size_t ehlen;
+aarch64_init (Elf *elf __attribute__ ((unused)),
+	      GElf_Half machine __attribute__ ((unused)),
+	      Ebl *eh,
+	      size_t ehlen)
 {
   /* Check whether the Elf_BH object has a sufficent size.  */
   if (ehlen < sizeof (Ebl))
diff --git a/backends/alpha_init.c b/backends/alpha_init.c
index a3307d8..25c5b32 100644
--- a/backends/alpha_init.c
+++ b/backends/alpha_init.c
@@ -40,11 +40,10 @@
 
 
 const char *
-alpha_init (elf, machine, eh, ehlen)
-     Elf *elf __attribute__ ((unused));
-     GElf_Half machine __attribute__ ((unused));
-     Ebl *eh;
-     size_t ehlen;
+alpha_init (Elf *elf __attribute__ ((unused)),
+	    GElf_Half machine __attribute__ ((unused)),
+	    Ebl *eh,
+	    size_t ehlen)
 {
   /* Check whether the Elf_BH object has a sufficent size.  */
   if (ehlen < sizeof (Ebl))
diff --git a/backends/arm_init.c b/backends/arm_init.c
index f3e5f0a..caadac6 100644
--- a/backends/arm_init.c
+++ b/backends/arm_init.c
@@ -40,11 +40,10 @@
 
 
 const char *
-arm_init (elf, machine, eh, ehlen)
-     Elf *elf __attribute__ ((unused));
-     GElf_Half machine __attribute__ ((unused));
-     Ebl *eh;
-     size_t ehlen;
+arm_init (Elf *elf __attribute__ ((unused)),
+	  GElf_Half machine __attribute__ ((unused)),
+	  Ebl *eh,
+	  size_t ehlen)
 {
   /* Check whether the Elf_BH object has a sufficent size.  */
   if (ehlen < sizeof (Ebl))
diff --git a/backends/i386_init.c b/backends/i386_init.c
index 1e0b486..515d5ac 100644
--- a/backends/i386_init.c
+++ b/backends/i386_init.c
@@ -39,11 +39,10 @@
 #include "common-reloc.c"
 
 const char *
-i386_init (elf, machine, eh, ehlen)
-     Elf *elf __attribute__ ((unused));
-     GElf_Half machine __attribute__ ((unused));
-     Ebl *eh;
-     size_t ehlen;
+i386_init (Elf *elf __attribute__ ((unused)),
+	   GElf_Half machine __attribute__ ((unused)),
+	   Ebl *eh,
+	   size_t ehlen)
 {
   /* Check whether the Elf_BH object has a sufficent size.  */
   if (ehlen < sizeof (Ebl))
diff --git a/backends/ia64_init.c b/backends/ia64_init.c
index 91da748..7241d7b 100644
--- a/backends/ia64_init.c
+++ b/backends/ia64_init.c
@@ -39,11 +39,10 @@
 #include "common-reloc.c"
 
 const char *
-ia64_init (elf, machine, eh, ehlen)
-     Elf *elf __attribute__ ((unused));
-     GElf_Half machine __attribute__ ((unused));
-     Ebl *eh;
-     size_t ehlen;
+ia64_init (Elf *elf __attribute__ ((unused)),
+	   GElf_Half machine __attribute__ ((unused)),
+	   Ebl *eh,
+	   size_t ehlen)
 {
   /* Check whether the Elf_BH object has a sufficent size.  */
   if (ehlen < sizeof (Ebl))
diff --git a/backends/ppc64_init.c b/backends/ppc64_init.c
index 56e1828..2ba8232 100644
--- a/backends/ppc64_init.c
+++ b/backends/ppc64_init.c
@@ -42,11 +42,10 @@
 
 
 const char *
-ppc64_init (elf, machine, eh, ehlen)
-     Elf *elf __attribute__ ((unused));
-     GElf_Half machine __attribute__ ((unused));
-     Ebl *eh;
-     size_t ehlen;
+ppc64_init (Elf *elf __attribute__ ((unused)),
+	    GElf_Half machine __attribute__ ((unused)),
+	    Ebl *eh,
+	    size_t ehlen)
 {
   /* Check whether the Elf_BH object has a sufficent size.  */
   if (ehlen < sizeof (Ebl))
diff --git a/backends/ppc_init.c b/backends/ppc_init.c
index ad92765..c3e3ca3 100644
--- a/backends/ppc_init.c
+++ b/backends/ppc_init.c
@@ -40,11 +40,10 @@
 
 
 const char *
-ppc_init (elf, machine, eh, ehlen)
-     Elf *elf __attribute__ ((unused));
-     GElf_Half machine __attribute__ ((unused));
-     Ebl *eh;
-     size_t ehlen;
+ppc_init (Elf *elf __attribute__ ((unused)),
+	  GElf_Half machine __attribute__ ((unused)),
+	  Ebl *eh,
+	  size_t ehlen)
 {
   /* Check whether the Elf_BH object has a sufficent size.  */
   if (ehlen < sizeof (Ebl))
diff --git a/backends/s390_init.c b/backends/s390_init.c
index 26b20b4..ba8df45 100644
--- a/backends/s390_init.c
+++ b/backends/s390_init.c
@@ -41,11 +41,10 @@ extern __typeof (s390_core_note) s390x_core_note;
 
 
 const char *
-s390_init (elf, machine, eh, ehlen)
-     Elf *elf __attribute__ ((unused));
-     GElf_Half machine __attribute__ ((unused));
-     Ebl *eh;
-     size_t ehlen;
+s390_init (Elf *elf __attribute__ ((unused)),
+	   GElf_Half machine __attribute__ ((unused)),
+	   Ebl *eh,
+	   size_t ehlen)
 {
   /* Check whether the Elf_BH object has a sufficent size.  */
   if (ehlen < sizeof (Ebl))
diff --git a/backends/sh_init.c b/backends/sh_init.c
index 90ddcb2..5526aca 100644
--- a/backends/sh_init.c
+++ b/backends/sh_init.c
@@ -40,11 +40,10 @@
 
 
 const char *
-sh_init (elf, machine, eh, ehlen)
-     Elf *elf __attribute__ ((unused));
-     GElf_Half machine __attribute__ ((unused));
-     Ebl *eh;
-     size_t ehlen;
+sh_init (Elf *elf __attribute__ ((unused)),
+	 GElf_Half machine __attribute__ ((unused)),
+	 Ebl *eh,
+	 size_t ehlen)
 {
   /* Check whether the Elf_BH object has a sufficent size.  */
   if (ehlen < sizeof (Ebl))
diff --git a/backends/sparc_init.c b/backends/sparc_init.c
index 7d22998..18d7349 100644
--- a/backends/sparc_init.c
+++ b/backends/sparc_init.c
@@ -40,11 +40,10 @@
 extern __typeof (EBLHOOK (core_note)) sparc64_core_note attribute_hidden;
 
 const char *
-sparc_init (elf, machine, eh, ehlen)
-     Elf *elf __attribute__ ((unused));
-     GElf_Half machine __attribute__ ((unused));
-     Ebl *eh;
-     size_t ehlen;
+sparc_init (Elf *elf __attribute__ ((unused)),
+	    GElf_Half machine __attribute__ ((unused)),
+	    Ebl *eh,
+	    size_t ehlen)
 {
   /* Check whether the Elf_BH object has a sufficent size.  */
   if (ehlen < sizeof (Ebl))
diff --git a/backends/tilegx_init.c b/backends/tilegx_init.c
index 858798b..162ed36 100644
--- a/backends/tilegx_init.c
+++ b/backends/tilegx_init.c
@@ -38,11 +38,10 @@
 #include "common-reloc.c"
 
 const char *
-tilegx_init (elf, machine, eh, ehlen)
-     Elf *elf __attribute__ ((unused));
-     GElf_Half machine __attribute__ ((unused));
-     Ebl *eh;
-     size_t ehlen;
+tilegx_init (Elf *elf __attribute__ ((unused)),
+	     GElf_Half machine __attribute__ ((unused)),
+	     Ebl *eh,
+	     size_t ehlen)
 {
   /* Check whether the Elf_BH object has a sufficent size.  */
   if (ehlen < sizeof (Ebl))
diff --git a/backends/x86_64_init.c b/backends/x86_64_init.c
index 273eabb..cfd0158 100644
--- a/backends/x86_64_init.c
+++ b/backends/x86_64_init.c
@@ -42,11 +42,10 @@
 extern __typeof (EBLHOOK (core_note)) x32_core_note attribute_hidden;
 
 const char *
-x86_64_init (elf, machine, eh, ehlen)
-     Elf *elf __attribute__ ((unused));
-     GElf_Half machine __attribute__ ((unused));
-     Ebl *eh;
-     size_t ehlen;
+x86_64_init (Elf *elf __attribute__ ((unused)),
+	     GElf_Half machine __attribute__ ((unused)),
+	     Ebl *eh,
+	     size_t ehlen)
 {
   /* Check whether the Elf_BH object has a sufficent size.  */
   if (ehlen < sizeof (Ebl))
diff --git a/libasm/ChangeLog b/libasm/ChangeLog
index 9b25af9..91338d0 100644
--- a/libasm/ChangeLog
+++ b/libasm/ChangeLog
@@ -1,3 +1,10 @@
+2015-09-04  Chih-Hung Hsieh  <chh@google.com>
+
+	* asm_addint8.c (FCT): Replace K&R function definition
+	with ansi-C definitions.
+	* asm_adduint8.c (UFCT): Likewise.
+	* asm_begin.c (asm_begin): Likewise.
+
 2014-12-18  Ulrich Drepper  <drepper@gmail.com>
 
 	* Makefile.am: Suppress output of textrel_check command.
diff --git a/libasm/asm_addint8.c b/libasm/asm_addint8.c
index ec05b8d..bb7d40f 100644
--- a/libasm/asm_addint8.c
+++ b/libasm/asm_addint8.c
@@ -51,9 +51,7 @@
 
 
 int
-FCT(SIZE) (asmscn, num)
-     AsmScn_t *asmscn;
-     TYPE(SIZE) num;
+FCT(SIZE) (AsmScn_t *asmscn, TYPE(SIZE) num)
 {
   if (asmscn == NULL)
     return -1;
diff --git a/libasm/asm_adduint8.c b/libasm/asm_adduint8.c
index 30641b8..18b67dd 100644
--- a/libasm/asm_adduint8.c
+++ b/libasm/asm_adduint8.c
@@ -48,9 +48,7 @@
 
 
 int
-UFCT(SIZE) (asmscn, num)
-     AsmScn_t *asmscn;
-     UTYPE(SIZE) num;
+UFCT(SIZE) (AsmScn_t *asmscn, UTYPE(SIZE) num)
 {
   return INTUSE(FCT(SIZE)) (asmscn, (TYPE(SIZE)) num);
 }
diff --git a/libasm/asm_begin.c b/libasm/asm_begin.c
index 48842d3..ff4d94c 100644
--- a/libasm/asm_begin.c
+++ b/libasm/asm_begin.c
@@ -127,10 +127,7 @@ prepare_binary_output (AsmCtx_t *result, Ebl *ebl)
 
 
 AsmCtx_t *
-asm_begin (fname, ebl, textp)
-     const char *fname;
-     Ebl *ebl;
-     bool textp;
+asm_begin (const char *fname, Ebl *ebl, bool textp)
 {
   if (fname == NULL && ! textp)
     return NULL;
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 315ad70..63910ba 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,9 @@
+2015-09-04  Chih-Hung Hsieh  <chh@google.com>
+
+	* libdw_findcu.c (__libdw_intern_next_unit): Replace K&R function
+	definition with ansi-C definitions.
+	(__libdw_findcu): Likewise.
+
 2015-08-25  Mark Wielaard  <mjw@redhat.com>
 
 	* dwarf.h: Add DW_LANG_Haskell.
diff --git a/libdw/dwarf_next_cfi.c b/libdw/dwarf_next_cfi.c
index b5af49e..53fc369 100644
--- a/libdw/dwarf_next_cfi.c
+++ b/libdw/dwarf_next_cfi.c
@@ -37,13 +37,12 @@
 
 
 int
-dwarf_next_cfi (e_ident, data, eh_frame_p, off, next_off, entry)
-     const unsigned char e_ident[];
-     Elf_Data *data;
-     bool eh_frame_p;
-     Dwarf_Off off;
-     Dwarf_Off *next_off;
-     Dwarf_CFI_Entry *entry;
+dwarf_next_cfi (const unsigned char e_ident[],
+		Elf_Data *data,
+		bool eh_frame_p,
+		Dwarf_Off off,
+		Dwarf_Off *next_off,
+		Dwarf_CFI_Entry *entry)
 {
   /* Dummy struct for memory-access.h macros.  */
   BYTE_ORDER_DUMMY (dw, e_ident);
diff --git a/libdw/libdw_findcu.c b/libdw/libdw_findcu.c
index d8da2e3..5c03843 100644
--- a/libdw/libdw_findcu.c
+++ b/libdw/libdw_findcu.c
@@ -63,9 +63,7 @@ findcu_cb (const void *arg1, const void *arg2)
 
 struct Dwarf_CU *
 internal_function
-__libdw_intern_next_unit (dbg, debug_types)
-     Dwarf *dbg;
-     bool debug_types;
+__libdw_intern_next_unit (Dwarf *dbg, bool debug_types)
 {
   Dwarf_Off *const offsetp
     = debug_types ? &dbg->next_tu_offset : &dbg->next_cu_offset;
@@ -135,10 +133,7 @@ __libdw_intern_next_unit (dbg, debug_types)
 }
 
 struct Dwarf_CU *
-__libdw_findcu (dbg, start, debug_types)
-     Dwarf *dbg;
-     Dwarf_Off start;
-     bool debug_types;
+__libdw_findcu (Dwarf *dbg, Dwarf_Off start, bool debug_types)
 {
   void **tree = debug_types ? &dbg->tu_tree : &dbg->cu_tree;
   Dwarf_Off *next_offset
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index 4305cf6..60ae566 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,9 @@
+2015-09-04  Chih-Hung Hsieh  <chh@google.com>
+
+	* eblopenbackend.c (ebl_openbackend_machine): Replace K&R function
+	definition with ansi-C definitions.
+	* eblstother.c (ebl_check_st_other_bits): Likewise.
+
 2015-06-12  Mark Wielaard  <mjw@redhat.com>
 
 	* eblcheckreloctargettype.c (ebl_check_reloc_target_type): Allow
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index 2766e7b..02b24d3 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -418,8 +418,7 @@ ebl_openbackend (elf)
 
 /* Find backend without underlying ELF file.  */
 Ebl *
-ebl_openbackend_machine (machine)
-     GElf_Half machine;
+ebl_openbackend_machine (GElf_Half machine)
 {
   return openbackend (NULL, NULL, machine);
 }
diff --git a/libebl/eblstother.c b/libebl/eblstother.c
index ccbf138..273f6fc 100644
--- a/libebl/eblstother.c
+++ b/libebl/eblstother.c
@@ -34,9 +34,7 @@
 
 
 bool
-ebl_check_st_other_bits (ebl, st_other)
-     Ebl *ebl;
-     unsigned char st_other;
+ebl_check_st_other_bits (Ebl *ebl, unsigned char st_other)
 {
   return ((st_other ^ GELF_ST_VISIBILITY (st_other)) == 0
 	  || ebl->check_st_other_bits (st_other ^ GELF_ST_VISIBILITY (st_other)));
-- 
1.8.3.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-libdw-Add-const-declaration-to-getlocations_addr-loc.patch --]
[-- Type: text/x-patch, Size: 2065 bytes --]

From f6b93914662566bbbb974cc85ef686a9f6b41a42 Mon Sep 17 00:00:00 2001
From: Chih-Hung Hsieh <chh@google.com>
Date: Fri, 4 Sep 2015 12:04:11 -0700
Subject: [PATCH 2/4] libdw: Add const declaration to getlocations_addr locs.

And change K&R C function definition to ansi, which prevented GCC from
seeing that callers passed in const arguments.

Signed-off-by: Chih-Hung Hsieh <chh@google.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
 libdw/ChangeLog           |  7 +++++++
 libdw/dwarf_getlocation.c | 15 ++++-----------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 63910ba..96f8d90 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,4 +1,11 @@
 2015-09-04  Chih-Hung Hsieh  <chh@google.com>
+	    Mark Wielaard  <mjw@redhat.com>
+
+	* dwarf_getlocation.c (getlocations_addr): Replace K&R function
+	definition with ansi-C definition and add const qualifier to
+	locs argument.
+
+2015-09-04  Chih-Hung Hsieh  <chh@google.com>
 
 	* libdw_findcu.c (__libdw_intern_next_unit): Replace K&R function
 	definition with ansi-C definitions.
diff --git a/libdw/dwarf_getlocation.c b/libdw/dwarf_getlocation.c
index f1dda68..0a0e04b 100644
--- a/libdw/dwarf_getlocation.c
+++ b/libdw/dwarf_getlocation.c
@@ -680,17 +680,10 @@ initial_offset_base (attr, offset, basep)
 }
 
 static ptrdiff_t
-getlocations_addr (attr, offset, basep, startp, endp, address,
-		   locs, expr, exprlen)
-     Dwarf_Attribute *attr;
-     ptrdiff_t offset;
-     Dwarf_Addr *basep;
-     Dwarf_Addr *startp;
-     Dwarf_Addr *endp;
-     Dwarf_Addr address;
-     Elf_Data *locs;
-     Dwarf_Op **expr;
-     size_t *exprlen;
+getlocations_addr (Dwarf_Attribute *attr, ptrdiff_t offset,
+		   Dwarf_Addr *basep, Dwarf_Addr *startp, Dwarf_Addr *endp,
+		   Dwarf_Addr address, const Elf_Data *locs, Dwarf_Op **expr,
+		   size_t *exprlen)
 {
   unsigned char *readp = locs->d_buf + offset;
   unsigned char *readendp = locs->d_buf + locs->d_size;
-- 
1.8.3.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-tests-Remove-unused-static-const-variables-in-md5-sh.patch --]
[-- Type: text/x-patch, Size: 1392 bytes --]

From 4cb8f6196201a88d20f4a47fafaf0ae4e3cfa7a0 Mon Sep 17 00:00:00 2001
From: Chih-Hung Hsieh <chh@google.com>
Date: Fri, 4 Sep 2015 12:04:11 -0700
Subject: [PATCH 3/4] tests: Remove unused static const variables in
 md5-sha1-test.c.

Signed-off-by: Chih-Hung Hsieh <chh@google.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
 tests/ChangeLog       | 5 +++++
 tests/md5-sha1-test.c | 8 --------
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index 99b4d8f..44a8f04 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,5 +1,10 @@
 2015-09-04  Chih-Hung Hsieh  <chh@google.com>
 
+	* md5-sha1-test.c (md5_expected): Removed.
+	(sha1_expected): Likewise.
+
+2015-09-04  Chih-Hung Hsieh  <chh@google.com>
+
 	* asm-tst1.c (main): Replace %Z length modifier with %z.
 	* asm-tst2.c (main): Likewise.
 	* asm-tst3.c (main): Likewise.
diff --git a/tests/md5-sha1-test.c b/tests/md5-sha1-test.c
index 49de078..d50355e 100644
--- a/tests/md5-sha1-test.c
+++ b/tests/md5-sha1-test.c
@@ -61,14 +61,6 @@ static const struct expected
 #define md5_size	16
 #define sha1_size	20
 
-static const char md5_expected[] =
-  {
-  };
-
-static const char sha1_expected[] =
-  {
-  };
-
 #define TEST_HASH(ALGO, I)						      \
   {									      \
     struct ALGO##_ctx ctx;						      \
-- 
1.8.3.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #5: 0004-tests-Init-local-variable-enctype-before-use-in-prin.patch --]
[-- Type: text/x-patch, Size: 1386 bytes --]

From b85f80ab687044ece15d51de8a5e7f63bc1d3fa9 Mon Sep 17 00:00:00 2001
From: Chih-Hung Hsieh <chh@google.com>
Date: Fri, 4 Sep 2015 12:04:11 -0700
Subject: [PATCH 4/4] tests: Init local variable enctype before use in
 print_base_type varlocs.c.

clang compiler static analysis failed.

Signed-off-by: Chih-Hung Hsieh <chh@google.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
 tests/ChangeLog | 4 ++++
 tests/varlocs.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index 44a8f04..15c3ef9 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,5 +1,9 @@
 2015-09-04  Chih-Hung Hsieh  <chh@google.com>
 
+	* varlocs.c (print_base_type): Initialize enctype.
+
+2015-09-04  Chih-Hung Hsieh  <chh@google.com>
+
 	* md5-sha1-test.c (md5_expected): Removed.
 	(sha1_expected): Likewise.
 
diff --git a/tests/varlocs.c b/tests/varlocs.c
index b5733e7..c3fba89 100644
--- a/tests/varlocs.c
+++ b/tests/varlocs.c
@@ -82,7 +82,7 @@ print_base_type (Dwarf_Die *base)
   assert (dwarf_tag (base) == DW_TAG_base_type);
 
   Dwarf_Attribute encoding;
-  Dwarf_Word enctype;
+  Dwarf_Word enctype = 0;
   if (dwarf_attr (base, DW_AT_encoding, &encoding) == NULL
       || dwarf_formudata (&encoding, &enctype) != 0)
     error (EXIT_FAILURE, 0, "base type without encoding");
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] Fix type warnings from clang compiler.
@ 2015-09-04 19:04 Chih-Hung Hsieh
  0 siblings, 0 replies; 6+ messages in thread
From: Chih-Hung Hsieh @ 2015-09-04 19:04 UTC (permalink / raw)
  To: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 20109 bytes --]

* Replace K&R function definition with prototypes to match their declarations.
  Clang gives errors of: promoted type 'int' of K&R function parameter is not compatible with the parameter type
* Add const declaration to locs, which was passed a const.
  Clang gives errors of: passing 'const Elf_Data *' to parameter of type 'Elf_Data *' discards qualifiers
* Avoid clang errors of: comparison of nonnull parameter ... equal to a null pointer is false
  on first encounter [-Werror,-Wtautological-pointer-compare]
  The parameter was declared as non-null.
* Replace abs with labs for int64 values.
* Remove unused static variables.
* Init local variable before use, where static analysis failed.

Signed-off-by: Chih-Hung Hsieh <chh@google.com>
---
 backends/aarch64_init.c         | 10 +++++-----
 backends/aarch64_regs.c         |  8 +++++---
 backends/alpha_init.c           | 10 +++++-----
 backends/arm_init.c             | 10 +++++-----
 backends/i386_init.c            | 10 +++++-----
 backends/ia64_init.c            | 10 +++++-----
 backends/ppc64_init.c           | 10 +++++-----
 backends/ppc_init.c             | 10 +++++-----
 backends/s390_init.c            | 10 +++++-----
 backends/sh_init.c              | 10 +++++-----
 backends/sparc_init.c           | 10 +++++-----
 backends/tilegx_init.c          | 10 +++++-----
 backends/x86_64_init.c          | 10 +++++-----
 libasm/asm_addint8.c            |  4 +---
 libasm/asm_adduint8.c           |  4 +---
 libasm/asm_begin.c              |  5 +----
 libdw/dwarf_getlocation.c       |  2 +-
 libdw/dwarf_macro_getsrcfiles.c |  2 +-
 libdw/dwarf_next_cfi.c          | 14 +++++++-------
 libdw/dwarf_siblingof.c         |  2 +-
 libdw/libdw_findcu.c            |  9 ++-------
 libdw/libdw_visit_scopes.c      |  2 +-
 libdwfl/dwfl_frame.c            |  3 ++-
 libdwfl/dwfl_module_getelf.c    |  2 +-
 libdwfl/frame_unwind.c          |  2 +-
 libebl/ebldwarftoregno.c        |  2 +-
 libebl/eblinitreg.c             |  2 +-
 libebl/eblnormalizepc.c         |  2 +-
 libebl/eblopenbackend.c         |  3 +--
 libebl/eblstother.c             |  4 +---
 libebl/eblunwind.c              |  2 +-
 tests/md5-sha1-test.c           |  8 --------
 tests/varlocs.c                 |  2 +-
 33 files changed, 92 insertions(+), 112 deletions(-)

diff --git a/backends/aarch64_init.c b/backends/aarch64_init.c
index b0fd17a..18fdd3e 100644
--- a/backends/aarch64_init.c
+++ b/backends/aarch64_init.c
@@ -39,11 +39,11 @@
 
 
 const char *
-aarch64_init (elf, machine, eh, ehlen)
-     Elf *elf __attribute__ ((unused));
-     GElf_Half machine __attribute__ ((unused));
-     Ebl *eh;
-     size_t ehlen;
+aarch64_init (
+     Elf *elf __attribute__ ((unused)),
+     GElf_Half machine __attribute__ ((unused)),
+     Ebl *eh,
+     size_t ehlen)
 {
   /* Check whether the Elf_BH object has a sufficent size.  */
   if (ehlen < sizeof (Ebl))
diff --git a/backends/aarch64_regs.c b/backends/aarch64_regs.c
index 7a8a678..886e3a8 100644
--- a/backends/aarch64_regs.c
+++ b/backends/aarch64_regs.c
@@ -40,9 +40,11 @@
 
 ssize_t
 aarch64_register_info (Ebl *ebl __attribute__ ((unused)),
-		       int regno, char *name, size_t namelen,
-		       const char **prefix, const char **setnamep,
-		       int *bits, int *typep)
+		       int regno, char *name,
+		       size_t namelen __attribute__((unused)),
+		       const char **prefix,
+		       const char **setnamep __attribute__((unused)),
+		       int *bits, int *typep __attribute__((unused)))
 {
   if (name == NULL)
     return 128;
diff --git a/backends/alpha_init.c b/backends/alpha_init.c
index a3307d8..a18596c 100644
--- a/backends/alpha_init.c
+++ b/backends/alpha_init.c
@@ -40,11 +40,11 @@
 
 
 const char *
-alpha_init (elf, machine, eh, ehlen)
-     Elf *elf __attribute__ ((unused));
-     GElf_Half machine __attribute__ ((unused));
-     Ebl *eh;
-     size_t ehlen;
+alpha_init (
+     Elf *elf __attribute__ ((unused)),
+     GElf_Half machine __attribute__ ((unused)),
+     Ebl *eh,
+     size_t ehlen)
 {
   /* Check whether the Elf_BH object has a sufficent size.  */
   if (ehlen < sizeof (Ebl))
diff --git a/backends/arm_init.c b/backends/arm_init.c
index f3e5f0a..3c74778 100644
--- a/backends/arm_init.c
+++ b/backends/arm_init.c
@@ -40,11 +40,11 @@
 
 
 const char *
-arm_init (elf, machine, eh, ehlen)
-     Elf *elf __attribute__ ((unused));
-     GElf_Half machine __attribute__ ((unused));
-     Ebl *eh;
-     size_t ehlen;
+arm_init (
+     Elf *elf __attribute__ ((unused)),
+     GElf_Half machine __attribute__ ((unused)),
+     Ebl *eh,
+     size_t ehlen)
 {
   /* Check whether the Elf_BH object has a sufficent size.  */
   if (ehlen < sizeof (Ebl))
diff --git a/backends/i386_init.c b/backends/i386_init.c
index 1e0b486..1ed8520 100644
--- a/backends/i386_init.c
+++ b/backends/i386_init.c
@@ -39,11 +39,11 @@
 #include "common-reloc.c"
 
 const char *
-i386_init (elf, machine, eh, ehlen)
-     Elf *elf __attribute__ ((unused));
-     GElf_Half machine __attribute__ ((unused));
-     Ebl *eh;
-     size_t ehlen;
+i386_init (
+     Elf *elf __attribute__ ((unused)),
+     GElf_Half machine __attribute__ ((unused)),
+     Ebl *eh,
+     size_t ehlen)
 {
   /* Check whether the Elf_BH object has a sufficent size.  */
   if (ehlen < sizeof (Ebl))
diff --git a/backends/ia64_init.c b/backends/ia64_init.c
index 91da748..178c289 100644
--- a/backends/ia64_init.c
+++ b/backends/ia64_init.c
@@ -39,11 +39,11 @@
 #include "common-reloc.c"
 
 const char *
-ia64_init (elf, machine, eh, ehlen)
-     Elf *elf __attribute__ ((unused));
-     GElf_Half machine __attribute__ ((unused));
-     Ebl *eh;
-     size_t ehlen;
+ia64_init (
+     Elf *elf __attribute__ ((unused)),
+     GElf_Half machine __attribute__ ((unused)),
+     Ebl *eh,
+     size_t ehlen)
 {
   /* Check whether the Elf_BH object has a sufficent size.  */
   if (ehlen < sizeof (Ebl))
diff --git a/backends/ppc64_init.c b/backends/ppc64_init.c
index 56e1828..d34e0f8 100644
--- a/backends/ppc64_init.c
+++ b/backends/ppc64_init.c
@@ -42,11 +42,11 @@
 
 
 const char *
-ppc64_init (elf, machine, eh, ehlen)
-     Elf *elf __attribute__ ((unused));
-     GElf_Half machine __attribute__ ((unused));
-     Ebl *eh;
-     size_t ehlen;
+ppc64_init (
+     Elf *elf __attribute__ ((unused)),
+     GElf_Half machine __attribute__ ((unused)),
+     Ebl *eh,
+     size_t ehlen)
 {
   /* Check whether the Elf_BH object has a sufficent size.  */
   if (ehlen < sizeof (Ebl))
diff --git a/backends/ppc_init.c b/backends/ppc_init.c
index ad92765..366dd3c 100644
--- a/backends/ppc_init.c
+++ b/backends/ppc_init.c
@@ -40,11 +40,11 @@
 
 
 const char *
-ppc_init (elf, machine, eh, ehlen)
-     Elf *elf __attribute__ ((unused));
-     GElf_Half machine __attribute__ ((unused));
-     Ebl *eh;
-     size_t ehlen;
+ppc_init (
+     Elf *elf __attribute__ ((unused)),
+     GElf_Half machine __attribute__ ((unused)),
+     Ebl *eh,
+     size_t ehlen)
 {
   /* Check whether the Elf_BH object has a sufficent size.  */
   if (ehlen < sizeof (Ebl))
diff --git a/backends/s390_init.c b/backends/s390_init.c
index 26b20b4..05e1c35 100644
--- a/backends/s390_init.c
+++ b/backends/s390_init.c
@@ -41,11 +41,11 @@ extern __typeof (s390_core_note) s390x_core_note;
 
 
 const char *
-s390_init (elf, machine, eh, ehlen)
-     Elf *elf __attribute__ ((unused));
-     GElf_Half machine __attribute__ ((unused));
-     Ebl *eh;
-     size_t ehlen;
+s390_init (
+     Elf *elf __attribute__ ((unused)),
+     GElf_Half machine __attribute__ ((unused)),
+     Ebl *eh,
+     size_t ehlen)
 {
   /* Check whether the Elf_BH object has a sufficent size.  */
   if (ehlen < sizeof (Ebl))
diff --git a/backends/sh_init.c b/backends/sh_init.c
index 90ddcb2..405b709 100644
--- a/backends/sh_init.c
+++ b/backends/sh_init.c
@@ -40,11 +40,11 @@
 
 
 const char *
-sh_init (elf, machine, eh, ehlen)
-     Elf *elf __attribute__ ((unused));
-     GElf_Half machine __attribute__ ((unused));
-     Ebl *eh;
-     size_t ehlen;
+sh_init (
+     Elf *elf __attribute__ ((unused)),
+     GElf_Half machine __attribute__ ((unused)),
+     Ebl *eh,
+     size_t ehlen)
 {
   /* Check whether the Elf_BH object has a sufficent size.  */
   if (ehlen < sizeof (Ebl))
diff --git a/backends/sparc_init.c b/backends/sparc_init.c
index 7d22998..e69b9af 100644
--- a/backends/sparc_init.c
+++ b/backends/sparc_init.c
@@ -40,11 +40,11 @@
 extern __typeof (EBLHOOK (core_note)) sparc64_core_note attribute_hidden;
 
 const char *
-sparc_init (elf, machine, eh, ehlen)
-     Elf *elf __attribute__ ((unused));
-     GElf_Half machine __attribute__ ((unused));
-     Ebl *eh;
-     size_t ehlen;
+sparc_init (
+     Elf *elf __attribute__ ((unused)),
+     GElf_Half machine __attribute__ ((unused)),
+     Ebl *eh,
+     size_t ehlen)
 {
   /* Check whether the Elf_BH object has a sufficent size.  */
   if (ehlen < sizeof (Ebl))
diff --git a/backends/tilegx_init.c b/backends/tilegx_init.c
index 858798b..77e1b4b 100644
--- a/backends/tilegx_init.c
+++ b/backends/tilegx_init.c
@@ -38,11 +38,11 @@
 #include "common-reloc.c"
 
 const char *
-tilegx_init (elf, machine, eh, ehlen)
-     Elf *elf __attribute__ ((unused));
-     GElf_Half machine __attribute__ ((unused));
-     Ebl *eh;
-     size_t ehlen;
+tilegx_init (
+     Elf *elf __attribute__ ((unused)),
+     GElf_Half machine __attribute__ ((unused)),
+     Ebl *eh,
+     size_t ehlen)
 {
   /* Check whether the Elf_BH object has a sufficent size.  */
   if (ehlen < sizeof (Ebl))
diff --git a/backends/x86_64_init.c b/backends/x86_64_init.c
index 273eabb..882e99e 100644
--- a/backends/x86_64_init.c
+++ b/backends/x86_64_init.c
@@ -42,11 +42,11 @@
 extern __typeof (EBLHOOK (core_note)) x32_core_note attribute_hidden;
 
 const char *
-x86_64_init (elf, machine, eh, ehlen)
-     Elf *elf __attribute__ ((unused));
-     GElf_Half machine __attribute__ ((unused));
-     Ebl *eh;
-     size_t ehlen;
+x86_64_init (
+     Elf *elf __attribute__ ((unused)),
+     GElf_Half machine __attribute__ ((unused)),
+     Ebl *eh,
+     size_t ehlen)
 {
   /* Check whether the Elf_BH object has a sufficent size.  */
   if (ehlen < sizeof (Ebl))
diff --git a/libasm/asm_addint8.c b/libasm/asm_addint8.c
index ec05b8d..bb7d40f 100644
--- a/libasm/asm_addint8.c
+++ b/libasm/asm_addint8.c
@@ -51,9 +51,7 @@
 
 
 int
-FCT(SIZE) (asmscn, num)
-     AsmScn_t *asmscn;
-     TYPE(SIZE) num;
+FCT(SIZE) (AsmScn_t *asmscn, TYPE(SIZE) num)
 {
   if (asmscn == NULL)
     return -1;
diff --git a/libasm/asm_adduint8.c b/libasm/asm_adduint8.c
index 30641b8..18b67dd 100644
--- a/libasm/asm_adduint8.c
+++ b/libasm/asm_adduint8.c
@@ -48,9 +48,7 @@
 
 
 int
-UFCT(SIZE) (asmscn, num)
-     AsmScn_t *asmscn;
-     UTYPE(SIZE) num;
+UFCT(SIZE) (AsmScn_t *asmscn, UTYPE(SIZE) num)
 {
   return INTUSE(FCT(SIZE)) (asmscn, (TYPE(SIZE)) num);
 }
diff --git a/libasm/asm_begin.c b/libasm/asm_begin.c
index 48842d3..ff4d94c 100644
--- a/libasm/asm_begin.c
+++ b/libasm/asm_begin.c
@@ -127,10 +127,7 @@ prepare_binary_output (AsmCtx_t *result, Ebl *ebl)
 
 
 AsmCtx_t *
-asm_begin (fname, ebl, textp)
-     const char *fname;
-     Ebl *ebl;
-     bool textp;
+asm_begin (const char *fname, Ebl *ebl, bool textp)
 {
   if (fname == NULL && ! textp)
     return NULL;
diff --git a/libdw/dwarf_getlocation.c b/libdw/dwarf_getlocation.c
index f1dda68..1aa6a3c 100644
--- a/libdw/dwarf_getlocation.c
+++ b/libdw/dwarf_getlocation.c
@@ -688,7 +688,7 @@ getlocations_addr (attr, offset, basep, startp, endp, address,
      Dwarf_Addr *startp;
      Dwarf_Addr *endp;
      Dwarf_Addr address;
-     Elf_Data *locs;
+     const Elf_Data *locs;
      Dwarf_Op **expr;
      size_t *exprlen;
 {
diff --git a/libdw/dwarf_macro_getsrcfiles.c b/libdw/dwarf_macro_getsrcfiles.c
index cc19043..8b72611 100644
--- a/libdw/dwarf_macro_getsrcfiles.c
+++ b/libdw/dwarf_macro_getsrcfiles.c
@@ -36,7 +36,7 @@ int
 dwarf_macro_getsrcfiles (Dwarf *dbg, Dwarf_Macro *macro,
 			 Dwarf_Files **files, size_t *nfiles)
 {
-  if (macro == NULL)
+  if ((void*) macro == NULL)  /* macro was declared NN */
     return -1;
 
   Dwarf_Macro_Op_Table *const table = macro->table;
diff --git a/libdw/dwarf_next_cfi.c b/libdw/dwarf_next_cfi.c
index b5af49e..63dd471 100644
--- a/libdw/dwarf_next_cfi.c
+++ b/libdw/dwarf_next_cfi.c
@@ -37,13 +37,13 @@
 
 
 int
-dwarf_next_cfi (e_ident, data, eh_frame_p, off, next_off, entry)
-     const unsigned char e_ident[];
-     Elf_Data *data;
-     bool eh_frame_p;
-     Dwarf_Off off;
-     Dwarf_Off *next_off;
-     Dwarf_CFI_Entry *entry;
+dwarf_next_cfi (
+     const unsigned char e_ident[],
+     Elf_Data *data,
+     bool eh_frame_p,
+     Dwarf_Off off,
+     Dwarf_Off *next_off,
+     Dwarf_CFI_Entry *entry)
 {
   /* Dummy struct for memory-access.h macros.  */
   BYTE_ORDER_DUMMY (dw, e_ident);
diff --git a/libdw/dwarf_siblingof.c b/libdw/dwarf_siblingof.c
index e598ae4..88bfbe6 100644
--- a/libdw/dwarf_siblingof.c
+++ b/libdw/dwarf_siblingof.c
@@ -45,7 +45,7 @@ dwarf_siblingof (die, result)
   if (die == NULL)
     return -1;
 
-  if (result == NULL)
+  if ((void*) result == NULL)  /* result was declared NN */
     return -1;
 
   if (result != die)
diff --git a/libdw/libdw_findcu.c b/libdw/libdw_findcu.c
index d8da2e3..5c03843 100644
--- a/libdw/libdw_findcu.c
+++ b/libdw/libdw_findcu.c
@@ -63,9 +63,7 @@ findcu_cb (const void *arg1, const void *arg2)
 
 struct Dwarf_CU *
 internal_function
-__libdw_intern_next_unit (dbg, debug_types)
-     Dwarf *dbg;
-     bool debug_types;
+__libdw_intern_next_unit (Dwarf *dbg, bool debug_types)
 {
   Dwarf_Off *const offsetp
     = debug_types ? &dbg->next_tu_offset : &dbg->next_cu_offset;
@@ -135,10 +133,7 @@ __libdw_intern_next_unit (dbg, debug_types)
 }
 
 struct Dwarf_CU *
-__libdw_findcu (dbg, start, debug_types)
-     Dwarf *dbg;
-     Dwarf_Off start;
-     bool debug_types;
+__libdw_findcu (Dwarf *dbg, Dwarf_Off start, bool debug_types)
 {
   void **tree = debug_types ? &dbg->tu_tree : &dbg->cu_tree;
   Dwarf_Off *next_offset
diff --git a/libdw/libdw_visit_scopes.c b/libdw/libdw_visit_scopes.c
index ac7e853..b8d25f4 100644
--- a/libdw/libdw_visit_scopes.c
+++ b/libdw/libdw_visit_scopes.c
@@ -138,7 +138,7 @@ __libdw_visit_scopes (depth, root, imports, previsit, postvisit, arg)
 
 	child.prune = false;
 
-	if (previsit != NULL)
+	if ((void*) previsit != NULL)  /* previsit was declared NN */
 	  {
 	    int result = (*previsit) (depth + 1, &child, arg);
 	    if (result != DWARF_CB_OK)
diff --git a/libdwfl/dwfl_frame.c b/libdwfl/dwfl_frame.c
index f6f86c0..3fb02e8 100644
--- a/libdwfl/dwfl_frame.c
+++ b/libdwfl/dwfl_frame.c
@@ -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
+  if ((void*) thread_callbacks == NULL  /* thread_callbacks was declared NN */
+      || thread_callbacks->next_thread == NULL
       || thread_callbacks->set_initial_registers == NULL)
     {
       dwfl->attacherr = DWFL_E_INVALID_ARGUMENT;
diff --git a/libdwfl/dwfl_module_getelf.c b/libdwfl/dwfl_module_getelf.c
index f20fb04..31b8fe4 100644
--- a/libdwfl/dwfl_module_getelf.c
+++ b/libdwfl/dwfl_module_getelf.c
@@ -31,7 +31,7 @@
 Elf *
 dwfl_module_getelf (Dwfl_Module *mod, GElf_Addr *loadbase)
 {
-  if (mod == NULL)
+  if ((void*) mod == NULL) /* mod was declared NN */
     return NULL;
 
   __libdwfl_getelf (mod);
diff --git a/libdwfl/frame_unwind.c b/libdwfl/frame_unwind.c
index 16cebd0..6f08693 100644
--- a/libdwfl/frame_unwind.c
+++ b/libdwfl/frame_unwind.c
@@ -342,7 +342,7 @@ expr_eval (Dwfl_Frame *state, Dwarf_Frame *frame, const Dwarf_Op *ops,
 	      return false;						\
 	    }								\
 	  break;
-	UNOP (DW_OP_abs, abs ((int64_t) val1))
+	UNOP (DW_OP_abs, labs ((int64_t) val1))
 	UNOP (DW_OP_neg, -(int64_t) val1)
 	UNOP (DW_OP_not, ~val1)
 #undef UNOP
diff --git a/libebl/ebldwarftoregno.c b/libebl/ebldwarftoregno.c
index 8fb8540..bdb34e6 100644
--- a/libebl/ebldwarftoregno.c
+++ b/libebl/ebldwarftoregno.c
@@ -35,7 +35,7 @@
 bool
 ebl_dwarf_to_regno (Ebl *ebl, unsigned *regno)
 {
-  if (ebl == NULL)
+  if ((void*) ebl == NULL) /* ebl was declared NN */
     return false;
   return ebl->dwarf_to_regno == NULL ? true : ebl->dwarf_to_regno (ebl, regno);
 }
diff --git a/libebl/eblinitreg.c b/libebl/eblinitreg.c
index 5729b3c..4bce66c 100644
--- a/libebl/eblinitreg.c
+++ b/libebl/eblinitreg.c
@@ -47,7 +47,7 @@ ebl_set_initial_registers_tid (Ebl *ebl, pid_t tid,
 size_t
 ebl_frame_nregs (Ebl *ebl)
 {
-  return ebl == NULL ? 0 : ebl->frame_nregs;
+  return (void*) ebl == NULL ? 0 : ebl->frame_nregs;  /* ebl was declared NN */
 }
 
 GElf_Addr
diff --git a/libebl/eblnormalizepc.c b/libebl/eblnormalizepc.c
index a5fea77..d7175ab 100644
--- a/libebl/eblnormalizepc.c
+++ b/libebl/eblnormalizepc.c
@@ -35,6 +35,6 @@
 void
 ebl_normalize_pc (Ebl *ebl, Dwarf_Addr *pc)
 {
-  if (ebl != NULL && ebl->normalize_pc != NULL)
+  if ((void*) ebl != NULL && ebl->normalize_pc != NULL)
     ebl->normalize_pc (ebl, pc);
 }
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index 2766e7b..02b24d3 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -418,8 +418,7 @@ ebl_openbackend (elf)
 
 /* Find backend without underlying ELF file.  */
 Ebl *
-ebl_openbackend_machine (machine)
-     GElf_Half machine;
+ebl_openbackend_machine (GElf_Half machine)
 {
   return openbackend (NULL, NULL, machine);
 }
diff --git a/libebl/eblstother.c b/libebl/eblstother.c
index ccbf138..273f6fc 100644
--- a/libebl/eblstother.c
+++ b/libebl/eblstother.c
@@ -34,9 +34,7 @@
 
 
 bool
-ebl_check_st_other_bits (ebl, st_other)
-     Ebl *ebl;
-     unsigned char st_other;
+ebl_check_st_other_bits (Ebl *ebl, unsigned char st_other)
 {
   return ((st_other ^ GELF_ST_VISIBILITY (st_other)) == 0
 	  || ebl->check_st_other_bits (st_other ^ GELF_ST_VISIBILITY (st_other)));
diff --git a/libebl/eblunwind.c b/libebl/eblunwind.c
index 1251c1b..ddd95a3 100644
--- a/libebl/eblunwind.c
+++ b/libebl/eblunwind.c
@@ -37,7 +37,7 @@ 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)
+  if ((void*) ebl == NULL || ebl->unwind == NULL) /* ebl was declared NN */
     return false;
   return ebl->unwind (ebl, pc, setfunc, getfunc, readfunc, arg, signal_framep);
 }
diff --git a/tests/md5-sha1-test.c b/tests/md5-sha1-test.c
index 49de078..d50355e 100644
--- a/tests/md5-sha1-test.c
+++ b/tests/md5-sha1-test.c
@@ -61,14 +61,6 @@ static const struct expected
 #define md5_size	16
 #define sha1_size	20
 
-static const char md5_expected[] =
-  {
-  };
-
-static const char sha1_expected[] =
-  {
-  };
-
 #define TEST_HASH(ALGO, I)						      \
   {									      \
     struct ALGO##_ctx ctx;						      \
diff --git a/tests/varlocs.c b/tests/varlocs.c
index b5733e7..c3fba89 100644
--- a/tests/varlocs.c
+++ b/tests/varlocs.c
@@ -82,7 +82,7 @@ print_base_type (Dwarf_Die *base)
   assert (dwarf_tag (base) == DW_TAG_base_type);
 
   Dwarf_Attribute encoding;
-  Dwarf_Word enctype;
+  Dwarf_Word enctype = 0;
   if (dwarf_attr (base, DW_AT_encoding, &encoding) == NULL
       || dwarf_formudata (&encoding, &enctype) != 0)
     error (EXIT_FAILURE, 0, "base type without encoding");
-- 
2.5.0.457.gab17608


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-09-10 12:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-09 11:32 [PATCH] Fix type warnings from clang compiler Mark Wielaard
  -- strict thread matches above, loose matches on Subject: below --
2015-09-10 12:13 Mark Wielaard
2015-09-09 21:12 Chih-Hung Hsieh
2015-09-08 22:14 Chih-Hung Hsieh
2015-09-07 22:32 Mark Wielaard
2015-09-04 19:04 Chih-Hung Hsieh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).