Skip to contentSkip to conversation

Avoid warning when building with NDEBUG

PATCH Arnaldo Carvalho de Melo 2 participants 3 messages Feb 18, 2021 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Em Thu, Feb 18, 2021 at 09:51:15AM -0800, Ian Rogers escreveu:

Quoted 6 lines

The assert macro is compiled out with NDEBUG which can lead to an unused variable warning if the variable is only read in the assert. This is seen just here:

dwarf_loader.c:957:17: error: unused variable 'tag' [-Werror,-Wunused-variable]

        const uint16_t tag = dwarf_tag(die);

Thanks Ian, I added:

And CC: [email protected]

Please let me know if this is all ok.

- Arnaldo

Quoted 23 lines
---
 dwarf_loader.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
dwarf_loader.c +2 -1
index b73d786..22c3a55 100644
@@ -954,9 +954,10 @@ static struct lexblock *lexblock__new(Dwarf_Die *die, struct cu *cu)
 
 static void ftype__init(struct ftype *ftype, Dwarf_Die *die, struct cu *cu)
 {
+#ifndef NDEBUG
 	const uint16_t tag = dwarf_tag(die);
 	assert(tag == DW_TAG_subprogram || tag == DW_TAG_subroutine_type);
-
+#endif
 	tag__init(&ftype->tag, cu, die);
 	INIT_LIST_HEAD(&ftype->parms);
 	ftype->nr_parms	    = 0;
Signature · 1 line
2.30.0.617.g56c4b15f3c-goog
Signature · 1 line
- Arnaldo
#2 lore raw
Quoted 11 lines · Arnaldo Carvalho de Melo

Em Thu, Feb 18, 2021 at 09:51:15AM -0800, Ian Rogers escreveu:

Quoted 6 lines

The assert macro is compiled out with NDEBUG which can lead to an unused variable warning if the variable is only read in the assert. This is seen just here:

dwarf_loader.c:957:17: error: unused variable 'tag' [-Werror,-Wunused-variable]

        const uint16_t tag = dwarf_tag(die);

Thanks Ian, I added:

Quoted 7 lines

And CC: [email protected]

Please let me know if this is all ok.

- Arnaldo

That's okay by me, sorry for not posting in the right way and I'm also happy if this is just a bug report rather than a merged fix :-)

Thanks!
Ian

Quoted 27 lines
Quoted 21 lines
---
 dwarf_loader.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
dwarf_loader.c +2 -2
index b73d786..22c3a55 100644
@@ -954,9 +954,10 @@ static struct lexblock *lexblock__new(Dwarf_Die *die, struct cu *cu)
 
 static void ftype__init(struct ftype *ftype, Dwarf_Die *die, struct cu *cu)
 {
+#ifndef NDEBUG
      const uint16_t tag = dwarf_tag(die);
      assert(tag == DW_TAG_subprogram || tag == DW_TAG_subroutine_type);
-
+#endif
      tag__init(&ftype->tag, cu, die);
      INIT_LIST_HEAD(&ftype->parms);
      ftype->nr_parms     = 0;
--
Quoted 2 lines

2.30.0.617.g56c4b15f3c-goog

--

- Arnaldo

#3 lore raw

Em Thu, Feb 18, 2021 at 11:34:31AM -0800, Ian Rogers escreveu:

Quoted 15 lines
Quoted 13 lines · Arnaldo Carvalho de Melo

Em Thu, Feb 18, 2021 at 09:51:15AM -0800, Ian Rogers escreveu:

Quoted 6 lines

The assert macro is compiled out with NDEBUG which can lead to an unused variable warning if the variable is only read in the assert. This is seen just here:

dwarf_loader.c:957:17: error: unused variable 'tag' [-Werror,-Wunused-variable]

        const uint16_t tag = dwarf_tag(die);

Thanks Ian, I added:

Quoted 8 lines
Quoted 5 lines

And CC: [email protected]

Please let me know if this is all ok.

- Arnaldo

That's okay by me, sorry for not posting in the right way and I'm also happy if this is just a bug report rather than a merged fix :-)

It's in my local branch now, thanks!

- Arnaldo

Quoted 30 lines

Thanks!
Ian

Quoted 27 lines
Quoted 21 lines
---
 dwarf_loader.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
dwarf_loader.c +2 -2
index b73d786..22c3a55 100644
@@ -954,9 +954,10 @@ static struct lexblock *lexblock__new(Dwarf_Die *die, struct cu *cu)
 
 static void ftype__init(struct ftype *ftype, Dwarf_Die *die, struct cu *cu)
 {
+#ifndef NDEBUG
      const uint16_t tag = dwarf_tag(die);
      assert(tag == DW_TAG_subprogram || tag == DW_TAG_subroutine_type);
-
+#endif
      tag__init(&ftype->tag, cu, die);
      INIT_LIST_HEAD(&ftype->parms);
      ftype->nr_parms     = 0;
--
Quoted 2 lines

2.30.0.617.g56c4b15f3c-goog

--

- Arnaldo

Signature · 1 line
- Arnaldo