[PATCH 28/31] pfunct, dwarves_fprintf: Mark file-local functions as static

Arnaldo Carvalho de Melo <[email protected]> Wed, 29 Jul 2026 16:07:28 -0300
Newsgroups org.kernel.vger.dwarves,org.kernel.vger.bpf
Message-ID <[email protected]>
From: Arnaldo Carvalho de Melo <[email protected]>

Coverage analysis found 3 functions that were never declared in any
header and are only called within their own translation unit, yet
lacked the 'static' qualifier:

pfunct.c:
  elf_symtab__show:   introduced in 640bfd9679b4 ("pfunct: Introduce
                      --symtab", 2009), always local to the pfunct
                      executable.
  elf_symtabs__show:  introduced in the same commit, wrapper that
                      iterates elf_symtab__show over multiple files.

dwarves_fprintf.c:
  filename__read_int: introduced in 9f9588dc2bd8 ("fprintf: Add
                      alternative method for reading the data cacheline
                      size", 2021), only compiled on platforms without
                      _SC_LEVEL1_DCACHE_LINESIZE, only called by
                      cacheline_size() in the same file.

None were exported from shared libraries (pfunct is an executable;
filename__read_int is behind an #ifndef that evaluates to false on
Linux).  Adding 'static' lets the compiler warn if they ever become
truly dead and enables better inlining/optimization.

Before: 3 functions global without external callers
After:  3 functions properly marked static

Assisted-by: Claude:claude-sonnet-4-5
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
 dwarves_fprintf.c | 2 +-
 pfunct.c          | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/dwarves_fprintf.c b/dwarves_fprintf.c
index e44ac05c3b9e7e73..d7edb0cb14a5b803 100644
--- a/dwarves_fprintf.c
+++ b/dwarves_fprintf.c
@@ -2242,7 +2242,7 @@ void cus__print_error_msg(const char *progname, const struct cus *cus,
 }
 
 #ifndef _SC_LEVEL1_DCACHE_LINESIZE
-int filename__read_int(const char *filename, int *value)
+static int filename__read_int(const char *filename, int *value)
 {
         char line[64];
         int fd = open(filename, O_RDONLY), err = -1;
diff --git a/pfunct.c b/pfunct.c
index 5a6dd59a1c7a30b1..237bd54ab9319b0f 100644
--- a/pfunct.c
+++ b/pfunct.c
@@ -426,7 +426,7 @@ static int cu_function_iterator(struct cu *cu, void *cookie __maybe_unused)
 	return 0;
 }
 
-int elf_symtab__show(char *filename)
+static int elf_symtab__show(char *filename)
 {
 	int fd = open(filename, O_RDONLY), err = -1;
 	if (fd < 0)
@@ -494,7 +494,7 @@ out_close:
 	return err;
 }
 
-int elf_symtabs__show(char *filenames[])
+static int elf_symtabs__show(char *filenames[])
 {
 	int i = 0;
 
-- 
2.55.0