Skip to contentSkip to conversation

btrfs-progs: tests: fix warnings during make test

PATCH In review Anand Jain 2 participants 6 messages Jun 23, 2023 – Jun 28, 2023 Btrfs file system

lore
Share & tools
lore

Anand Jain

author
#0 lore raw

cover btrfs-progs: tests: fix warnings during make test

This set of patches addresses the warnings when running the following commands:

  $ rm fssum fsstress
  $ make test

Ensure cleaner test suite for btrfs-progs.

Anand Jain (4):
btrfs-progs: tests/fssum.c: fix missing prototype warning
btrfs-progs: tests/fsstress.c: move do_mmap under HAVE_SYS_MMAN_H
btrfs-progs: tests/fsstress.c: move do_fallocate under
HAVE_LINUX_FALLOC_H
btrfs-progs: tests/fsstress.c: move delete_subvol_children under
HAVE_BTRFSUTIL_H

 tests/fsstress.c | 10 ++++++----
 tests/fssum.c    | 46 +++++++++++++++++++++++-----------------------
 2 files changed, 29 insertions(+), 27 deletions(-)
Signature · 1 line
2.39.2
author
#1 lore raw

PATCH 1/4 btrfs-progs: tests/fssum.c: fix missing prototype warning

Annoying warnings when running 'make test' from the file tests/fssum.c. gcc version 8.5.0. Fix the it by declaring the corresponding functions as static.

$ rm fssum
$ make TEST=001\* test-misc
::
tests/fssum.c:86:1: warning: no previous prototype for ‘getln’ [-Wmissing-prototypes]
   86 | getln(char *buf, int size, FILE *fp)
      | ^~~~~
tests/fssum.c:103:1: warning: no previous prototype for ‘parse_flag’ [-Wmissing-prototypes]
  103 | parse_flag(int c)
      | ^~~~~~~~~~
tests/fssum.c:123:1: warning: no previous prototype for ‘parse_flags’ [-Wmissing-prototypes]
  123 | parse_flags(char *p)
      | ^~~~~~~~~~~
tests/fssum.c:130:1: warning: no previous prototype for ‘usage’ [-Wmissing-prototypes]
  130 | usage(void)
      | ^~~~~
tests/fssum.c:163:1: warning: no previous prototype for ‘alloc’ [-Wmissing-prototypes]
  163 | alloc(size_t sz)
      | ^~~~~
tests/fssum.c:176:1: warning: no previous prototype for ‘sum_init’ [-Wmissing-prototypes]
  176 | sum_init(sum_t *cs)
      | ^~~~~~~~
tests/fssum.c:182:1: warning: no previous prototype for ‘sum_fini’ [-Wmissing-prototypes]
  182 | sum_fini(sum_t *cs)
      | ^~~~~~~~
tests/fssum.c:188:1: warning: no previous prototype for ‘sum_add’ [-Wmissing-prototypes]
  188 | sum_add(sum_t *cs, void *buf, int size)
      | ^~~~~~~
tests/fssum.c:194:1: warning: no previous prototype for ‘sum_add_sum’ [-Wmissing-prototypes]
  194 | sum_add_sum(sum_t *dst, sum_t *src)
      | ^~~~~~~~~~~
tests/fssum.c:200:1: warning: no previous prototype for ‘sum_add_u64’ [-Wmissing-prototypes]
  200 | sum_add_u64(sum_t *dst, uint64_t val)
      | ^~~~~~~~~~~
tests/fssum.c:207:1: warning: no previous prototype for ‘sum_add_time’ [-Wmissing-prototypes]
  207 | sum_add_time(sum_t *dst, time_t t)
      | ^~~~~~~~~~~~
tests/fssum.c:213:1: warning: no previous prototype for ‘sum_to_string’ [-Wmissing-prototypes]
  213 | sum_to_string(sum_t *dst)
      | ^~~~~~~~~~~~~
tests/fssum.c:225:1: warning: no previous prototype for ‘namecmp’ [-Wmissing-prototypes]
  225 | namecmp(const void *aa, const void *bb)
      | ^~~~~~~
tests/fssum.c:234:1: warning: no previous prototype for ‘sum_xattrs’ [-Wmissing-prototypes]
  234 | sum_xattrs(int fd, sum_t *dst)
      | ^~~~~~~~~~
tests/fssum.c:325:1: warning: no previous prototype for ‘sum_file_data_permissive’ [-Wmissing-prototypes]
  325 | sum_file_data_permissive(int fd, sum_t *dst)
      | ^~~~~~~~~~~~~~~~~~~~~~~~
tests/fssum.c:341:1: warning: no previous prototype for ‘sum_file_data_strict’ [-Wmissing-prototypes]
  341 | sum_file_data_strict(int fd, sum_t *dst)
      | ^~~~~~~~~~~~~~~~~~~~
tests/fssum.c:369:1: warning: no previous prototype for ‘escape’ [-Wmissing-prototypes]
  369 | escape(char *in)
      | ^~~~~~
tests/fssum.c:389:1: warning: no previous prototype for ‘excess_file’ [-Wmissing-prototypes]
  389 | excess_file(const char *fn)
      | ^~~~~~~~~~~
tests/fssum.c:395:1: warning: no previous prototype for ‘missing_file’ [-Wmissing-prototypes]
  395 | missing_file(const char *fn)
      | ^~~~~~~~~~~~
tests/fssum.c:401:1: warning: no previous prototype for ‘pathcmp’ [-Wmissing-prototypes]
  401 | pathcmp(const char *a, const char *b)
      | ^~~~~~~
tests/fssum.c:419:1: warning: no previous prototype for ‘check_match’ [-Wmissing-prototypes]
  419 | check_match(char *fn, char *local_m, char *remote_m,
      | ^~~~~~~~~~~
tests/fssum.c:438:1: warning: no previous prototype for ‘check_manifest’ [-Wmissing-prototypes]
  438 | check_manifest(char *fn, char *m, char *c, int last_call)
      | ^~~~~~~~~~~~~~
tests/fssum.c:509:1: warning: no previous prototype for ‘sum’ [-Wmissing-prototypes]
  509 | sum(int dirfd, int level, sum_t *dircs, char *path_prefix, char *path_in)
      | ^~~
    [LD]     fsstress
tests/fsstress.c:4363:1: warning: ‘do_mmap’ defined but not used [-Wunused-function]
 4363 | do_mmap(opnum_t opno, long r, int prot)
      | ^~~~~~~
tests/fsstress.c:3814:1: warning: ‘do_fallocate’ defined but not used [-Wunused-function]
 3814 | do_fallocate(opnum_t opno, long r, int mode)
      | ^~~~~~~~~~~~
tests/fsstress.c:1183:1: warning: ‘delete_subvol_children’ defined but not used [-Wunused-function]
 1183 | delete_subvol_children(int parid)
---
 tests/fssum.c | 46 +++++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)
tests/fssum.c +23 -23
index e35c027424cd..bca33c7714cd 100644
@@ -82,7 +82,7 @@ char line[65536];
 
 int flags[NUM_FLAGS] = {1, 1, 1, 1, 1, 0, 1, 1, 0, 0};
 
-char *
+static char *
 getln(char *buf, int size, FILE *fp)
 {
 	char *p;
@@ -99,7 +99,7 @@ getln(char *buf, int size, FILE *fp)
 	return p;
 }
 
-void
+static void
 parse_flag(int c)
 {
 	int i;
@@ -119,14 +119,14 @@ parse_flag(int c)
 	exit(-1);
 }
 
-void
+static void
 parse_flags(char *p)
 {
 	while (*p)
 		parse_flag(*p++);
 }
 
-void
+static void
 usage(void)
 {
 	fprintf(stderr, "usage: fssum <options> <path>\n");
@@ -159,7 +159,7 @@ usage(void)
 
 static char buf[65536];
 
-void *
+static void *
 alloc(size_t sz)
 {
 	void *p = malloc(sz);
@@ -172,44 +172,44 @@ alloc(size_t sz)
 	return p;
 }
 
-void
+static void
 sum_init(sum_t *cs)
 {
 	SHA256Reset(&cs->sha);
 }
 
-void
+static void
 sum_fini(sum_t *cs)
 {
 	SHA256Result(&cs->sha, cs->out);
 }
 
-void
+static void
 sum_add(sum_t *cs, void *buf, int size)
 {
 	SHA256Input(&cs->sha, buf, size);
 }
 
-void
+static void
 sum_add_sum(sum_t *dst, sum_t *src)
 {
 	sum_add(dst, src->out, sizeof(src->out));
 }
 
-void
+static void
 sum_add_u64(sum_t *dst, uint64_t val)
 {
 	uint64_t v = cpu_to_le64(val);
 	sum_add(dst, &v, sizeof(v));
 }
 
-void
+static void
 sum_add_time(sum_t *dst, time_t t)
 {
 	sum_add_u64(dst, t);
 }
 
-char *
+static char *
 sum_to_string(sum_t *dst)
 {
 	int i;
@@ -221,7 +221,7 @@ sum_to_string(sum_t *dst)
 	return s;
 }
 
-int
+static int
 namecmp(const void *aa, const void *bb)
 {
 	char * const *a = aa;
@@ -230,7 +230,7 @@ namecmp(const void *aa, const void *bb)
 	return strcmp(*a, *b);
 }
 
-int
+static int
 sum_xattrs(int fd, sum_t *dst)
 {
 	ssize_t buflen;
@@ -321,7 +321,7 @@ out:
 	return ret;
 }
 
-int
+static int
 sum_file_data_permissive(int fd, sum_t *dst)
 {
 	int ret;
@@ -337,7 +337,7 @@ sum_file_data_permissive(int fd, sum_t *dst)
 	return 0;
 }
 
-int
+static int
 sum_file_data_strict(int fd, sum_t *dst)
 {
 	int ret;
@@ -365,7 +365,7 @@ sum_file_data_strict(int fd, sum_t *dst)
 	}
 }
 
-char *
+static char *
 escape(char *in)
 {
 	char *out = alloc(strlen(in) * 3 + 1);
@@ -385,19 +385,19 @@ escape(char *in)
 	return out;
 }
 
-void
+static void
 excess_file(const char *fn)
 {
 	printf("only in local fs: %s\n", fn);
 }
 
-void
+static void
 missing_file(const char *fn)
 {
 	printf("only in remote fs: %s\n", fn);
 }
 
-int
+static int
 pathcmp(const char *a, const char *b)
 {
 	int len_a = strlen(a);
@@ -415,7 +415,7 @@ pathcmp(const char *a, const char *b)
 	return strcmp(a, b);
 }
 
-void
+static void
 check_match(char *fn, char *local_m, char *remote_m,
 	    char *local_c, char *remote_c)
 {
@@ -434,7 +434,7 @@ check_match(char *fn, char *local_m, char *remote_m,
 char *prev_fn;
 char *prev_m;
 char *prev_c;
-void
+static void
 check_manifest(char *fn, char *m, char *c, int last_call)
 {
 	char *rem_m;
@@ -505,7 +505,7 @@ malformed:
 		excess_file(fn);
 }
 
-void
+static void
 sum(int dirfd, int level, sum_t *dircs, char *path_prefix, char *path_in)
 {
 	DIR *d;
Signature · 1 line
2.39.2
author
#2 lore raw

PATCH 2/4 btrfs-progs: tests/fsstress.c: move do_mmap under HAVE_SYS_MMAN_H

In reply to Anand Jain

Move the entire 'do_mmap' function under the 'HAVE_SYS_MMAN_H' define and fix the following warnings. This function is called only when 'HAVE_SYS_MMAN_H' is defined.

tests/fsstress.c:4363:1: warning: ‘do_mmap’ defined but not used [-Wunused-function]
4363 | do_mmap(opnum_t opno, long r, int prot)

---
 tests/fsstress.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/fsstress.c +2 -2
index f7d3a83a4e2e..692d7cfacaf4 100644
@@ -4359,10 +4359,10 @@ struct print_flags mmap_flags[] = {
 	({translate_flags(flags, "|", mmap_flags);})
 #endif
 
+#ifdef HAVE_SYS_MMAN_H
 static void
 do_mmap(opnum_t opno, long r, int prot)
 {
-#ifdef HAVE_SYS_MMAN_H
 	char		*addr;
 	int		e;
 	pathname_t	f;
@@ -4454,8 +4454,8 @@ do_mmap(opnum_t opno, long r, int prot)
 
 	free_pathname(&f);
 	close(fd);
-#endif
 }
+#endif
 
 void
 mread_f(opnum_t opno, long r)
Signature · 1 line
2.39.2
author
#3 lore raw

PATCH 3/4 btrfs-progs: tests/fsstress.c: move do_fallocate under HAVE_LINUX_FALLOC_H

In reply to Anand Jain

Move the entire 'do_fallocate' function under the 'HAVE_LINUX_FALLOC_H' define and fix the following warnings. This function is called only when 'HAVE_LINUX_FALLOC_H' is defined.

tests/fsstress.c:3814:1: warning: ‘do_fallocate’ defined but not used [-Wunused-function]
3814 | do_fallocate(opnum_t opno, long r, int mode)

---
 tests/fsstress.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/fsstress.c +2 -2
index 692d7cfacaf4..5fd347ccf1d4 100644
@@ -3810,10 +3810,10 @@ struct print_flags falloc_flags [] = {
 	({translate_flags(mode, "|", falloc_flags);})
 #endif
 
+#ifdef HAVE_LINUX_FALLOC_H
 static void
 do_fallocate(opnum_t opno, long r, int mode)
 {
-#ifdef HAVE_LINUX_FALLOC_H
 	int		e;
 	pathname_t	f;
 	int		fd;
@@ -3870,8 +3870,8 @@ do_fallocate(opnum_t opno, long r, int mode)
 		       f.path, st, (long long)off, (long long)len, e);
 	free_pathname(&f);
 	close(fd);
-#endif
 }
+#endif
 
 void
 fallocate_f(opnum_t opno, long r)
Signature · 1 line
2.39.2
author
#4 lore raw

PATCH 4/4 btrfs-progs: tests/fsstress.c: move delete_subvol_children under HAVE_BTRFSUTIL_H

In reply to Anand Jain

Bring the 'delete_subvol_children' function under the HAVE_BTRFSUTIL_H define and fix the following warnings. This function is called only when 'HAVE_BTRFSUTILS_H' is defined.

tests/fsstress.c:1183:1: warning: ‘delete_subvol_children’ defined but not used [-Wunused-function]
1183 | delete_subvol_children(int parid

---
 tests/fsstress.c | 2 ++
 1 file changed, 2 insertions(+)
tests/fsstress.c +2 -0
index 5fd347ccf1d4..3b8cde847aa1 100644
@@ -1179,6 +1179,7 @@ del_from_flist(int ft, int slot)
 		ftp->nfiles--;
 }
 
+#ifdef HAVE_BTRFSUTIL_H
 static void
 delete_subvol_children(int parid)
 {
@@ -1198,6 +1199,7 @@ again:
 		}
 	}
 }
+#endif
 
 static fent_t *
 dirid_to_fent(int dirid)
Signature · 1 line
2.39.2
#5 lore raw
In reply to Anand Jain
Quoted 7 lines · Anand Jain

This set of patches addresses the warnings when running the following commands:

  $ rm fssum fsstress
  $ make test

Ensure cleaner test suite for btrfs-progs.

Quoted 7 lines

Anand Jain (4):
btrfs-progs: tests/fssum.c: fix missing prototype warning
btrfs-progs: tests/fsstress.c: move do_mmap under HAVE_SYS_MMAN_H
btrfs-progs: tests/fsstress.c: move do_fallocate under
HAVE_LINUX_FALLOC_H
btrfs-progs: tests/fsstress.c: move delete_subvol_children under
HAVE_BTRFSUTIL_H

Added to devel, thanks.