diff mbox series

[dwarves,2/2] dwarves: Fix clang warning about unused variable

Message ID 20250306170455.2957229-3-alan.maguire@oracle.com (mailing list archive)
State Not Applicable
Headers show
Series dwarves: Introduce github actions for CI | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Alan Maguire March 6, 2025, 5:04 p.m. UTC
With dwarves CI, clang builds give a legit warning:

/build/dwarves_fprintf.c:2102:9: error: variable 'printed' set but not used [-Werror,-Wunused-but-set-variable]
 2102 |         size_t printed = fprintf(fp, "namespace %s {\n", namespace__name(space));
      |                ^
1 error generated.

And in fact we accumulate values in printed but never use it
for the return value.  Add the printed count to the final fprintf().

Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
---
 dwarves_fprintf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/dwarves_fprintf.c b/dwarves_fprintf.c
index c3e7f3c..4407fd1 100644
--- a/dwarves_fprintf.c
+++ b/dwarves_fprintf.c
@@ -2110,7 +2110,7 @@  static size_t namespace__fprintf(const struct tag *tag, const struct cu *cu,
 		printed += fprintf(fp, "\n\n");
 	}
 
-	return fprintf(fp, "%.*s}", conf->indent, tabs);
+	return printed + fprintf(fp, "%.*s}", conf->indent, tabs);
 }
 
 size_t tag__fprintf(struct tag *tag, const struct cu *cu,