All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] mtd-utils: various cleanups, enable compiler warnings
@ 2017-06-28 11:08 David Oberhollenzer
  2017-06-28 11:08 ` [PATCH 1/9] Replace defunct ubifs_assert David Oberhollenzer
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: David Oberhollenzer @ 2017-06-28 11:08 UTC (permalink / raw)
  To: linux-mtd

Hello,


this patch series contains a number of cleanups for mtd-utils.

Apart from some minor cleanups, the first larger change in the series is
a restructuring of the dependency handling in the autoconf.ac file. The
main idea is to always have the configure script finish and _then_ print
a list of _all_ missing libraries for the current build configuration
instead of having to go back and forth between installing libraries/
changing external build scrips and rebuilding just to see what else is
missing.

The second larger change deals with compiler warnings. A number of
compiler warning flags are set if the compiler supports them. An m4
script has been borrowed from coreutils (via util-linux) to check if
the compiler supports a specific warning flag.

The rest of the patch set attempts to deal with the resulting fallout.

For now, -Wshadow and -Wsign-compare are explicitly disabled. Dealing
with those would require a number of non-trivial code changes that
should probably be handled as a separate patch set.


David

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

* [PATCH 1/9] Replace defunct ubifs_assert
  2017-06-28 11:08 [PATCH 0/9] mtd-utils: various cleanups, enable compiler warnings David Oberhollenzer
@ 2017-06-28 11:08 ` David Oberhollenzer
  2017-06-28 11:08 ` [PATCH 2/9] Restructure autoconf configure.ac David Oberhollenzer
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: David Oberhollenzer @ 2017-06-28 11:08 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Oberhollenzer

The ubifs assert defined in defs.h was only used in three places
inside key.h and defined to never perform any checks at all.

This patch replaces ubifs_assert in mkfs.ubifs with the regular
libc assert macro.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
---
 ubifs-utils/mkfs.ubifs/defs.h | 2 --
 ubifs-utils/mkfs.ubifs/key.h  | 8 +++++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/ubifs-utils/mkfs.ubifs/defs.h b/ubifs-utils/mkfs.ubifs/defs.h
index 1fa3316..8db5277 100644
--- a/ubifs-utils/mkfs.ubifs/defs.h
+++ b/ubifs-utils/mkfs.ubifs/defs.h
@@ -31,8 +31,6 @@
 
 #define unlikely(x) (x)
 
-#define ubifs_assert(x) ({})
-
 struct qstr
 {
 	char *name;
diff --git a/ubifs-utils/mkfs.ubifs/key.h b/ubifs-utils/mkfs.ubifs/key.h
index 118858b..cd4b849 100644
--- a/ubifs-utils/mkfs.ubifs/key.h
+++ b/ubifs-utils/mkfs.ubifs/key.h
@@ -37,6 +37,8 @@
 #ifndef __UBIFS_KEY_H__
 #define __UBIFS_KEY_H__
 
+#include <assert.h>
+
 /**
  * key_mask_hash - mask a valid hash value.
  * @val: value to be masked
@@ -113,7 +115,7 @@ static inline void dent_key_init(const struct ubifs_info *c,
 {
 	uint32_t hash = c->key_hash(nm->name, nm->len);
 
-	ubifs_assert(!(hash & ~UBIFS_S_KEY_HASH_MASK));
+	assert(!(hash & ~UBIFS_S_KEY_HASH_MASK));
 	key->u32[0] = inum;
 	key->u32[1] = hash | (UBIFS_DENT_KEY << UBIFS_S_KEY_HASH_BITS);
 }
@@ -131,7 +133,7 @@ static inline void xent_key_init(const struct ubifs_info *c,
 {
 	uint32_t hash = c->key_hash(nm->name, nm->len);
 
-	ubifs_assert(!(hash & ~UBIFS_S_KEY_HASH_MASK));
+	assert(!(hash & ~UBIFS_S_KEY_HASH_MASK));
 	key->u32[0] = inum;
 	key->u32[1] = hash | (UBIFS_XENT_KEY << UBIFS_S_KEY_HASH_BITS);
 }
@@ -146,7 +148,7 @@ static inline void xent_key_init(const struct ubifs_info *c,
 static inline void data_key_init(union ubifs_key *key, ino_t inum,
 				 unsigned int block)
 {
-	ubifs_assert(!(block & ~UBIFS_S_KEY_BLOCK_MASK));
+	assert(!(block & ~UBIFS_S_KEY_BLOCK_MASK));
 	key->u32[0] = inum;
 	key->u32[1] = block | (UBIFS_DATA_KEY << UBIFS_S_KEY_BLOCK_BITS);
 }
-- 
2.12.3

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

* [PATCH 2/9] Restructure autoconf configure.ac
  2017-06-28 11:08 [PATCH 0/9] mtd-utils: various cleanups, enable compiler warnings David Oberhollenzer
  2017-06-28 11:08 ` [PATCH 1/9] Replace defunct ubifs_assert David Oberhollenzer
@ 2017-06-28 11:08 ` David Oberhollenzer
  2017-06-28 11:08 ` [PATCH 3/9] Use autoconf header detection correctly for libmissing David Oberhollenzer
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: David Oberhollenzer @ 2017-06-28 11:08 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Oberhollenzer

This patch attempts to cleanly seperate configure switches,
dependency checking and generating of output files inside
the autoconf configure.ac file.

Also, instead of aborting immediately if a dependency is missing,
the configure script now completes dependency checking and then
lists ALL dependencies that are missing for the selected build
options. In addition, suggestions on how to disable some features
that require the missing dependencies are printed out.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
---
 configure.ac | 180 +++++++++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 132 insertions(+), 48 deletions(-)

diff --git a/configure.ac b/configure.ac
index fbef15c..aedbb32 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,8 +4,6 @@ m4_define([RELEASE], 2.0.0)
 
 AC_INIT([mtd-utils], [RELEASE], [linux-mtd@lists.infradead.org], mtd-utils)
 
-AC_CONFIG_HEADERS([include/config.h])
-
 AC_ARG_ENABLE([unit-tests],
 	[AS_HELP_STRING([--enable-unit-tests], [Compile unit test programs])],
 	[case "${enableval}" in
@@ -26,9 +24,21 @@ AC_DISABLE_STATIC
 AC_PROG_CC
 AC_PROG_INSTALL
 
+###### handle configure switches, select dependencies ######
+
+need_clock_gettime="no"
+need_pthread="no"
+need_uuid="no"
+need_zlib="no"
+need_lzo="no"
+need_xattr="no"
+need_cmocka="no"
+
+
+AM_COND_IF([UNIT_TESTS], [
+	need_cmocka="yes"
+])
 
-AC_SEARCH_LIBS([clock_gettime],[rt posix4])
-AC_CHECK_FUNCS([clock_gettime])
 
 AC_ARG_ENABLE([tests],
 	[AS_HELP_STRING([--disable-tests], [Compile test programs])],
@@ -39,8 +49,10 @@ AC_ARG_ENABLE([tests],
 	esac],
 	[AM_CONDITIONAL([BUILD_TESTS], [true])])
 
-AM_COND_IF([BUILD_TESTS],
-	[AX_PTHREAD([], [AC_MSG_ERROR([pthread missing])])])
+AM_COND_IF([BUILD_TESTS], [
+	need_clock_gettime="yes"
+	need_pthread="yes"
+])
 
 
 AC_ARG_ENABLE([install-tests],
@@ -58,18 +70,6 @@ AM_COND_IF([INSTALL_TESTS],
 	[AC_SUBST(testbindir, ["\".\""])])
 
 
-AC_CONFIG_FILES([tests/fs-tests/fs_help_all.sh
-	tests/fs-tests/fs_run_all.sh
-	tests/fs-tests/stress/fs_stress00.sh
-	tests/fs-tests/stress/fs_stress01.sh
-	tests/ubi-tests/runubitests.sh
-	tests/ubi-tests/ubi-stress-test.sh])
-
-
-need_uuid="no"
-need_zlib="no"
-need_lzo="no"
-
 AC_ARG_WITH([jffs],
 	[AS_HELP_STRING([--without-jffs], [Disable jffsX utilities])],
 	[case "${withval}" in
@@ -90,67 +90,151 @@ AC_ARG_WITH([ubifs],
 
 AM_COND_IF([BUILD_UBIFS], [
 	need_uuid="yes"
+	need_xattr="yes"
 	need_zlib="yes"
 	need_lzo="yes"
 ])
 
 AM_COND_IF([BUILD_JFFSX], [
+	need_xattr="yes"
 	need_zlib="yes"
 	need_lzo="yes"
 ])
 
-if test "x$need_zlib" = "xyes"; then
-	PKG_CHECK_MODULES(ZLIB, [zlib])
-fi
-
-if test "x$need_uuid" = "xyes"; then
-	PKG_CHECK_MODULES(UUID, [uuid])
-fi
-
-
 AC_ARG_WITH([xattr],
 	[AS_HELP_STRING([--without-xattr],
 		[Disable support forextended file attributes])],
 	[case "${withval}" in
-	yes) AM_CONDITIONAL([WITHOUT_XATTR], [false]) ;;
-	no)  AM_CONDITIONAL([WITHOUT_XATTR], [true]) ;;
+	yes) ;;
+	no) need_xattr="no" ;;
 	*) AC_MSG_ERROR([bad value ${withval} for --without-xattr]) ;;
-	esac],
-	[AM_CONDITIONAL([WITHOUT_XATTR], [false])])
-
-AC_CHECK_HEADER(sys/xattr.h, [], [AM_CONDITIONAL([WITHOUT_XATTR], [true])])
-AC_CHECK_HEADER(sys/acl.h, [], [AM_CONDITIONAL([WITHOUT_XATTR], [true])])
-
+	esac])
 
 AC_ARG_WITH([lzo],
 	[AS_HELP_STRING([--without-lzo], [Disable support for LZO compression])],
 	[case "${withval}" in
-	yes) AM_CONDITIONAL([WITHOUT_LZO], [test "x$need_lzo" != "xyes"]) ;;
-	no)  AM_CONDITIONAL([WITHOUT_LZO], [true]) ;;
+	yes) ;;
+	no) need_lzo="no" ;;
 	*) AC_MSG_ERROR([bad value ${withval} for --without-lzo]) ;;
-	esac],
-	[AM_CONDITIONAL([WITHOUT_LZO], [test "x$need_lzo" != "xyes"])])
+	esac])
 
+##### search for dependencies #####
 
-AC_CHECK_HEADERS([execinfo.h], [execinfo_found=yes])
-AM_CONDITIONAL([HAVE_EXECINFO], [test "x$execinfo_found" == "xyes"])
+clock_gettime_missing="no"
+pthread_missing="no"
+uuid_missing="no"
+zlib_missing="no"
+lzo_missing="no"
+xattr_missing="no"
+cmocka_missing="no"
+
+if test "x$need_zlib" = "xyes"; then
+	PKG_CHECK_MODULES(ZLIB, [zlib], [], [zlib_missing="yes"])
+fi
 
-AM_COND_IF([UNIT_TESTS], [PKG_CHECK_MODULES(CMOCKA, [ cmocka ])], [])
+if test "x$need_uuid" = "xyes"; then
+	PKG_CHECK_MODULES(UUID, [uuid], [], [uuid_missing="yes"])
+fi
+
+if test "x$need_clock_gettime" = "xyes"; then
+	AC_SEARCH_LIBS([clock_gettime], [rt posix4])
+	AC_CHECK_FUNCS([clock_gettime], [], [clock_gettime_missing="yes"])
+fi
 
-AM_COND_IF([WITHOUT_LZO], [], [
-	have_lzo="yes"
+if test "x$need_pthread" = "xyes"; then
+	AX_PTHREAD([], [pthread_missing="yes"])
+fi
+
+if test "x$need_lzo" = "xyes"; then
 	AC_ARG_VAR([LZO_CFLAGS], [C compiler flags for lzo])
 	AC_ARG_VAR([LZO_LIBS], [linker flags for lzo])
 	AC_CHECK_LIB([lzo2], [lzo1x_1_15_compress], [LZO_LIBS="-llzo2"],
 		[AC_CHECK_LIB([lzo],[lzo1x_1_15_compress],[LZO_LIBS="-llzo"],
-			[have_lzo="no"]
+			[lzo_missing="yes"]
 		)]
 	)
-	test "${have_lzo}" != "yes" && AC_MSG_ERROR([lzo missing])
-])
+fi
 
-AC_CHECK_SIZEOF([off_t])
+if test "x$need_xattr" = "xyes"; then
+	AC_CHECK_HEADERS([sys/xattr.h], [], [xattr_missing="yes"])
+	AC_CHECK_HEADERS([sys/acl.h], [], [xattr_missing="yes"])
+fi
+
+if test "x$need_cmocka" = "xyes"; then
+	PKG_CHECK_MODULES(CMOCKA, [cmocka], [], [cmocka_missing="yes"])
+fi
+
+AC_CHECK_HEADERS([execinfo.h], [execinfo_found=yes])
+
+##### produce summary on dependencies #####
 
+dep_missing="no"
+
+if test "x$clock_gettime_missing" = "xyes"; then
+	AC_MSG_WARN([cannot find clock_gettime function required for MTD tests])
+	AC_MSG_NOTICE([building test programs can optionally be dissabled])
+	dep_missing="yes"
+fi
+
+if test "x$pthread_missing" = "xyes"; then
+	AC_MSG_WARN([cannot find pthread support required for test programs])
+	AC_MSG_NOTICE([building test programs can optionally be dissabled])
+	dep_missing="yes"
+fi
+
+if test "x$uuid_missing" = "xyes"; then
+	AC_MSG_WARN([cannot find uuid library required for mkfs.ubifs])
+	AC_MSG_NOTICE([mtd-utils can optionally be built without mkfs.ubifs])
+	dep_missing="yes"
+fi
+
+if test "x$zlib_missing" = "xyes"; then
+	AC_MSG_WARN([cannot find ZLIB library required for mkfs programs])
+	AC_MSG_NOTICE([mtd-utils can optionally be built without mkfs.ubifs])
+	AC_MSG_NOTICE([mtd-utils can optionally be built without mkfs.jffs2])
+	dep_missing="yes"
+fi
+
+if test "x$lzo_missing" = "xyes"; then
+	AC_MSG_WARN([cannot find LZO library required for mkfs programs])
+	AC_MSG_NOTICE([mtd-utils can optionally be built without mkfs.ubifs])
+	AC_MSG_NOTICE([mtd-utils can optionally be built without mkfs.jffs2])
+	AC_MSG_NOTICE([mtd-utils can optionally be built without LZO support])
+	dep_missing="yes"
+fi
+
+if test "x$xattr_missing" = "xyes"; then
+	AC_MSG_WARN([cannot find headers for extended attributes])
+	AC_MSG_WARN([disabling XATTR support])
+	need_xattr="no"
+fi
+
+if test "x$cmocka_missing" = "xyes"; then
+	AC_MSG_WARN([cannot find CMocka library required for unit tests])
+	AC_MSG_NOTICE([unit tests can optionally be disabled])
+	dep_missing="yes"
+fi
+
+if test "x$dep_missing" = "xyes"; then
+	AC_MSG_ERROR([missing one or more dependencies])
+fi
+
+##### generate output #####
+
+AM_CONDITIONAL([WITHOUT_LZO], [test "x$need_lzo" != "xyes"])
+AM_CONDITIONAL([WITHOUT_XATTR], [test "x$need_xattr" != "xyes"])
+AM_CONDITIONAL([HAVE_EXECINFO], [test "x$execinfo_found" == "xyes"])
+
+AC_CHECK_SIZEOF([off_t])
 AC_CHECK_SIZEOF([loff_t])
 
+AC_CONFIG_HEADERS([include/config.h])
+
+AC_CONFIG_FILES([tests/fs-tests/fs_help_all.sh
+	tests/fs-tests/fs_run_all.sh
+	tests/fs-tests/stress/fs_stress00.sh
+	tests/fs-tests/stress/fs_stress01.sh
+	tests/ubi-tests/runubitests.sh
+	tests/ubi-tests/ubi-stress-test.sh])
+
 AC_OUTPUT([Makefile])
-- 
2.12.3

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

* [PATCH 3/9] Use autoconf header detection correctly for libmissing
  2017-06-28 11:08 [PATCH 0/9] mtd-utils: various cleanups, enable compiler warnings David Oberhollenzer
  2017-06-28 11:08 ` [PATCH 1/9] Replace defunct ubifs_assert David Oberhollenzer
  2017-06-28 11:08 ` [PATCH 2/9] Restructure autoconf configure.ac David Oberhollenzer
@ 2017-06-28 11:08 ` David Oberhollenzer
  2017-06-28 11:08 ` [PATCH 4/9] Move libfec declarations to public header in global include directory David Oberhollenzer
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: David Oberhollenzer @ 2017-06-28 11:08 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Oberhollenzer

AC_CHECK_HEADERS already makes sure our config header contains a
HAVE_$FOO_H macro if a header was found. There is no need to
awkwardly set our own Automake conditionals and check for it all
over the place in the Automake files.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
---
 Makefile.am                  | 4 ----
 configure.ac                 | 3 +--
 include/libmissing.h         | 6 ++++--
 lib/execinfo.c               | 4 ++--
 tests/fs-tests/Makemodule.am | 7 +------
 5 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 31b21bc..4c123f2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -10,10 +10,6 @@ if WITHOUT_LZO
 AM_CPPFLAGS += -DWITHOUT_LZO
 endif
 
-if HAVE_EXECINFO
-AM_CPPFLAGS += -DHAVE_EXECINFO
-endif
-
 sbin_PROGRAMS =
 sbin_SCRIPTS =
 noinst_LIBRARIES =
diff --git a/configure.ac b/configure.ac
index aedbb32..8db281d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -164,7 +164,7 @@ if test "x$need_cmocka" = "xyes"; then
 	PKG_CHECK_MODULES(CMOCKA, [cmocka], [], [cmocka_missing="yes"])
 fi
 
-AC_CHECK_HEADERS([execinfo.h], [execinfo_found=yes])
+AC_CHECK_HEADERS([execinfo.h])
 
 ##### produce summary on dependencies #####
 
@@ -223,7 +223,6 @@ fi
 
 AM_CONDITIONAL([WITHOUT_LZO], [test "x$need_lzo" != "xyes"])
 AM_CONDITIONAL([WITHOUT_XATTR], [test "x$need_xattr" != "xyes"])
-AM_CONDITIONAL([HAVE_EXECINFO], [test "x$execinfo_found" == "xyes"])
 
 AC_CHECK_SIZEOF([off_t])
 AC_CHECK_SIZEOF([loff_t])
diff --git a/include/libmissing.h b/include/libmissing.h
index c765f6d..0196033 100644
--- a/include/libmissing.h
+++ b/include/libmissing.h
@@ -1,11 +1,13 @@
 #ifndef LIBMISSING_H
 #define LIBMISSING_H
 
-#ifdef HAVE_EXECINFO
+#include "config.h"
+
+#ifdef HAVE_EXECINFO_H
 #include <execinfo.h>
 #endif
 
-#ifndef HAVE_EXECINFO
+#ifndef HAVE_EXECINFO_H
 int backtrace(void **buffer, int size);
 char **backtrace_symbols(void *const *buffer, int size);
 void backtrace_symbols_fd(void *const *buffer, int size, int fd);
diff --git a/lib/execinfo.c b/lib/execinfo.c
index a39df83..a59f6a9 100644
--- a/lib/execinfo.c
+++ b/lib/execinfo.c
@@ -1,6 +1,6 @@
 #include "libmissing.h"
 
-#ifndef HAVE_EXECINFO
+#ifndef HAVE_EXECINFO_H
 #define PROGRAM_NAME "libmissing"
 #include "common.h"
 
@@ -22,4 +22,4 @@ void backtrace_symbols_fd(void *const *buffer, int size, int fd)
 {
 	errmsg("backtrace_symbols_fd() is not implemented");
 }
-#endif /* !HAVE_EXECINFO */
+#endif /* !HAVE_EXECINFO_H */
diff --git a/tests/fs-tests/Makemodule.am b/tests/fs-tests/Makemodule.am
index d3acaa5..2eae860 100644
--- a/tests/fs-tests/Makemodule.am
+++ b/tests/fs-tests/Makemodule.am
@@ -1,12 +1,7 @@
 integck_SOURCES = tests/fs-tests/integrity/integck.c
-integck_LDADD = libubi.a
+integck_LDADD = libubi.a libmissing.a
 integck_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/ubi-utils/include
 
-if HAVE_EXECINFO
-else
-integck_LDADD += libmissing.a
-endif
-
 test_1_SOURCES = tests/fs-tests/simple/test_1.c tests/fs-tests/lib/tests.c
 test_1_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib
 
-- 
2.12.3

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

* [PATCH 4/9] Move libfec declarations to public header in global include directory
  2017-06-28 11:08 [PATCH 0/9] mtd-utils: various cleanups, enable compiler warnings David Oberhollenzer
                   ` (2 preceding siblings ...)
  2017-06-28 11:08 ` [PATCH 3/9] Use autoconf header detection correctly for libmissing David Oberhollenzer
@ 2017-06-28 11:08 ` David Oberhollenzer
  2017-06-28 11:08 ` [PATCH 5/9] Enable compiler warnings David Oberhollenzer
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: David Oberhollenzer @ 2017-06-28 11:08 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Oberhollenzer

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
---
 include/libfec.h         | 37 +++++++++++++++++++++++++++++++++++++
 lib/libfec.c             |  1 +
 misc-utils/fectest.c     |  1 +
 misc-utils/mcast_image.h | 32 --------------------------------
 misc-utils/recv_image.c  |  1 +
 misc-utils/serve_image.c |  1 +
 6 files changed, 41 insertions(+), 32 deletions(-)
 create mode 100644 include/libfec.h

diff --git a/include/libfec.h b/include/libfec.h
new file mode 100644
index 0000000..356ac28
--- /dev/null
+++ b/include/libfec.h
@@ -0,0 +1,37 @@
+#ifndef LIBFEC_H
+#define LIBFEC_H
+
+struct fec_parms;
+
+/* k - number of actual data packets
+ * n - total number of packets including data and redundant packets
+ *   (actual packet size isn't relevant here) */
+struct fec_parms *fec_new(int k, int n);
+void fec_free(struct fec_parms *p);
+
+/* src   - array of (n) pointers to data packets
+ * fec   - buffer for packet to be generated
+ * index - index of packet to be generated (0 <= index < n)
+ * sz    - data packet size
+ *
+ * _linear version just takes a pointer to the raw data; no
+ * mucking about with packet pointers.
+ */
+void fec_encode(struct fec_parms *code, unsigned char *src[],
+		unsigned char *fec, int index, int sz);
+void fec_encode_linear(struct fec_parms *code, unsigned char *src,
+		       unsigned char *fec, int index, int sz);
+
+/* data  - array of (k) pointers to data packets, in arbitrary order (see i)
+ * i     - indices of (data) packets
+ * sz    - data packet size
+ *
+ * Will never fail as long as you give it (k) individual data packets.
+ * Will re-order the (data) pointers but not the indices -- data packets
+ * are ordered on return.
+ */
+int fec_decode(struct fec_parms *code, unsigned char *data[],
+	       int i[], int sz);
+
+#endif /* LIBFEC_H */
+
diff --git a/lib/libfec.c b/lib/libfec.c
index bf68381..0d8056a 100644
--- a/lib/libfec.c
+++ b/lib/libfec.c
@@ -45,6 +45,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include "libfec.h"
 
 /*
  * stuff used for testing purposes only
diff --git a/misc-utils/fectest.c b/misc-utils/fectest.c
index fd577f3..fcba513 100644
--- a/misc-utils/fectest.c
+++ b/misc-utils/fectest.c
@@ -8,6 +8,7 @@
 #include <sys/stat.h>
 
 #include "mcast_image.h"
+#include "libfec.h"
 #include <crc32.h>
 
 #define ERASE_SIZE 131072
diff --git a/misc-utils/mcast_image.h b/misc-utils/mcast_image.h
index 8e94ffa..5264659 100644
--- a/misc-utils/mcast_image.h
+++ b/misc-utils/mcast_image.h
@@ -20,35 +20,3 @@ struct image_pkt {
 	struct image_pkt_hdr hdr;
 	unsigned char data[PKT_SIZE];
 };
-
-struct fec_parms;
-
-/* k - number of actual data packets
- * n - total number of packets including data and redundant packets
- *   (actual packet size isn't relevant here) */
-struct fec_parms *fec_new(int k, int n);
-void fec_free(struct fec_parms *p);
-
-/* src   - array of (n) pointers to data packets
- * fec   - buffer for packet to be generated
- * index - index of packet to be generated (0 <= index < n)
- * sz    - data packet size
- *
- * _linear version just takes a pointer to the raw data; no
- * mucking about with packet pointers.
- */
-void fec_encode(struct fec_parms *code, unsigned char *src[],
-		unsigned char *fec, int index, int sz);
-void fec_encode_linear(struct fec_parms *code, unsigned char *src,
-		       unsigned char *fec, int index, int sz);
-
-/* data  - array of (k) pointers to data packets, in arbitrary order (see i)
- * i     - indices of (data) packets
- * sz    - data packet size
- *
- * Will never fail as long as you give it (k) individual data packets.
- * Will re-order the (data) pointers but not the indices -- data packets
- * are ordered on return.
- */
-int fec_decode(struct fec_parms *code, unsigned char *data[],
-	       int i[], int sz);
diff --git a/misc-utils/recv_image.c b/misc-utils/recv_image.c
index 8bd7356..7f6662b 100644
--- a/misc-utils/recv_image.c
+++ b/misc-utils/recv_image.c
@@ -20,6 +20,7 @@
 #include <crc32.h>
 #include "mtd/mtd-user.h"
 #include "mcast_image.h"
+#include "libfec.h"
 
 #include "common.h"
 
diff --git a/misc-utils/serve_image.c b/misc-utils/serve_image.c
index 26632e3..f2475d6 100644
--- a/misc-utils/serve_image.c
+++ b/misc-utils/serve_image.c
@@ -21,6 +21,7 @@
 #include <common.h>
 
 #include "mcast_image.h"
+#include "libfec.h"
 
 int tx_rate = 80000;
 int pkt_delay;
-- 
2.12.3

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

* [PATCH 5/9] Enable compiler warnings
  2017-06-28 11:08 [PATCH 0/9] mtd-utils: various cleanups, enable compiler warnings David Oberhollenzer
                   ` (3 preceding siblings ...)
  2017-06-28 11:08 ` [PATCH 4/9] Move libfec declarations to public header in global include directory David Oberhollenzer
@ 2017-06-28 11:08 ` David Oberhollenzer
  2017-06-28 11:08 ` [PATCH 6/9] Eliminate warnings about missing prototypes David Oberhollenzer
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: David Oberhollenzer @ 2017-06-28 11:08 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Oberhollenzer

This patch borrows the compiler.m4 script from util-linux to check
for compiler support of a number of warning flags and sets them if
they are supported.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
---
 Makefile.am    |  2 +-
 configure.ac   | 22 ++++++++++++++++++++++
 m4/compiler.m4 | 40 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 63 insertions(+), 1 deletion(-)
 create mode 100644 m4/compiler.m4

diff --git a/Makefile.am b/Makefile.am
index 4c123f2..e9c1608 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
 ACLOCAL_AMFLAGS = -I m4
 
-AM_CPPFLAGS = -D_GNU_SOURCE -I$(top_srcdir)/include
+AM_CPPFLAGS = $(WARN_CFLAGS) -D_GNU_SOURCE -std=gnu99 -I$(top_srcdir)/include
 
 if WITHOUT_XATTR
 AM_CPPFLAGS += -DWITHOUT_XATTR
diff --git a/configure.ac b/configure.ac
index 8db281d..c1cf1d1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,6 +24,28 @@ AC_DISABLE_STATIC
 AC_PROG_CC
 AC_PROG_INSTALL
 
+## compiler warnings
+UL_WARN_ADD([-Wall])
+UL_WARN_ADD([-Wextra])
+UL_WARN_ADD([-Wunused])
+UL_WARN_ADD([-Wmissing-prototypes])
+UL_WARN_ADD([-Wmissing-declarations])
+UL_WARN_ADD([-Wwrite-strings])
+UL_WARN_ADD([-Wjump-misses-init])
+UL_WARN_ADD([-Wuninitialized])
+UL_WARN_ADD([-Winit-self])
+UL_WARN_ADD([-Wlogical-op])
+UL_WARN_ADD([-Wunused-but-set-parameter])
+UL_WARN_ADD([-Wunused-but-set-variable])
+UL_WARN_ADD([-Wunused-parameter])
+UL_WARN_ADD([-Wunused-result])
+UL_WARN_ADD([-Wunused-variable])
+
+UL_WARN_ADD([-Wno-shadow])
+UL_WARN_ADD([-Wno-sign-compare])
+
+AC_SUBST([WARN_CFLAGS])
+
 ###### handle configure switches, select dependencies ######
 
 need_clock_gettime="no"
diff --git a/m4/compiler.m4 b/m4/compiler.m4
new file mode 100644
index 0000000..058c73f
--- /dev/null
+++ b/m4/compiler.m4
@@ -0,0 +1,40 @@
+dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Simon Josefsson
+dnl -- derivated from coreutils m4/warnings.m4
+
+# UL_AS_VAR_APPEND(VAR, VALUE)
+# ----------------------------
+# Provide the functionality of AS_VAR_APPEND if Autoconf does not have it.
+m4_ifdef([AS_VAR_APPEND],
+[m4_copy([AS_VAR_APPEND], [UL_AS_VAR_APPEND])],
+[m4_define([UL_AS_VAR_APPEND],
+[AS_VAR_SET([$1], [AS_VAR_GET([$1])$2])])])
+
+# UL_ADD_WARN(COMPILER_OPTION [, VARNAME])
+# ------------------------
+# Adds parameter to WARN_CFLAGS (or to $VARNAME) if the compiler supports it.
+AC_DEFUN([UL_WARN_ADD], [
+  m4_define([warnvarname], m4_default([$2],WARN_CFLAGS))
+  AS_VAR_PUSHDEF([ul_Warn], [ul_cv_warn_$1])dnl
+  AC_CACHE_CHECK([whether compiler handles $1], m4_defn([ul_Warn]), [
+    # store AC_LANG_WERROR status, then turn it on
+    save_ac_[]_AC_LANG_ABBREV[]_werror_flag="${ac_[]_AC_LANG_ABBREV[]_werror_flag}"
+    AC_LANG_WERROR
+
+    ul_save_CPPFLAGS="$CPPFLAGS"
+    CPPFLAGS="-Werror ${CPPFLAGS} $1"
+    AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])],
+                      [AS_VAR_SET(ul_Warn, [yes])],
+                      [AS_VAR_SET(ul_Warn, [no])])
+    # restore AC_LANG_WERROR
+    ac_[]_AC_LANG_ABBREV[]_werror_flag="${save_ac_[]_AC_LANG_ABBREV[]_werror_flag}"
+
+    CPPFLAGS="$ul_save_CPPFLAGS"
+  ])
+  AS_VAR_IF(ul_Warn, [yes], [UL_AS_VAR_APPEND(warnvarname, [" $1"])])
+])
+
-- 
2.12.3

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

* [PATCH 6/9] Eliminate warnings about missing prototypes
  2017-06-28 11:08 [PATCH 0/9] mtd-utils: various cleanups, enable compiler warnings David Oberhollenzer
                   ` (4 preceding siblings ...)
  2017-06-28 11:08 ` [PATCH 5/9] Enable compiler warnings David Oberhollenzer
@ 2017-06-28 11:08 ` David Oberhollenzer
  2017-06-28 11:08 ` [PATCH 7/9] Remove unused variables and functions David Oberhollenzer
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: David Oberhollenzer @ 2017-06-28 11:08 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Oberhollenzer

This patch eliminates warnings generated by the -Wmissing-prototypes
option. With this flag set, we are now forced to have prototypes for
all global, exported functions, that have to be made visible to the
definitions and we are forced to mark all local functions as static.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
---
 jffsX-utils/jffs2dump.c                  | 10 +++---
 jffsX-utils/jffs2reader.c                | 56 ++++++++++++--------------------
 jffsX-utils/mkfs.jffs2.c                 | 10 +++---
 jffsX-utils/sumtool.c                    | 40 +++++++++++------------
 lib/libcrc32.c                           |  1 +
 lib/libfec.c                             |  2 +-
 lib/libmtd.c                             |  6 ++--
 misc-utils/docfdisk.c                    |  2 +-
 misc-utils/flash_otp_write.c             |  2 +-
 misc-utils/ftl_check.c                   |  2 +-
 misc-utils/mtd_debug.c                   | 13 ++++----
 nand-utils/nandtest.c                    |  8 +++--
 nand-utils/nftl_format.c                 |  2 +-
 nor-utils/rfddump.c                      |  8 ++---
 nor-utils/rfdformat.c                    |  6 ++--
 tests/checkfs/checkfs.c                  | 14 ++++----
 tests/checkfs/makefiles.c                |  4 +--
 tests/fs-tests/integrity/integck.c       |  2 +-
 tests/fs-tests/lib/tests.c               |  4 +--
 tests/fs-tests/simple/ftrunc.c           |  6 ++--
 tests/fs-tests/simple/orph.c             |  6 ++--
 tests/fs-tests/simple/perf.c             |  6 ++--
 tests/fs-tests/simple/test_1.c           |  6 ++--
 tests/fs-tests/simple/test_2.c           |  6 ++--
 tests/fs-tests/stress/atoms/fwrite00.c   |  6 ++--
 tests/fs-tests/stress/atoms/gcd_hupper.c | 16 ++++-----
 tests/fs-tests/stress/atoms/pdfrun.c     |  8 ++---
 tests/fs-tests/stress/atoms/rmdir00.c    |  6 ++--
 tests/fs-tests/stress/atoms/rndrm00.c    |  6 ++--
 tests/fs-tests/stress/atoms/rndrm99.c    | 20 ++++++------
 tests/fs-tests/stress/atoms/rndwrite00.c |  6 ++--
 tests/fs-tests/stress/atoms/stress_1.c   |  6 ++--
 tests/fs-tests/stress/atoms/stress_2.c   |  6 ++--
 tests/fs-tests/stress/atoms/stress_3.c   |  6 ++--
 tests/fs-tests/utils/fstest_monitor.c    | 14 ++++----
 tests/jittertest/JitterTest.c            |  4 +--
 tests/jittertest/plotJittervsFill.c      |  4 +--
 37 files changed, 159 insertions(+), 171 deletions(-)

diff --git a/jffsX-utils/jffs2dump.c b/jffsX-utils/jffs2dump.c
index a7d99e8..ad7a9e3 100644
--- a/jffsX-utils/jffs2dump.c
+++ b/jffsX-utils/jffs2dump.c
@@ -50,7 +50,7 @@
 long	imglen;		// length of image
 char	*data;		// image data
 
-void display_help (int error)
+static void display_help (int error)
 {
 	printf("Usage: %s [OPTION]... INPUTFILE\n"
 	       "Dump the contents of a binary JFFS2 image.\n\n"
@@ -68,7 +68,7 @@ void display_help (int error)
 	exit(error ? EXIT_FAILURE : EXIT_SUCCESS);
 }
 
-void display_version (void)
+static void display_version (void)
 {
 	common_print_version();
 	printf("Copyright (C) 2003 Thomas Gleixner \n"
@@ -95,7 +95,7 @@ char	cnvfile[256];		// filename for conversion output
 int	datsize;		// Size of data chunks, when oob data is inside the binary image
 int	oobsize;		// Size of oob chunks, when oob data is inside the binary image
 
-void process_options (int argc, char *argv[])
+static void process_options (int argc, char *argv[])
 {
 	int error = 0;
 
@@ -170,7 +170,7 @@ void process_options (int argc, char *argv[])
 /*
  *	Dump image contents
  */
-void do_dumpcontent (void)
+static void do_dumpcontent (void)
 {
 	char			*p = data, *p_free_begin;
 	union jffs2_node_union 	*node;
@@ -479,7 +479,7 @@ void do_dumpcontent (void)
 /*
  *	Convert endianess
  */
-void do_endianconvert (void)
+static void do_endianconvert (void)
 {
 	char			*p = data;
 	union jffs2_node_union 	*node, newnode;
diff --git a/jffsX-utils/jffs2reader.c b/jffsX-utils/jffs2reader.c
index 16870ba..083500e 100644
--- a/jffsX-utils/jffs2reader.c
+++ b/jffsX-utils/jffs2reader.c
@@ -106,27 +106,9 @@ struct dir {
 
 int target_endian = __BYTE_ORDER;
 
-void putblock(char *, size_t, size_t *, struct jffs2_raw_inode *);
-struct dir *putdir(struct dir *, struct jffs2_raw_dirent *);
-void printdir(char *o, size_t size, struct dir *d, const char *path,
-		int recurse, int want_ctime);
-void freedir(struct dir *);
+static struct jffs2_raw_inode *find_raw_inode(char *, size_t, uint32_t);
 
-struct jffs2_raw_inode *find_raw_inode(char *o, size_t size, uint32_t ino);
-struct jffs2_raw_dirent *resolvedirent(char *, size_t, uint32_t, uint32_t,
-		char *, uint8_t);
-struct jffs2_raw_dirent *resolvename(char *, size_t, uint32_t, char *, uint8_t);
-struct jffs2_raw_dirent *resolveinode(char *, size_t, uint32_t);
-
-struct jffs2_raw_dirent *resolvepath0(char *, size_t, uint32_t, const char *,
-		uint32_t *, int);
-struct jffs2_raw_dirent *resolvepath(char *, size_t, uint32_t, const char *,
-		uint32_t *);
-
-void lsdir(char *, size_t, const char *, int, int);
-void catfile(char *, size_t, char *, char *, size_t, size_t *);
-
-int main(int, char **);
+static void lsdir(char *, size_t, const char *, int, int);
 
 /* writes file node into buffer, to the proper position. */
 /* reading all valid nodes in version order reconstructs the file. */
@@ -138,7 +120,7 @@ int main(int, char **);
    n       - node
  */
 
-void putblock(char *b, size_t bsize, size_t * rsize,
+static void putblock(char *b, size_t bsize, size_t * rsize,
 		struct jffs2_raw_inode *n)
 {
 	uLongf dlen = je32_to_cpu(n->dsize);
@@ -184,7 +166,7 @@ void putblock(char *b, size_t bsize, size_t * rsize,
    return value: directory struct value replacing dd
  */
 
-struct dir *putdir(struct dir *dd, struct jffs2_raw_dirent *n)
+static struct dir *putdir(struct dir *dd, struct jffs2_raw_dirent *n)
 {
 	struct dir *o, *d, *p;
 
@@ -279,7 +261,7 @@ static const char SMODE0[] = "..S..S..T";
  * Return the standard ls-like mode string from a file mode.
  * This is static and so is overwritten on each call.
  */
-const char *mode_string(int mode)
+static const char *mode_string(int mode)
 {
 	static char buf[12];
 
@@ -301,8 +283,8 @@ const char *mode_string(int mode)
    d       - dir struct
  */
 
-void printdir(char *o, size_t size, struct dir *d, const char *path, int recurse,
-		int want_ctime)
+static void printdir(char *o, size_t size, struct dir *d, const char *path,
+					 int recurse, int want_ctime)
 {
 	char m;
 	char *filetime;
@@ -404,7 +386,7 @@ void printdir(char *o, size_t size, struct dir *d, const char *path, int recurse
    d       - dir struct
  */
 
-void freedir(struct dir *d)
+static void freedir(struct dir *d)
 {
 	struct dir *t;
 
@@ -429,7 +411,8 @@ void freedir(struct dir *d)
    inode, or NULL
  */
 
-struct jffs2_raw_inode *find_raw_inode(char *o, size_t size, uint32_t ino)
+static struct jffs2_raw_inode *find_raw_inode(char *o, size_t size,
+											  uint32_t ino)
 {
 	/* aligned! */
 	union jffs2_node_union *n;
@@ -497,7 +480,7 @@ struct jffs2_raw_inode *find_raw_inode(char *o, size_t size, uint32_t ino)
    return value: result directory structure, replaces d.
  */
 
-struct dir *collectdir(char *o, size_t size, uint32_t ino, struct dir *d)
+static struct dir *collectdir(char *o, size_t size, uint32_t ino, struct dir *d)
 {
 	/* aligned! */
 	union jffs2_node_union *n;
@@ -585,7 +568,7 @@ struct dir *collectdir(char *o, size_t size, uint32_t ino, struct dir *d)
    filesystem image or NULL
  */
 
-struct jffs2_raw_dirent *resolvedirent(char *o, size_t size,
+static struct jffs2_raw_dirent *resolvedirent(char *o, size_t size,
 		uint32_t ino, uint32_t pino,
 		char *name, uint8_t nsize)
 {
@@ -642,7 +625,7 @@ struct jffs2_raw_dirent *resolvedirent(char *o, size_t size,
    filesystem image or NULL
  */
 
-struct jffs2_raw_dirent *resolvename(char *o, size_t size, uint32_t pino,
+static struct jffs2_raw_dirent *resolvename(char *o, size_t size, uint32_t pino,
 		char *name, uint8_t nsize)
 {
 	return resolvedirent(o, size, 0, pino, name, nsize);
@@ -659,7 +642,7 @@ struct jffs2_raw_dirent *resolvename(char *o, size_t size, uint32_t pino,
    filesystem image or NULL
  */
 
-struct jffs2_raw_dirent *resolveinode(char *o, size_t size, uint32_t ino)
+static struct jffs2_raw_dirent *resolveinode(char *o, size_t size, uint32_t ino)
 {
 	return resolvedirent(o, size, ino, 0, NULL, 0);
 }
@@ -682,7 +665,7 @@ struct jffs2_raw_dirent *resolveinode(char *o, size_t size, uint32_t ino)
    (return value is NULL), but it has inode (*inos=1)
  */
 
-struct jffs2_raw_dirent *resolvepath0(char *o, size_t size, uint32_t ino,
+static struct jffs2_raw_dirent *resolvepath0(char *o, size_t size, uint32_t ino,
 		const char *p, uint32_t * inos, int recc)
 {
 	struct jffs2_raw_dirent *dir = NULL;
@@ -798,7 +781,7 @@ struct jffs2_raw_dirent *resolvepath0(char *o, size_t size, uint32_t ino,
    (return value is NULL), but it has inode (*inos=1)
  */
 
-struct jffs2_raw_dirent *resolvepath(char *o, size_t size, uint32_t ino,
+static struct jffs2_raw_dirent *resolvepath(char *o, size_t size, uint32_t ino,
 		const char *p, uint32_t * inos)
 {
 	return resolvepath0(o, size, ino, p, inos, 0);
@@ -812,7 +795,8 @@ struct jffs2_raw_dirent *resolvepath(char *o, size_t size, uint32_t ino,
    p       - path to be resolved
  */
 
-void lsdir(char *o, size_t size, const char *path, int recurse, int want_ctime)
+static void lsdir(char *o, size_t size, const char *path, int recurse,
+				  int want_ctime)
 {
 	struct jffs2_raw_dirent *dd;
 	struct dir *d = NULL;
@@ -841,8 +825,8 @@ void lsdir(char *o, size_t size, const char *path, int recurse, int want_ctime)
    rsize   - file result size
  */
 
-void catfile(char *o, size_t size, char *path, char *b, size_t bsize,
-		size_t * rsize)
+static void catfile(char *o, size_t size, char *path, char *b, size_t bsize,
+					size_t * rsize)
 {
 	struct jffs2_raw_dirent *dd;
 	struct jffs2_raw_inode *ri;
diff --git a/jffsX-utils/mkfs.jffs2.c b/jffsX-utils/mkfs.jffs2.c
index 2fb7730..9aa6c39 100644
--- a/jffsX-utils/mkfs.jffs2.c
+++ b/jffsX-utils/mkfs.jffs2.c
@@ -112,7 +112,7 @@ static int squash_perms = 0;
 static int fake_times = 0;
 int target_endian = __BYTE_ORDER;
 
-uint32_t find_hardlink(struct filesystem_entry *e)
+static uint32_t find_hardlink(struct filesystem_entry *e)
 {
 	struct filesystem_entry *f;
 	struct rb_node **n = &hardlinks.rb_node;
@@ -139,7 +139,7 @@ uint32_t find_hardlink(struct filesystem_entry *e)
 	return 0;
 }
 
-extern char *xreadlink(const char *path)
+static char *xreadlink(const char *path)
 {
 	static const int GROWBY = 80; /* how large we will grow strings by */
 
@@ -1428,7 +1428,7 @@ static const char helptext[] =
 "  -V, --version           Display version information\n"
 "  -i, --incremental=FILE  Parse FILE and generate appendage output for it\n\n";
 
-int load_next_block() {
+static int load_next_block(void) {
 
 	int ret;
 	ret = read(in_fd, file_buffer, erase_block_size);
@@ -1439,7 +1439,7 @@ int load_next_block() {
 	return ret;
 }
 
-void process_buffer(int inp_size) {
+static void process_buffer(int inp_size) {
 	uint8_t		*p = file_buffer;
 	union jffs2_node_union 	*node;
 	uint16_t	type;
@@ -1542,7 +1542,7 @@ void process_buffer(int inp_size) {
 	}
 }
 
-void parse_image(){
+static void parse_image(void){
 	int ret;
 
 	file_buffer = xmalloc(erase_block_size);
diff --git a/jffsX-utils/sumtool.c b/jffsX-utils/sumtool.c
index a995bdf..68268a9 100644
--- a/jffsX-utils/sumtool.c
+++ b/jffsX-utils/sumtool.c
@@ -120,7 +120,7 @@ static unsigned char ffbuf[16] = {
 
 static void full_write(void *target_buff, const void *buf, int len);
 
-void setup_cleanmarker(void)
+static void setup_cleanmarker(void)
 {
 	cleanmarker.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
 	cleanmarker.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER);
@@ -128,7 +128,7 @@ void setup_cleanmarker(void)
 	cleanmarker.hdr_crc = cpu_to_je32(mtd_crc32(0, &cleanmarker, sizeof(struct jffs2_unknown_node)-4));
 }
 
-void process_options (int argc, char **argv)
+static void process_options (int argc, char **argv)
 {
 	int opt,c;
 
@@ -227,24 +227,24 @@ void process_options (int argc, char **argv)
 }
 
 
-void init_buffers(void)
+static void init_buffers(void)
 {
 	data_buffer = xmalloc(erase_block_size);
 	file_buffer = xmalloc(erase_block_size);
 }
 
-void init_sumlist(void)
+static void init_sumlist(void)
 {
 	sum_collected = xzalloc(sizeof(*sum_collected));
 }
 
-void clean_buffers(void)
+static void clean_buffers(void)
 {
 	free(data_buffer);
 	free(file_buffer);
 }
 
-void clean_sumlist(void)
+static void clean_sumlist(void)
 {
 	union jffs2_sum_mem *temp;
 
@@ -264,7 +264,7 @@ void clean_sumlist(void)
 	}
 }
 
-int load_next_block(void)
+static int load_next_block(void)
 {
 	int ret;
 	ret = read(in_fd, file_buffer, erase_block_size);
@@ -275,7 +275,7 @@ int load_next_block(void)
 	return ret;
 }
 
-void write_buff_to_file(void)
+static void write_buff_to_file(void)
 {
 	int ret;
 	int len = data_ofs;
@@ -299,7 +299,7 @@ void write_buff_to_file(void)
 	data_ofs = 0;
 }
 
-void dump_sum_records(void)
+static void dump_sum_records(void)
 {
 
 	struct jffs2_raw_summary isum;
@@ -475,7 +475,7 @@ static inline void pad_block_if_less_than(int req,int plus)
 	}
 }
 
-void flush_buffers(void)
+static void flush_buffers(void)
 {
 
 	if ((add_cleanmarkers == 1) && (found_cleanmarkers == 1)) { /* CLEANMARKER */
@@ -513,7 +513,7 @@ void flush_buffers(void)
 	}
 }
 
-int add_sum_mem(union jffs2_sum_mem *item)
+static int add_sum_mem(union jffs2_sum_mem *item)
 {
 
 	if (!sum_collected->sum_list_head)
@@ -549,7 +549,7 @@ int add_sum_mem(union jffs2_sum_mem *item)
 	return 0;
 }
 
-void add_sum_inode_mem(union jffs2_node_union *node)
+static void add_sum_inode_mem(union jffs2_node_union *node)
 {
 	struct jffs2_sum_inode_mem *temp = xmalloc(sizeof(*temp));
 
@@ -563,7 +563,7 @@ void add_sum_inode_mem(union jffs2_node_union *node)
 	add_sum_mem((union jffs2_sum_mem *) temp);
 }
 
-void add_sum_dirent_mem(union jffs2_node_union *node)
+static void add_sum_dirent_mem(union jffs2_node_union *node)
 {
 	struct jffs2_sum_dirent_mem *temp = xmalloc(sizeof(*temp) + node->d.nsize);
 
@@ -581,7 +581,7 @@ void add_sum_dirent_mem(union jffs2_node_union *node)
 	add_sum_mem((union jffs2_sum_mem *) temp);
 }
 
-void add_sum_xattr_mem(union jffs2_node_union *node)
+static void add_sum_xattr_mem(union jffs2_node_union *node)
 {
 	struct jffs2_sum_xattr_mem *temp = xmalloc(sizeof(*temp));
 
@@ -595,7 +595,7 @@ void add_sum_xattr_mem(union jffs2_node_union *node)
 	add_sum_mem((union jffs2_sum_mem *) temp);
 }
 
-void add_sum_xref_mem(union jffs2_node_union *node)
+static void add_sum_xref_mem(union jffs2_node_union *node)
 {
 	struct jffs2_sum_xref_mem *temp = xmalloc(sizeof(*temp));
 
@@ -606,7 +606,7 @@ void add_sum_xref_mem(union jffs2_node_union *node)
 	add_sum_mem((union jffs2_sum_mem *) temp);
 }
 
-void write_dirent_to_buff(union jffs2_node_union *node)
+static void write_dirent_to_buff(union jffs2_node_union *node)
 {
 	pad_block_if_less_than(je32_to_cpu (node->d.totlen),JFFS2_SUMMARY_DIRENT_SIZE(node->d.nsize));
 	add_sum_dirent_mem(node);
@@ -615,7 +615,7 @@ void write_dirent_to_buff(union jffs2_node_union *node)
 }
 
 
-void write_inode_to_buff(union jffs2_node_union *node)
+static void write_inode_to_buff(union jffs2_node_union *node)
 {
 	pad_block_if_less_than(je32_to_cpu (node->i.totlen),JFFS2_SUMMARY_INODE_SIZE);
 	add_sum_inode_mem(node);	/* Add inode summary mem to summary list */
@@ -623,7 +623,7 @@ void write_inode_to_buff(union jffs2_node_union *node)
 	padword();
 }
 
-void write_xattr_to_buff(union jffs2_node_union *node)
+static void write_xattr_to_buff(union jffs2_node_union *node)
 {
 	pad_block_if_less_than(je32_to_cpu(node->x.totlen), JFFS2_SUMMARY_XATTR_SIZE);
 	add_sum_xattr_mem(node);	/* Add xdatum summary mem to summary list */
@@ -631,7 +631,7 @@ void write_xattr_to_buff(union jffs2_node_union *node)
 	padword();
 }
 
-void write_xref_to_buff(union jffs2_node_union *node)
+static void write_xref_to_buff(union jffs2_node_union *node)
 {
 	pad_block_if_less_than(je32_to_cpu(node->r.totlen), JFFS2_SUMMARY_XREF_SIZE);
 	add_sum_xref_mem(node);		/* Add xref summary mem to summary list */
@@ -639,7 +639,7 @@ void write_xref_to_buff(union jffs2_node_union *node)
 	padword();
 }
 
-void create_summed_image(int inp_size)
+static void create_summed_image(int inp_size)
 {
 	uint8_t *p = file_buffer;
 	union jffs2_node_union *node;
diff --git a/lib/libcrc32.c b/lib/libcrc32.c
index 90b916c..48563a8 100644
--- a/lib/libcrc32.c
+++ b/lib/libcrc32.c
@@ -38,6 +38,7 @@
  */
 
 #include <stdint.h>
+#include "crc32.h"
 
 static const uint32_t crc32_table[256] = {
 	0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
diff --git a/lib/libfec.c b/lib/libfec.c
index 0d8056a..aeb0bc2 100644
--- a/lib/libfec.c
+++ b/lib/libfec.c
@@ -544,7 +544,7 @@ fail:
  * q = values of the polynomial (known)
  */
 
-int
+static int
 invert_vdm(gf *src, int k)
 {
     int i, j, row, col ;
diff --git a/lib/libmtd.c b/lib/libmtd.c
index a50f18a..1ecb31b 100644
--- a/lib/libmtd.c
+++ b/lib/libmtd.c
@@ -1200,9 +1200,9 @@ int mtd_write(libmtd_t desc, const struct mtd_dev_info *mtd, int fd, int eb,
 	return 0;
 }
 
-int do_oob_op(libmtd_t desc, const struct mtd_dev_info *mtd, int fd,
-	      uint64_t start, uint64_t length, void *data, unsigned int cmd64,
-	      unsigned int cmd)
+static int do_oob_op(libmtd_t desc, const struct mtd_dev_info *mtd, int fd,
+		     uint64_t start, uint64_t length, void *data,
+		     unsigned int cmd64, unsigned int cmd)
 {
 	int ret, oob_offs;
 	struct mtd_oob_buf64 oob64;
diff --git a/misc-utils/docfdisk.c b/misc-utils/docfdisk.c
index b363662..c2b9150 100644
--- a/misc-utils/docfdisk.c
+++ b/misc-utils/docfdisk.c
@@ -44,7 +44,7 @@ struct INFTLMediaHeader *mh;
 
 #define MAXSCAN 10
 
-void show_header(int mhoffs) {
+static void show_header(int mhoffs) {
 	int i, unitsize, numunits, bmbits, numpart;
 	int start, end, num, nextunit;
 	unsigned int flags;
diff --git a/misc-utils/flash_otp_write.c b/misc-utils/flash_otp_write.c
index 111318d..b02d0b0 100644
--- a/misc-utils/flash_otp_write.c
+++ b/misc-utils/flash_otp_write.c
@@ -16,7 +16,7 @@
 #include <common.h>
 #include <mtd/mtd-user.h>
 
-ssize_t xread(int fd, void *buf, size_t count)
+static ssize_t xread(int fd, void *buf, size_t count)
 {
 	ssize_t ret, done = 0;
 
diff --git a/misc-utils/ftl_check.c b/misc-utils/ftl_check.c
index 970d968..a853cf4 100644
--- a/misc-utils/ftl_check.c
+++ b/misc-utils/ftl_check.c
@@ -169,7 +169,7 @@ static void check_partition(int fd)
 } /* format_partition */
 
 /* Show usage information */
-void showusage(void)
+static void showusage(void)
 {
 	fprintf(stderr, "usage: %s device\n", PROGRAM_NAME);
 }
diff --git a/misc-utils/mtd_debug.c b/misc-utils/mtd_debug.c
index f3826cf..90f5d52 100644
--- a/misc-utils/mtd_debug.c
+++ b/misc-utils/mtd_debug.c
@@ -76,7 +76,7 @@ static int getregions(int fd, struct region_info_user *regions, int *n)
 	return 0;
 }
 
-int erase_flash(int fd, u_int32_t offset, u_int32_t bytes)
+static int erase_flash(int fd, u_int32_t offset, u_int32_t bytes)
 {
 	int err;
 	struct erase_info_user erase;
@@ -91,7 +91,7 @@ int erase_flash(int fd, u_int32_t offset, u_int32_t bytes)
 	return 0;
 }
 
-void printsize(u_int32_t x)
+static void printsize(u_int32_t x)
 {
 	int i;
 	static const char *flags = "KMGT";
@@ -103,7 +103,7 @@ void printsize(u_int32_t x)
 		printf("(%u%c)", x, flags[i]);
 }
 
-int flash_to_file(int fd, off_t offset, size_t len, const char *filename)
+static int flash_to_file(int fd, off_t offset, size_t len, const char *filename)
 {
 	u_int8_t *buf = NULL;
 	int outfd, err;
@@ -172,7 +172,8 @@ err0:
 	return 1;
 }
 
-int file_to_flash(int fd, off_t offset, u_int32_t len, const char *filename)
+static int file_to_flash(int fd, off_t offset, u_int32_t len,
+			 const char *filename)
 {
 	u_int8_t *buf = NULL;
 	FILE *fp;
@@ -228,7 +229,7 @@ retry:
 	return 0;
 }
 
-int showinfo(int fd)
+static int showinfo(int fd)
 {
 	int i, err, n;
 	struct mtd_info_user mtd;
@@ -338,7 +339,7 @@ int showinfo(int fd)
 	return 0;
 }
 
-void showusage(void)
+static void showusage(void)
 {
 	fprintf(stderr, "usage: %1$s info <device>\n"
 			"       %1$s read <device> <offset> <len> <dest-filename>\n"
diff --git a/nand-utils/nandtest.c b/nand-utils/nandtest.c
index 9e39446..d5c7369 100644
--- a/nand-utils/nandtest.c
+++ b/nand-utils/nandtest.c
@@ -17,7 +17,7 @@
 #include "mtd/mtd-user.h"
 #include "common.h"
 
-void usage(int status)
+static void usage(int status)
 {
 	fprintf(status ? stderr : stdout,
 		"usage: %s [OPTIONS] <device>\n\n"
@@ -40,7 +40,8 @@ int fd;
 int markbad=0;
 int seed;
 
-int read_and_compare(loff_t ofs, unsigned char *data, unsigned char *rbuf)
+static int read_and_compare(loff_t ofs, unsigned char *data,
+			    unsigned char *rbuf)
 {
 	ssize_t len;
 	int i;
@@ -89,7 +90,8 @@ int read_and_compare(loff_t ofs, unsigned char *data, unsigned char *rbuf)
 	return 0;
 }
 
-int erase_and_write(loff_t ofs, unsigned char *data, unsigned char *rbuf, int nr_reads)
+static int erase_and_write(loff_t ofs, unsigned char *data, unsigned char *rbuf,
+			   int nr_reads)
 {
 	struct erase_info_user er;
 	ssize_t len;
diff --git a/nand-utils/nftl_format.c b/nand-utils/nftl_format.c
index ea8199d..ec87604 100644
--- a/nand-utils/nftl_format.c
+++ b/nand-utils/nftl_format.c
@@ -198,7 +198,7 @@ static int checkbbt(void)
 	return (0);
 }
 
-void usage(int rc)
+static void usage(int rc)
 {
 	fprintf(stderr, "Usage: %s [-ib] <mtddevice> [<start offset> [<size>]]\n", PROGRAM_NAME);
 	exit(rc);
diff --git a/nor-utils/rfddump.c b/nor-utils/rfddump.c
index 5141ea3..4ad2f91 100644
--- a/nor-utils/rfddump.c
+++ b/nor-utils/rfddump.c
@@ -55,7 +55,7 @@ struct rfd {
 	int verbose;
 };
 
-void display_help(int status)
+static void display_help(int status)
 {
 	printf("Usage: %s [OPTIONS] MTD-device filename\n"
 			"Dumps the contents of a resident flash disk\n"
@@ -68,7 +68,7 @@ void display_help(int status)
 	exit(status);
 }
 
-void display_version(void)
+static void display_version(void)
 {
 	common_print_version();
 	printf("This is free software; see the source for copying conditions.  There is NO\n"
@@ -76,7 +76,7 @@ void display_version(void)
 	exit(0);
 }
 
-void process_options(int argc, char *argv[], struct rfd *rfd)
+static void process_options(int argc, char *argv[], struct rfd *rfd)
 {
 	int error = 0;
 
@@ -125,7 +125,7 @@ void process_options(int argc, char *argv[], struct rfd *rfd)
 	rfd->out_filename = argv[optind + 1];
 }
 
-int build_block_map(struct rfd *rfd, int fd, int block)
+static int build_block_map(struct rfd *rfd, int fd, int block)
 {
 	int  i;
 	int sectors;
diff --git a/nor-utils/rfdformat.c b/nor-utils/rfdformat.c
index 1f01a85..0a3d9fb 100644
--- a/nor-utils/rfdformat.c
+++ b/nor-utils/rfdformat.c
@@ -30,7 +30,7 @@
 
 #include "common.h"
 
-void display_help(int status)
+static void display_help(int status)
 {
 	printf("Usage: %s [OPTIONS] MTD-device\n"
 			"Formats NOR flash for resident flash disk\n"
@@ -41,7 +41,7 @@ void display_help(int status)
 	exit(status);
 }
 
-void display_version(void)
+static void display_version(void)
 {
 	common_print_version();
 	printf("This is free software; see the source for copying conditions.  There is NO\n"
@@ -49,7 +49,7 @@ void display_version(void)
 	exit(0);
 }
 
-void process_options(int argc, char *argv[], const char **mtd_filename)
+static void process_options(int argc, char *argv[], const char **mtd_filename)
 {
 	int error = 0;
 
diff --git a/tests/checkfs/checkfs.c b/tests/checkfs/checkfs.c
index 3e4a6e2..3e34cc4 100644
--- a/tests/checkfs/checkfs.c
+++ b/tests/checkfs/checkfs.c
@@ -161,7 +161,7 @@ static const unsigned short crc_ccitt_table[] = {
   Returns file descriptor to open port. Use this fd to write to port
   and close it later, when done.
 */
-int setupSerial (const char *dev) {
+static int setupSerial (const char *dev) {
     int i, fd;
     struct termios tios;
 
@@ -215,7 +215,7 @@ int setupSerial (const char *dev) {
 //CRC to calculate out to 0xf0b8 (the hardcoded value at the end)
 //and returns TRUE if it is and FALSE if it doesn't.
 //Why don't people document better!!!!
-int check_crc_ccitt(char *filename)
+static int check_crc_ccitt(char *filename)
 {
     FILE *fp;
     FILE *logfp;
@@ -306,7 +306,7 @@ int check_crc_ccitt(char *filename)
   initially (and once) created by the separate "makefiles.c"
   program.
 */
-void send_pwrdn_ok(void){
+static void send_pwrdn_ok(void){
 
     int fd;
     FILE *cyclefp;
@@ -363,7 +363,7 @@ void send_pwrdn_ok(void){
   Appends 16bit CRC at the end of numBytes long buffer.
   Make sure buf, extends at least 2 bytes beyond.
  */
-void appendChecksum(char *buf, int numBytes){
+static void appendChecksum(char *buf, int numBytes){
 
     unsigned short crc = 0xffff;
     int index = 0;
@@ -395,7 +395,7 @@ void appendChecksum(char *buf, int numBytes){
   number of int's in it (this is needed to know how much
   data to read and checksum later).
 */
-void make_new_file(char *filename){
+static void make_new_file(char *filename){
 
 
     int dfd; /* data file descriptor */
@@ -486,7 +486,7 @@ void make_new_file(char *filename){
 /*
   Show's help on stdout
  */
-void printHelp(char **argv)
+static void printHelp(char **argv)
 {
     printf("Usage:%s <options, defined below>\n", argv[0]);
     printf("%s </dev/ttyS0,1,2...>: Set com port to send ok to pwr dn msg on\n",
@@ -502,7 +502,7 @@ void printHelp(char **argv)
 
 
 
-void processCmdLine(int argc, char **argv)
+static void processCmdLine(int argc, char **argv)
 {
 
     int cnt;
diff --git a/tests/checkfs/makefiles.c b/tests/checkfs/makefiles.c
index 52fea54..4f37f2e 100644
--- a/tests/checkfs/makefiles.c
+++ b/tests/checkfs/makefiles.c
@@ -79,7 +79,7 @@ static const unsigned short crc_ccitt_table[] = {
 //CRC to calculate out to 0xf0b8 (the hardcoded value at the end)
 //and returns TRUE if it is and FALSE if it doesn't.
 //Why don't people document better!!!!
-void check_crc_ccitt(char *filename)
+static void check_crc_ccitt(char *filename)
 {
   FILE *fp;
   unsigned short crc = 0xffff;
@@ -127,7 +127,7 @@ void check_crc_ccitt(char *filename)
  contents, and then appends the checksum at the end of the file,
  closes the file and returns.
 */
-void checksum(char *filename){
+static void checksum(char *filename){
 
   FILE *fp;
   unsigned short crc = 0xffff;
diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 827adc5..cac145d 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -1640,7 +1640,7 @@ static char *symlink_path(const char *path, const char *target_pathname)
 	return p;
 }
 
-void symlink_check(const struct symlink_info *symlink)
+static void symlink_check(const struct symlink_info *symlink)
 {
 	char *path, buf[8192], *target;
 	struct stat st1, st2;
diff --git a/tests/fs-tests/lib/tests.c b/tests/fs-tests/lib/tests.c
index 8a6a5f5..8d4d83a 100644
--- a/tests/fs-tests/lib/tests.c
+++ b/tests/fs-tests/lib/tests.c
@@ -530,7 +530,7 @@ void tests_check_filled_file(const char *file_name)
 	CHECK(close(fd) != -1);
 }
 
-void tests_sync_directory(const char *file_name)
+static void tests_sync_directory(const char *file_name)
 {
 	char *path;
 	char *dir;
@@ -949,7 +949,7 @@ int64_t tests_remove_entry(void)
 }
 
 /* Read mount information from /proc/mounts or /etc/mtab */
-int tests_get_mount_info(struct mntent *info)
+static int tests_get_mount_info(struct mntent *info)
 {
 	FILE *f;
 	struct mntent *entry;
diff --git a/tests/fs-tests/simple/ftrunc.c b/tests/fs-tests/simple/ftrunc.c
index 86edf65..2df404b 100644
--- a/tests/fs-tests/simple/ftrunc.c
+++ b/tests/fs-tests/simple/ftrunc.c
@@ -32,7 +32,7 @@
 
 #define WRITE_BUFFER_SIZE 32768
 
-void ftrunc(void)
+static void ftrunc(void)
 {
 	int fd, i;
 	pid_t pid;
@@ -74,14 +74,14 @@ void ftrunc(void)
 
 /* Title of this test */
 
-const char *ftrunc_get_title(void)
+static const char *ftrunc_get_title(void)
 {
 	return "Truncate a large test file";
 }
 
 /* Description of this test */
 
-const char *ftrunc_get_description(void)
+static const char *ftrunc_get_description(void)
 {
 	return
 		"Create a file named ftrunc_test_file. " \
diff --git a/tests/fs-tests/simple/orph.c b/tests/fs-tests/simple/orph.c
index f6d8956..c51fa2c 100644
--- a/tests/fs-tests/simple/orph.c
+++ b/tests/fs-tests/simple/orph.c
@@ -32,7 +32,7 @@
 
 #define MAX_ORPHANS 1000000
 
-void orph(void)
+static void orph(void)
 {
 	pid_t pid;
 	unsigned i, j, k, n;
@@ -133,14 +133,14 @@ void orph(void)
 
 /* Title of this test */
 
-const char *orph_get_title(void)
+static const char *orph_get_title(void)
 {
 	return "Create many open unlinked files";
 }
 
 /* Description of this test */
 
-const char *orph_get_description(void)
+static const char *orph_get_description(void)
 {
 	return
 		"Create a directory named orph_test_dir_pid, where " \
diff --git a/tests/fs-tests/simple/perf.c b/tests/fs-tests/simple/perf.c
index b98b98b..aee8226 100644
--- a/tests/fs-tests/simple/perf.c
+++ b/tests/fs-tests/simple/perf.c
@@ -66,7 +66,7 @@ static unsigned speed(size_t bytes, long long usecs)
 	return (unsigned) k;
 }
 
-void perf(void)
+static void perf(void)
 {
 	pid_t pid;
 	int fd, i;
@@ -155,14 +155,14 @@ void perf(void)
 
 /* Title of this test */
 
-const char *perf_get_title(void)
+static const char *perf_get_title(void)
 {
 	return "Measure file system read and write speed";
 }
 
 /* Description of this test */
 
-const char *perf_get_description(void)
+static const char *perf_get_description(void)
 {
 	return
 		"Syncs the file system (a newly created empty file system is " \
diff --git a/tests/fs-tests/simple/test_1.c b/tests/fs-tests/simple/test_1.c
index 79fd0b9..874e4b2 100644
--- a/tests/fs-tests/simple/test_1.c
+++ b/tests/fs-tests/simple/test_1.c
@@ -28,7 +28,7 @@
 
 #include "tests.h"
 
-void test_1(void)
+static void test_1(void)
 {
 	int fd;
 	pid_t pid;
@@ -112,14 +112,14 @@ void test_1(void)
 
 /* Title of this test */
 
-const char *test_1_get_title(void)
+static const char *test_1_get_title(void)
 {
 	return "Fill file system while holding deleted big file descriptor";
 }
 
 /* Description of this test */
 
-const char *test_1_get_description(void)
+static const char *test_1_get_description(void)
 {
 	return
 		"Create a directory named test_1_test_dir_pid, where " \
diff --git a/tests/fs-tests/simple/test_2.c b/tests/fs-tests/simple/test_2.c
index 2094460..cef1536 100644
--- a/tests/fs-tests/simple/test_2.c
+++ b/tests/fs-tests/simple/test_2.c
@@ -28,7 +28,7 @@
 
 #include "tests.h"
 
-void test_2(void)
+static void test_2(void)
 {
 	pid_t pid;
 	int create, full;
@@ -163,14 +163,14 @@ void test_2(void)
 
 /* Title of this test */
 
-const char *test_2_get_title(void)
+static const char *test_2_get_title(void)
 {
 	return "Repeated write many small files and one big deleted file";
 }
 
 /* Description of this test */
 
-const char *test_2_get_description(void)
+static const char *test_2_get_description(void)
 {
 	return
 		"Create a directory named test_2_test_dir_pid, where " \
diff --git a/tests/fs-tests/stress/atoms/fwrite00.c b/tests/fs-tests/stress/atoms/fwrite00.c
index fd691be..3406bba 100644
--- a/tests/fs-tests/stress/atoms/fwrite00.c
+++ b/tests/fs-tests/stress/atoms/fwrite00.c
@@ -34,7 +34,7 @@
 
 #define HOLE_BLOCK_SIZE 10000000
 
-void filestress00(void)
+static void filestress00(void)
 {
 	int fd, i, deleted;
 	pid_t pid;
@@ -153,14 +153,14 @@ void filestress00(void)
 
 /* Title of this test */
 
-const char *filestress00_get_title(void)
+static const char *filestress00_get_title(void)
 {
 	return "File stress test 00";
 }
 
 /* Description of this test */
 
-const char *filestress00_get_description(void)
+static const char *filestress00_get_description(void)
 {
 	return
 		"Create a file named filestress00_test_file_pid, where " \
diff --git a/tests/fs-tests/stress/atoms/gcd_hupper.c b/tests/fs-tests/stress/atoms/gcd_hupper.c
index 31c175d..522250b 100644
--- a/tests/fs-tests/stress/atoms/gcd_hupper.c
+++ b/tests/fs-tests/stress/atoms/gcd_hupper.c
@@ -46,7 +46,7 @@ struct gcd_pid
 
 struct gcd_pid *gcd_pid_list = NULL;
 
-int add_gcd_pid(const char *number)
+static int add_gcd_pid(const char *number)
 {
 	int pid;
 	FILE *f;
@@ -86,7 +86,7 @@ int add_gcd_pid(const char *number)
 	return pid;
 }
 
-int get_pid_list(void)
+static int get_pid_list(void)
 {
 	DIR *dir;
 	struct dirent *entry;
@@ -107,7 +107,7 @@ int get_pid_list(void)
 	return 0;
 }
 
-int parse_index_number(const char *name)
+static int parse_index_number(const char *name)
 {
 	const char *p, *q;
 	int all_zero;
@@ -133,7 +133,7 @@ int parse_index_number(const char *name)
 	return index;
 }
 
-int get_mtd_index(void)
+static int get_mtd_index(void)
 {
 	FILE *f;
 	struct mntent *entry;
@@ -172,7 +172,7 @@ int get_mtd_index(void)
 	return mtd_index;
 }
 
-int get_gcd_pid()
+static int get_gcd_pid(void)
 {
 	struct gcd_pid *g;
 	int mtd_index;
@@ -188,7 +188,7 @@ int get_gcd_pid()
 	return 0;
 }
 
-void gcd_hupper(void)
+static void gcd_hupper(void)
 {
 	int64_t repeat;
 	int pid;
@@ -213,14 +213,14 @@ void gcd_hupper(void)
 
 /* Title of this test */
 
-const char *gcd_hupper_get_title(void)
+static const char *gcd_hupper_get_title(void)
 {
 	return "Send HUP signals to gcd";
 }
 
 /* Description of this test */
 
-const char *gcd_hupper_get_description(void)
+static const char *gcd_hupper_get_description(void)
 {
 	return
 		"Determine the PID of the gcd process. " \
diff --git a/tests/fs-tests/stress/atoms/pdfrun.c b/tests/fs-tests/stress/atoms/pdfrun.c
index 46c70e1..094af66 100644
--- a/tests/fs-tests/stress/atoms/pdfrun.c
+++ b/tests/fs-tests/stress/atoms/pdfrun.c
@@ -32,7 +32,7 @@
 
 #define WRITE_BUFFER_SIZE 32768
 
-void adjust_size(void)
+static void adjust_size(void)
 {
 	char dummy[1024];
 	unsigned long total_memory;
@@ -49,7 +49,7 @@ void adjust_size(void)
 		tests_size_parameter = total_memory / 2;
 }
 
-void run_pdf(void)
+static void run_pdf(void)
 {
 	int fd, i;
 	pid_t pid;
@@ -99,14 +99,14 @@ void run_pdf(void)
 
 /* Title of this test */
 
-const char *run_pdf_get_title(void)
+static const char *run_pdf_get_title(void)
 {
 	return "Create / overwrite a large file in the current directory";
 }
 
 /* Description of this test */
 
-const char *run_pdf_get_description(void)
+static const char *run_pdf_get_description(void)
 {
 	return
 		"Create a file named run_pdf_test_file_pid, " \
diff --git a/tests/fs-tests/stress/atoms/rmdir00.c b/tests/fs-tests/stress/atoms/rmdir00.c
index c1d0729..d855310 100644
--- a/tests/fs-tests/stress/atoms/rmdir00.c
+++ b/tests/fs-tests/stress/atoms/rmdir00.c
@@ -30,7 +30,7 @@
 
 #include "tests.h"
 
-void rmdir00(void)
+static void rmdir00(void)
 {
 	int64_t repeat;
 	int64_t size, this_size;
@@ -77,14 +77,14 @@ void rmdir00(void)
 
 /* Title of this test */
 
-const char *rmdir00_get_title(void)
+static const char *rmdir00_get_title(void)
 {
 	return "Create and remove directories and files";
 }
 
 /* Description of this test */
 
-const char *rmdir00_get_description(void)
+static const char *rmdir00_get_description(void)
 {
 	return
 		"Create a directory named rmdir00_test_dir_pid, where " \
diff --git a/tests/fs-tests/stress/atoms/rndrm00.c b/tests/fs-tests/stress/atoms/rndrm00.c
index 724b1c3..75e163c 100644
--- a/tests/fs-tests/stress/atoms/rndrm00.c
+++ b/tests/fs-tests/stress/atoms/rndrm00.c
@@ -30,7 +30,7 @@
 
 #include "tests.h"
 
-void rndrm00(void)
+static void rndrm00(void)
 {
 	int64_t repeat;
 	int64_t size, this_size;
@@ -100,14 +100,14 @@ void rndrm00(void)
 
 /* Title of this test */
 
-const char *rndrm00_get_title(void)
+static const char *rndrm00_get_title(void)
 {
 	return "Randomly create and remove directories and files";
 }
 
 /* Description of this test */
 
-const char *rndrm00_get_description(void)
+static const char *rndrm00_get_description(void)
 {
 	return
 		"Create a directory named rndrm00_test_dir_pid, where " \
diff --git a/tests/fs-tests/stress/atoms/rndrm99.c b/tests/fs-tests/stress/atoms/rndrm99.c
index 7751839..340fe5d 100644
--- a/tests/fs-tests/stress/atoms/rndrm99.c
+++ b/tests/fs-tests/stress/atoms/rndrm99.c
@@ -43,7 +43,7 @@ uint32_t dirs_created = 0;
 uint32_t dirs_removed = 0;
 int64_t *size_ptr = 0;
 
-void display_stats(void)
+static void display_stats(void)
 {
 	printf(	"\nrndrm99 stats:\n"
 		"\tNumber of files created = %u\n"
@@ -62,12 +62,12 @@ void display_stats(void)
 struct timeval tv_before;
 struct timeval tv_after;
 
-void before(void)
+static void before(void)
 {
 	CHECK(gettimeofday(&tv_before, NULL) != -1);
 }
 
-void after(const char *msg)
+static void after(const char *msg)
 {
 	time_t diff;
 	CHECK(gettimeofday(&tv_after, NULL) != -1);
@@ -104,7 +104,7 @@ static void init_write_buffer()
 
 /* Write size random bytes into file descriptor fd at the current position,
    returning the number of bytes actually written */
-uint64_t fill_file(int fd, uint64_t size)
+static uint64_t fill_file(int fd, uint64_t size)
 {
 	ssize_t written;
 	size_t sz;
@@ -142,7 +142,7 @@ uint64_t fill_file(int fd, uint64_t size)
 }
 
 /* Create a file of size file_size */
-uint64_t create_file(const char *file_name, uint64_t file_size)
+static uint64_t create_file(const char *file_name, uint64_t file_size)
 {
 	int fd;
 	int flags;
@@ -176,7 +176,7 @@ uint64_t create_file(const char *file_name, uint64_t file_size)
 }
 
 /* Create an empty sub-directory or small file in the current directory */
-int64_t create_entry(char *return_name)
+static int64_t create_entry(char *return_name)
 {
 	int fd;
 	char name[256];
@@ -217,7 +217,7 @@ int64_t create_entry(char *return_name)
 }
 
 /* Remove a random file of empty sub-directory from the current directory */
-int64_t remove_entry(void)
+static int64_t remove_entry(void)
 {
 	DIR *dir;
 	struct dirent *entry;
@@ -291,7 +291,7 @@ int64_t remove_entry(void)
 	return result;
 }
 
-void rndrm99(void)
+static void rndrm99(void)
 {
 	int64_t repeat, loop_cnt;
 	int64_t size, this_size;
@@ -374,14 +374,14 @@ void rndrm99(void)
 
 /* Title of this test */
 
-const char *rndrm99_get_title(void)
+static const char *rndrm99_get_title(void)
 {
 	return "Randomly create and remove directories and files";
 }
 
 /* Description of this test */
 
-const char *rndrm99_get_description(void)
+static const char *rndrm99_get_description(void)
 {
 	return
 		"Create a directory named rndrm99_test_dir_pid, where " \
diff --git a/tests/fs-tests/stress/atoms/rndwrite00.c b/tests/fs-tests/stress/atoms/rndwrite00.c
index 3c38e43..7dba6be 100644
--- a/tests/fs-tests/stress/atoms/rndwrite00.c
+++ b/tests/fs-tests/stress/atoms/rndwrite00.c
@@ -52,7 +52,7 @@ static void check_file(int fd, char *data, size_t length)
 	CHECK(n == length);
 }
 
-void rndwrite00(void)
+static void rndwrite00(void)
 {
 	int fd;
 	pid_t pid;
@@ -143,14 +143,14 @@ void rndwrite00(void)
 
 /* Title of this test */
 
-const char *rndwrite00_get_title(void)
+static const char *rndwrite00_get_title(void)
 {
 	return "Randomly write a large test file";
 }
 
 /* Description of this test */
 
-const char *rndwrite00_get_description(void)
+static const char *rndwrite00_get_description(void)
 {
 	return
 		"Create a file named rndwrite00_test_file_pid, where " \
diff --git a/tests/fs-tests/stress/atoms/stress_1.c b/tests/fs-tests/stress/atoms/stress_1.c
index 86f94c2..678f8fa 100644
--- a/tests/fs-tests/stress/atoms/stress_1.c
+++ b/tests/fs-tests/stress/atoms/stress_1.c
@@ -32,7 +32,7 @@
 
 #define WRITE_BUFFER_SIZE 32768
 
-void stress_1(void)
+static void stress_1(void)
 {
 	int fd, i;
 	pid_t pid;
@@ -71,14 +71,14 @@ void stress_1(void)
 
 /* Title of this test */
 
-const char *stress_1_get_title(void)
+static const char *stress_1_get_title(void)
 {
 	return "Create / overwrite a large file";
 }
 
 /* Description of this test */
 
-const char *stress_1_get_description(void)
+static const char *stress_1_get_description(void)
 {
 	return
 		"Create a file named stress_1_test_file_pid, " \
diff --git a/tests/fs-tests/stress/atoms/stress_2.c b/tests/fs-tests/stress/atoms/stress_2.c
index a9bc31a..5dea1b7 100644
--- a/tests/fs-tests/stress/atoms/stress_2.c
+++ b/tests/fs-tests/stress/atoms/stress_2.c
@@ -32,7 +32,7 @@
 
 #define WRITE_BUFFER_SIZE 32768
 
-void stress_2(void)
+static void stress_2(void)
 {
 	int fd, i;
 	pid_t pid;
@@ -77,14 +77,14 @@ void stress_2(void)
 
 /* Title of this test */
 
-const char *stress_2_get_title(void)
+static const char *stress_2_get_title(void)
 {
 	return "Create / overwrite a large deleted file";
 }
 
 /* Description of this test */
 
-const char *stress_2_get_description(void)
+static const char *stress_2_get_description(void)
 {
 	return
 		"Create a file named stress_2_test_file. " \
diff --git a/tests/fs-tests/stress/atoms/stress_3.c b/tests/fs-tests/stress/atoms/stress_3.c
index 99fb05d..0272d52 100644
--- a/tests/fs-tests/stress/atoms/stress_3.c
+++ b/tests/fs-tests/stress/atoms/stress_3.c
@@ -32,7 +32,7 @@
 
 #define WRITE_BUFFER_SIZE 32768
 
-void stress_3(void)
+static void stress_3(void)
 {
 	int fd, i;
 	pid_t pid;
@@ -79,14 +79,14 @@ void stress_3(void)
 
 /* Title of this test */
 
-const char *stress_3_get_title(void)
+static const char *stress_3_get_title(void)
 {
 	return "Create a file with a large hole and fill it";
 }
 
 /* Description of this test */
 
-const char *stress_3_get_description(void)
+static const char *stress_3_get_description(void)
 {
 	return
 		"Create a file named stress_3_test_file_pid, " \
diff --git a/tests/fs-tests/utils/fstest_monitor.c b/tests/fs-tests/utils/fstest_monitor.c
index 298ee26..58946cc 100644
--- a/tests/fs-tests/utils/fstest_monitor.c
+++ b/tests/fs-tests/utils/fstest_monitor.c
@@ -38,7 +38,7 @@ struct child_info {
 
 struct child_info *children = 0;
 
-void kill_children(void)
+static void kill_children(void)
 {
 	struct child_info *child;
 
@@ -57,7 +57,7 @@ void kill_children(void)
 	}
 }
 
-void add_child(pid_t child_pid)
+static void add_child(pid_t child_pid)
 {
 	struct child_info *child;
 	size_t sz;
@@ -70,7 +70,7 @@ void add_child(pid_t child_pid)
 	children = child;
 }
 
-void mark_child_gone(pid_t child_pid)
+static void mark_child_gone(pid_t child_pid)
 {
 	struct child_info *child;
 
@@ -84,7 +84,7 @@ void mark_child_gone(pid_t child_pid)
 	}
 }
 
-int have_children(void)
+static int have_children(void)
 {
 	struct child_info *child;
 
@@ -97,7 +97,7 @@ int have_children(void)
 	return 0;
 }
 
-int parse_command_line(char *cmdline, int *pargc, char ***pargv)
+static int parse_command_line(char *cmdline, int *pargc, char ***pargv)
 {
 	char **tmp;
 	char *p, *v, *q;
@@ -175,7 +175,7 @@ int parse_command_line(char *cmdline, int *pargc, char ***pargv)
 	return 0;
 }
 
-void signal_handler(int signum)
+static void signal_handler(int signum)
 {
 	kill_children();
 }
@@ -183,7 +183,7 @@ void signal_handler(int signum)
 int result = 0;
 int alarm_gone_off = 0;
 
-void alarm_handler(int signum)
+static void alarm_handler(int signum)
 {
 	if (!result)
 		alarm_gone_off = 1;
diff --git a/tests/jittertest/JitterTest.c b/tests/jittertest/JitterTest.c
index 1d74b8a..0364a00 100644
--- a/tests/jittertest/JitterTest.c
+++ b/tests/jittertest/JitterTest.c
@@ -451,7 +451,7 @@ void SignalHandler(
   stats reset by doing a (any) write to the /proc/profile
   file.
  */
-void doGrabKProfile(int jitterusec, char *fileName)
+static void doGrabKProfile(int jitterusec, char *fileName)
 {
     int fdSnapshot;
     int fdProfile;
@@ -498,7 +498,7 @@ void doGrabKProfile(int jitterusec, char *fileName)
 /*
   Call this routine to clear the kernel profiling buffer /proc/profile
 */
-void clearProfileBuf(void){
+static void clearProfileBuf(void){
 
 
   int fdProfile;
diff --git a/tests/jittertest/plotJittervsFill.c b/tests/jittertest/plotJittervsFill.c
index f9427f1..8d71a33 100644
--- a/tests/jittertest/plotJittervsFill.c
+++ b/tests/jittertest/plotJittervsFill.c
@@ -75,7 +75,7 @@ static int Debug = 0; /* Debug level. Each "-d" on the cmd line increases the le
 
 #define MIN_JITTER_THRESHOLD 1 /* ms minimum jitter threshold */
 
-void PrintHelpInfo(void)
+static void PrintHelpInfo(void)
 {
     printf("Usage: plotJittervsFill [options] -f [--file] <input log file name> -t [--jitter_threshold] <jitter threshold in ms>\n");
     printf("[options]:\n-v [--version] Print version and exit\n");
@@ -90,7 +90,7 @@ void PrintHelpInfo(void)
  *  This function handles the command line arguments.
  *  output: stack size
  ***********************************************************************/
-void HandleCmdLineArgs(
+static void HandleCmdLineArgs(
     int argc,                       /* number of command-line arguments */
     char *argv[])                   /* ptrs to command-line arguments   */
 {
-- 
2.12.3

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

* [PATCH 7/9] Remove unused variables and functions
  2017-06-28 11:08 [PATCH 0/9] mtd-utils: various cleanups, enable compiler warnings David Oberhollenzer
                   ` (5 preceding siblings ...)
  2017-06-28 11:08 ` [PATCH 6/9] Eliminate warnings about missing prototypes David Oberhollenzer
@ 2017-06-28 11:08 ` David Oberhollenzer
  2017-06-28 11:08 ` [PATCH 8/9] Silence warnings about unused arguments David Oberhollenzer
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: David Oberhollenzer @ 2017-06-28 11:08 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Oberhollenzer

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
---
 lib/libiniparser.c      | 18 ------------------
 nand-utils/nandwrite.c  |  2 --
 tests/ubi-tests/integ.c |  2 --
 3 files changed, 22 deletions(-)

diff --git a/lib/libiniparser.c b/lib/libiniparser.c
index ba70c08..a6ddcc7 100644
--- a/lib/libiniparser.c
+++ b/lib/libiniparser.c
@@ -389,24 +389,6 @@ int iniparser_find_entry(
 
 /*-------------------------------------------------------------------------*/
 /**
-  @brief    Set an entry in a dictionary.
-  @param    ini     Dictionary to modify.
-  @param    entry   Entry to modify (entry name)
-  @param    val     New value to associate to the entry.
-  @return   int 0 if Ok, -1 otherwise.
-
-  If the given entry can be found in the dictionary, it is modified to
-  contain the provided value. If it cannot be found, -1 is returned.
-  It is Ok to set val to NULL.
- */
-/*--------------------------------------------------------------------------*/
-int iniparser_set(dictionary * ini, char * entry, char * val)
-{
-    return dictionary_set(ini, strlwc(entry), val) ;
-}
-
-/*-------------------------------------------------------------------------*/
-/**
   @brief    Delete an entry in a dictionary
   @param    ini     Dictionary to modify
   @param    entry   Entry to delete (entry name)
diff --git a/nand-utils/nandwrite.c b/nand-utils/nandwrite.c
index f29fc67..8f21593 100644
--- a/nand-utils/nandwrite.c
+++ b/nand-utils/nandwrite.c
@@ -261,8 +261,6 @@ static int is_virt_block_bad(struct mtd_dev_info *mtd, int fd,
  */
 int main(int argc, char * const argv[])
 {
-	int allffs;
-	int ii;
 	int fd = -1;
 	int ifd = -1;
 	int pagelen;
diff --git a/tests/ubi-tests/integ.c b/tests/ubi-tests/integ.c
index 94d546b..26c2ce5 100644
--- a/tests/ubi-tests/integ.c
+++ b/tests/ubi-tests/integ.c
@@ -561,8 +561,6 @@ static void get_ubi_devices_info(void)
 
 static void load_ubi(void)
 {
-	int ret;
-
 	if (system("modprobe -r ubi"))
 		error_exit("Failed to unload UBI module");
 
-- 
2.12.3

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

* [PATCH 8/9] Silence warnings about unused arguments
  2017-06-28 11:08 [PATCH 0/9] mtd-utils: various cleanups, enable compiler warnings David Oberhollenzer
                   ` (6 preceding siblings ...)
  2017-06-28 11:08 ` [PATCH 7/9] Remove unused variables and functions David Oberhollenzer
@ 2017-06-28 11:08 ` David Oberhollenzer
  2017-06-28 11:08 ` [PATCH 9/9] Add const modifier to read only strings and string constants David Oberhollenzer
  2017-07-03  8:35 ` [PATCH 0/9] mtd-utils: various cleanups, enable compiler warnings David Oberhollenzer
  9 siblings, 0 replies; 11+ messages in thread
From: David Oberhollenzer @ 2017-06-28 11:08 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Oberhollenzer

This patch deals with functions that need to have a certain signature,
but don't make use of all the arguments (e.g. signal handlers).

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
---
 lib/execinfo.c                        | 3 +++
 tests/fs-tests/utils/fstest_monitor.c | 2 ++
 tests/jittertest/JitterTest.c         | 6 ++++++
 3 files changed, 11 insertions(+)

diff --git a/lib/execinfo.c b/lib/execinfo.c
index a59f6a9..499b0c3 100644
--- a/lib/execinfo.c
+++ b/lib/execinfo.c
@@ -7,6 +7,7 @@
 int backtrace(void **buffer, int size)
 {
 	void *addr = __builtin_return_address(0);
+	(void)buffer; (void)size;
 
 	errmsg("backtrace() is not implemented. Called from %p", addr);
 	return 0;
@@ -14,12 +15,14 @@ int backtrace(void **buffer, int size)
 
 char **backtrace_symbols(void *const *buffer, int size)
 {
+	(void)buffer; (void)size;
 	errmsg("backtrace_symbols() is not implemented");
 	return NULL;
 }
 
 void backtrace_symbols_fd(void *const *buffer, int size, int fd)
 {
+	(void)buffer; (void)size; (void)fd;
 	errmsg("backtrace_symbols_fd() is not implemented");
 }
 #endif /* !HAVE_EXECINFO_H */
diff --git a/tests/fs-tests/utils/fstest_monitor.c b/tests/fs-tests/utils/fstest_monitor.c
index 58946cc..afb951b 100644
--- a/tests/fs-tests/utils/fstest_monitor.c
+++ b/tests/fs-tests/utils/fstest_monitor.c
@@ -177,6 +177,7 @@ static int parse_command_line(char *cmdline, int *pargc, char ***pargv)
 
 static void signal_handler(int signum)
 {
+	(void)signum;
 	kill_children();
 }
 
@@ -185,6 +186,7 @@ int alarm_gone_off = 0;
 
 static void alarm_handler(int signum)
 {
+	(void)signum;
 	if (!result)
 		alarm_gone_off = 1;
 	kill_children();
diff --git a/tests/jittertest/JitterTest.c b/tests/jittertest/JitterTest.c
index 0364a00..4627fb0 100644
--- a/tests/jittertest/JitterTest.c
+++ b/tests/jittertest/JitterTest.c
@@ -426,6 +426,8 @@ void SignalHandler(
     char tmpBuf[200];
 
     /* Note sigNum not used. */
+    (void)sigNum;
+
     printf("Ctrl+C detected. Worst Jitter time was:%fms.\nJitterTest exiting.\n",
            (float)LastMaxDiff/1000.0);
 
@@ -458,6 +460,8 @@ static void doGrabKProfile(int jitterusec, char *fileName)
     int readBytes;
     char readBuf[4096];
 
+    (void)jitterusec;
+
     if((fdSnapshot = open(fileName, O_WRONLY | O_CREAT, S_IRWXU)) <= 0)
     {
         fprintf(stderr, "Could not open file %s.\n", fileName);
@@ -553,6 +557,8 @@ void AlarmHandler(
 				   if invoked < 1sec apart.
 				*/
 
+    (void)sigNum;
+
     if (gettimeofday(&CurrTimeVal, NULL) == (int) 0) {
 
         /*----------------------------------------------------------------
-- 
2.12.3

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

* [PATCH 9/9] Add const modifier to read only strings and string constants
  2017-06-28 11:08 [PATCH 0/9] mtd-utils: various cleanups, enable compiler warnings David Oberhollenzer
                   ` (7 preceding siblings ...)
  2017-06-28 11:08 ` [PATCH 8/9] Silence warnings about unused arguments David Oberhollenzer
@ 2017-06-28 11:08 ` David Oberhollenzer
  2017-07-03  8:35 ` [PATCH 0/9] mtd-utils: various cleanups, enable compiler warnings David Oberhollenzer
  9 siblings, 0 replies; 11+ messages in thread
From: David Oberhollenzer @ 2017-06-28 11:08 UTC (permalink / raw)
  To: linux-mtd; +Cc: David Oberhollenzer

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
---
 tests/fs-tests/lib/tests.c             | 16 ++++++++--------
 tests/fs-tests/lib/tests.h             |  6 +++---
 tests/fs-tests/simple/ftrunc.c         |  2 +-
 tests/fs-tests/stress/atoms/stress_2.c |  2 +-
 tests/fs-tests/utils/free_space.c      |  2 +-
 5 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/tests/fs-tests/lib/tests.c b/tests/fs-tests/lib/tests.c
index 8d4d83a..d1a2e0c 100644
--- a/tests/fs-tests/lib/tests.c
+++ b/tests/fs-tests/lib/tests.c
@@ -40,9 +40,9 @@
 
 #include "tests.h"
 
-char *tests_file_system_mount_dir = TESTS_DEFAULT_FILE_SYSTEM_MOUNT_DIR;
+const char *tests_file_system_mount_dir = TESTS_DEFAULT_FILE_SYSTEM_MOUNT_DIR;
 
-char *tests_file_system_type = TESTS_DEFAULT_FILE_SYSTEM_TYPE;
+const char *tests_file_system_type = TESTS_DEFAULT_FILE_SYSTEM_TYPE;
 
 int tests_ok_to_sync = 0; /* Whether to use fsync */
 
@@ -62,7 +62,7 @@ int64_t tests_repeat_parameter = 0;
 int64_t tests_sleep_parameter = 0;
 
 /* Program name from argv[0] */
-char *program_name = "unknown";
+const char *program_name = "unknown";
 
 /* General purpose test parameter to specify a file should be unlinked.
    May be used by different tests in different ways or not at all. */
@@ -1058,8 +1058,8 @@ void tests_remount(void)
 {
 	int err;
 	struct mntent mount_info;
-	char *source, *target, *filesystemtype, *data;
-	char cwd[4096];
+	const char *source, *target, *filesystemtype;
+	char cwd[4096], *data;
 	unsigned long mountflags, flags;
 	unsigned int rorw1, um, um_ro, um_rorw, rorw2;
 
@@ -1152,9 +1152,9 @@ void tests_remount(void)
 static void tests_mnt(int mnt)
 {
 	static struct mntent mount_info;
-	char *source;
-	char *target;
-	char *filesystemtype;
+	const char *source;
+	const char *target;
+	const char *filesystemtype;
 	unsigned long mountflags;
 	char *data;
 	static char cwd[4096];
diff --git a/tests/fs-tests/lib/tests.h b/tests/fs-tests/lib/tests.h
index 01849bc..6bcfd83 100644
--- a/tests/fs-tests/lib/tests.h
+++ b/tests/fs-tests/lib/tests.h
@@ -164,9 +164,9 @@ int tests_fs_is_currfs(void);
 /* Concatenate a pid to a string in a signal safe way */
 void tests_cat_pid(char *buf, const char *name, pid_t pid);
 
-extern char *tests_file_system_mount_dir;
+extern const char *tests_file_system_mount_dir;
 
-extern char *tests_file_system_type;
+extern const char *tests_file_system_type;
 
 /* General purpose test parameter to specify some aspect of test size.
    May be used by different tests in different ways.
@@ -200,7 +200,7 @@ extern int tests_delete_flag;
 extern int tests_hole_flag;
 
 /* Program name from argv[0] */
-extern char *program_name;
+extern const char *program_name;
 
 /* Maximum file name length of test file system (from statfs) */
 extern long tests_max_fname_len;
diff --git a/tests/fs-tests/simple/ftrunc.c b/tests/fs-tests/simple/ftrunc.c
index 2df404b..52b660b 100644
--- a/tests/fs-tests/simple/ftrunc.c
+++ b/tests/fs-tests/simple/ftrunc.c
@@ -39,7 +39,7 @@ static void ftrunc(void)
 	ssize_t written;
 	int64_t remains;
 	size_t block;
-	char *file_name;
+	const char *file_name;
 	off_t actual;
 	char buf[WRITE_BUFFER_SIZE];
 
diff --git a/tests/fs-tests/stress/atoms/stress_2.c b/tests/fs-tests/stress/atoms/stress_2.c
index 5dea1b7..bd53ad3 100644
--- a/tests/fs-tests/stress/atoms/stress_2.c
+++ b/tests/fs-tests/stress/atoms/stress_2.c
@@ -40,7 +40,7 @@ static void stress_2(void)
 	int64_t remains;
 	int64_t repeat;
 	size_t block;
-	char *file_name;
+	const char *file_name;
 	char buf[WRITE_BUFFER_SIZE];
 
 	file_name = "stress_2_test_file";
diff --git a/tests/fs-tests/utils/free_space.c b/tests/fs-tests/utils/free_space.c
index 88036aa..3421e7d 100644
--- a/tests/fs-tests/utils/free_space.c
+++ b/tests/fs-tests/utils/free_space.c
@@ -25,7 +25,7 @@
 
 int main(int argc, char *argv[])
 {
-	char *dir_name = ".";
+	const char *dir_name = ".";
 	uint64_t free_space;
 	struct statvfs fs_info;
 
-- 
2.12.3

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

* Re: [PATCH 0/9] mtd-utils: various cleanups, enable compiler warnings
  2017-06-28 11:08 [PATCH 0/9] mtd-utils: various cleanups, enable compiler warnings David Oberhollenzer
                   ` (8 preceding siblings ...)
  2017-06-28 11:08 ` [PATCH 9/9] Add const modifier to read only strings and string constants David Oberhollenzer
@ 2017-07-03  8:35 ` David Oberhollenzer
  9 siblings, 0 replies; 11+ messages in thread
From: David Oberhollenzer @ 2017-07-03  8:35 UTC (permalink / raw)
  To: linux-mtd

Applied to mtd-utils.git

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

end of thread, other threads:[~2017-07-03  8:35 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-28 11:08 [PATCH 0/9] mtd-utils: various cleanups, enable compiler warnings David Oberhollenzer
2017-06-28 11:08 ` [PATCH 1/9] Replace defunct ubifs_assert David Oberhollenzer
2017-06-28 11:08 ` [PATCH 2/9] Restructure autoconf configure.ac David Oberhollenzer
2017-06-28 11:08 ` [PATCH 3/9] Use autoconf header detection correctly for libmissing David Oberhollenzer
2017-06-28 11:08 ` [PATCH 4/9] Move libfec declarations to public header in global include directory David Oberhollenzer
2017-06-28 11:08 ` [PATCH 5/9] Enable compiler warnings David Oberhollenzer
2017-06-28 11:08 ` [PATCH 6/9] Eliminate warnings about missing prototypes David Oberhollenzer
2017-06-28 11:08 ` [PATCH 7/9] Remove unused variables and functions David Oberhollenzer
2017-06-28 11:08 ` [PATCH 8/9] Silence warnings about unused arguments David Oberhollenzer
2017-06-28 11:08 ` [PATCH 9/9] Add const modifier to read only strings and string constants David Oberhollenzer
2017-07-03  8:35 ` [PATCH 0/9] mtd-utils: various cleanups, enable compiler warnings David Oberhollenzer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.