2018-02-20 18:50:35

by Steve Dickson

[permalink] [raw]
Subject: [PATCH 0/7] nfs-utils: Use -Werror warning flags to clean up the code.

I received a patch that tried to turns on some
of these -Werror flags but could not get passed
the warning that were being generated by
the rpcgen code.

After taking care of the rpcgen warnings, I
took over the patch and finished it off.

The warning flags I choose to use are pattern
after the list in the libostree and the
systemd list.

Steve Dickson (7):
configure.ac: clean up
Removed missing-prototypes warnings.
Removed format-overflow=2 warnings
Removed format=2 warnings
Removed undef warnings
Removed missing-include-dirs warnings
Added more -Werror= warning flags

configure.ac | 41 ++++++++++++++++++++++++--------------
support/misc/mountpoint.c | 1 +
support/nfs/atomicio.c | 2 ++
support/nfs/cacheio.c | 2 +-
support/nfs/closeall.c | 2 ++
support/nfs/rpcmisc.c | 1 +
support/nfs/strlcat.c | 2 ++
support/nfs/strlcpy.c | 2 ++
support/nfs/svc_socket.c | 2 ++
support/nfs/wildmat.c | 7 +++++++
support/nfsidmap/libnfsidmap.c | 3 ++-
support/nfsidmap/nfsidmap_plugin.h | 1 +
support/nfsidmap/nss.c | 2 +-
systemd/systemd.c | 1 +
utils/blkmapd/device-discovery.c | 10 +++++-----
utils/blkmapd/dm-device.c | 2 +-
utils/gssd/Makefile.am | 2 ++
utils/gssd/err_util.c | 1 +
utils/gssd/gss_names.c | 1 +
utils/gssd/gssd_proc.c | 4 ++--
utils/gssd/krb5_util.c | 6 +++---
utils/gssd/svcgssd.c | 4 ++--
utils/gssd/svcgssd_mech2file.c | 1 +
utils/idmapd/Makefile.am | 2 ++
utils/idmapd/idmapd.c | 4 ++--
utils/mount/configfile.c | 4 ++++
utils/mount/mount_libmount.c | 2 ++
utils/mount/stropts.c | 2 ++
utils/mountd/svc_run.c | 1 +
utils/nfsdcltrack/sqlite.c | 3 ++-
utils/nfsidmap/Makefile.am | 2 ++
utils/nfsstat/nfsstat.c | 4 +++-
utils/statd/svc_run.c | 1 +
33 files changed, 90 insertions(+), 35 deletions(-)

--
2.14.3



2018-02-20 18:50:36

by Steve Dickson

[permalink] [raw]
Subject: [PATCH 2/7] Removed missing-prototypes warnings.

Added the -Werror=missing-prototypes warning flag
then cleaned up the mess.

Signed-off-by: Steve Dickson <[email protected]>
---
configure.ac | 4 +++-
support/misc/mountpoint.c | 1 +
support/nfs/atomicio.c | 2 ++
support/nfs/closeall.c | 2 ++
support/nfs/rpcmisc.c | 1 +
support/nfs/strlcat.c | 2 ++
support/nfs/strlcpy.c | 2 ++
support/nfs/svc_socket.c | 2 ++
support/nfs/wildmat.c | 1 +
support/nfsidmap/libnfsidmap.c | 3 ++-
support/nfsidmap/nfsidmap_plugin.h | 1 +
support/nfsidmap/nss.c | 2 +-
systemd/systemd.c | 1 +
utils/blkmapd/device-discovery.c | 10 +++++-----
utils/blkmapd/dm-device.c | 2 +-
utils/gssd/err_util.c | 1 +
utils/gssd/gss_names.c | 1 +
utils/gssd/gssd_proc.c | 4 ++--
utils/gssd/svcgssd.c | 4 ++--
utils/gssd/svcgssd_mech2file.c | 1 +
utils/idmapd/idmapd.c | 2 +-
utils/mount/configfile.c | 4 ++++
utils/mount/mount_libmount.c | 2 ++
utils/mountd/svc_run.c | 1 +
utils/nfsdcltrack/sqlite.c | 3 ++-
utils/nfsstat/nfsstat.c | 2 +-
utils/statd/svc_run.c | 1 +
27 files changed, 46 insertions(+), 16 deletions(-)

diff --git a/configure.ac b/configure.ac
index b3f6b97..31990c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -547,7 +547,9 @@ my_am_cflags="\
-pipe \
-Wall \
-Wextra \
- -Wstrict-prototypes \
+ -Werror=strict-prototypes \
+ -Werror=missing-prototypes \
+ -Werror=missing-declarations \
"

AC_SUBST([AM_CFLAGS], ["$my_am_cflags"])
diff --git a/support/misc/mountpoint.c b/support/misc/mountpoint.c
index a72fb92..9f9ce44 100644
--- a/support/misc/mountpoint.c
+++ b/support/misc/mountpoint.c
@@ -6,6 +6,7 @@
#include <string.h>
#include "xcommon.h"
#include <sys/stat.h>
+#include "misc.h"

int
is_mountpoint(char *path)
diff --git a/support/nfs/atomicio.c b/support/nfs/atomicio.c
index aa819ca..0e81838 100644
--- a/support/nfs/atomicio.c
+++ b/support/nfs/atomicio.c
@@ -28,6 +28,8 @@
#include <unistd.h>
#include <errno.h>

+#include "nfslib.h"
+
/*
* ensure all of data on socket comes through. f==read || f==write
*/
diff --git a/support/nfs/closeall.c b/support/nfs/closeall.c
index a69bf35..e07253e 100644
--- a/support/nfs/closeall.c
+++ b/support/nfs/closeall.c
@@ -9,6 +9,8 @@
#include <dirent.h>
#include <errno.h>

+#include "nfslib.h"
+
void
closeall(int min)
{
diff --git a/support/nfs/rpcmisc.c b/support/nfs/rpcmisc.c
index ae2c0a6..abe89ba 100644
--- a/support/nfs/rpcmisc.c
+++ b/support/nfs/rpcmisc.c
@@ -32,6 +32,7 @@
#include <unistd.h>
#include <time.h>
#include "nfslib.h"
+#include "rpcmisc.h"

#if SIZEOF_SOCKLEN_T - 0 == 0
#define socklen_t int
diff --git a/support/nfs/strlcat.c b/support/nfs/strlcat.c
index daedd7a..0edee14 100644
--- a/support/nfs/strlcat.c
+++ b/support/nfs/strlcat.c
@@ -38,6 +38,8 @@ static char *rcsid = "$OpenBSD: strlcat.c,v 1.8 2001/05/13 15:40:15 deraadt Exp
#include "config.h"
#endif /* HAVE_CONFIG_H */

+#include "nfslib.h"
+
/*
* Appends src to string dst of size siz (unlike strncat, siz is the
* full size of dst, not space left). At most siz-1 characters
diff --git a/support/nfs/strlcpy.c b/support/nfs/strlcpy.c
index a2653ee..23e3ae9 100644
--- a/support/nfs/strlcpy.c
+++ b/support/nfs/strlcpy.c
@@ -38,6 +38,8 @@ static char *rcsid = "$OpenBSD: strlcpy.c,v 1.5 2001/05/13 15:40:16 deraadt Exp
#include "config.h"
#endif /* HAVE_CONFIG_H */

+#include "nfslib.h"
+
/*
* Copy src to string dst of size siz. At most siz-1 characters
* will be copied. Always NUL terminates (unless siz == 0).
diff --git a/support/nfs/svc_socket.c b/support/nfs/svc_socket.c
index 1fa0d15..1239712 100644
--- a/support/nfs/svc_socket.c
+++ b/support/nfs/svc_socket.c
@@ -25,6 +25,8 @@
#include <sys/fcntl.h>
#include <errno.h>
#include "xlog.h"
+#include "rpcmisc.h"
+#include "nfslib.h"

#include "config.h"

diff --git a/support/nfs/wildmat.c b/support/nfs/wildmat.c
index c5b4c78..2f40358 100644
--- a/support/nfs/wildmat.c
+++ b/support/nfs/wildmat.c
@@ -41,6 +41,7 @@
#endif

#include <ctype.h>
+#include "nfslib.h"

#define TRUE 1
#define FALSE 0
diff --git a/support/nfsidmap/libnfsidmap.c b/support/nfsidmap/libnfsidmap.c
index 3b44da6..d9d44de 100644
--- a/support/nfsidmap/libnfsidmap.c
+++ b/support/nfsidmap/libnfsidmap.c
@@ -64,6 +64,7 @@

#pragma GCC visibility push(hidden)

+void nfs4_cleanup_name_mapping(void);
static char *default_domain;
static struct mapping_plugin **nfs4_plugins = NULL;
static struct mapping_plugin **gss_plugins = NULL;
@@ -327,7 +328,7 @@ out:
return ret;
}

-char * get_default_domain(void)
+static char *get_default_domain(void)
{
int ret;

diff --git a/support/nfsidmap/nfsidmap_plugin.h b/support/nfsidmap/nfsidmap_plugin.h
index e19efe5..708874c 100644
--- a/support/nfsidmap/nfsidmap_plugin.h
+++ b/support/nfsidmap/nfsidmap_plugin.h
@@ -51,6 +51,7 @@ struct trans_func {

extern int idmap_verbosity;
extern nfs4_idmap_log_function_t idmap_log_func;
+struct trans_func *libnfsidmap_plugin_init(void);

/* Level zero always prints, others print depending on verbosity level */
#define IDMAP_LOG(LVL, MSG) \
diff --git a/support/nfsidmap/nss.c b/support/nfsidmap/nss.c
index 6f024dc..65625a8 100644
--- a/support/nfsidmap/nss.c
+++ b/support/nfsidmap/nss.c
@@ -436,7 +436,7 @@ out:
return err;
}

-int nss_gss_princ_to_grouplist(char *secname, char *princ,
+static int nss_gss_princ_to_grouplist(char *secname, char *princ,
gid_t *groups, int *ngroups,
extra_mapping_params **UNUSED(ex))
{
diff --git a/systemd/systemd.c b/systemd/systemd.c
index 17820d4..c7bdb4d 100644
--- a/systemd/systemd.c
+++ b/systemd/systemd.c
@@ -8,6 +8,7 @@
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
+#include "systemd.h"

static const char hex[16] =
{
diff --git a/utils/blkmapd/device-discovery.c b/utils/blkmapd/device-discovery.c
index cae8c8d..b71c949 100644
--- a/utils/blkmapd/device-discovery.c
+++ b/utils/blkmapd/device-discovery.c
@@ -81,7 +81,7 @@ int bl_watch_fd, bl_pipe_fd, nfs_pipedir_wfd, rpc_pipedir_wfd;
int pidfd = -1;


-struct bl_disk_path *bl_get_path(const char *filepath,
+static struct bl_disk_path *bl_get_path(const char *filepath,
struct bl_disk_path *paths)
{
struct bl_disk_path *tmp = paths;
@@ -103,7 +103,7 @@ struct bl_disk_path *bl_get_path(const char *filepath,
* exist for each multipath device. If not, active device path will be
* chosen for device creation.
*/
-int bl_update_path(enum bl_path_state_e state, struct bl_disk *disk)
+static int bl_update_path(enum bl_path_state_e state, struct bl_disk *disk)
{
struct bl_disk_path *valid_path = disk->valid_path;

@@ -112,7 +112,7 @@ int bl_update_path(enum bl_path_state_e state, struct bl_disk *disk)
return 1;
}

-void bl_release_disk(void)
+static void bl_release_disk(void)
{
struct bl_disk *disk;
struct bl_disk_path *path = NULL;
@@ -133,7 +133,7 @@ void bl_release_disk(void)
}
}

-void bl_add_disk(char *filepath)
+static void bl_add_disk(char *filepath)
{
struct bl_disk *disk = NULL;
int fd = 0;
@@ -435,7 +435,7 @@ static int bl_event_helper(void)
return ret;
}

-void sig_die(int signal)
+static void sig_die(int signal)
{
if (pidfd >= 0) {
close(pidfd);
diff --git a/utils/blkmapd/dm-device.c b/utils/blkmapd/dm-device.c
index 24ffcbf..f2d4de4 100644
--- a/utils/blkmapd/dm-device.c
+++ b/utils/blkmapd/dm-device.c
@@ -210,7 +210,7 @@ static int dm_device_remove_byname(const char *dev_name)
return ret;
}

-int dm_device_remove(uint64_t dev)
+static int dm_device_remove(uint64_t dev)
{
struct dm_task *dmt;
struct dm_names *dmnames;
diff --git a/utils/gssd/err_util.c b/utils/gssd/err_util.c
index fe09eda..2b1132a 100644
--- a/utils/gssd/err_util.c
+++ b/utils/gssd/err_util.c
@@ -36,6 +36,7 @@
#include <stdarg.h>
#include <string.h>
#include "xlog.h"
+#include "err_util.h"

static int verbosity = 0;
static int fg = 0;
diff --git a/utils/gssd/gss_names.c b/utils/gssd/gss_names.c
index 047069d..2a7f3a1 100644
--- a/utils/gssd/gss_names.c
+++ b/utils/gssd/gss_names.c
@@ -51,6 +51,7 @@

#include "svcgssd.h"
#include "gss_util.h"
+#include "gss_names.h"
#include "err_util.h"
#include "context.h"
#include "misc.h"
diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c
index 4fc81c3..ce73777 100644
--- a/utils/gssd/gssd_proc.c
+++ b/utils/gssd/gssd_proc.c
@@ -473,7 +473,7 @@ change_identity(uid_t uid)
return 0;
}

-AUTH *
+static AUTH *
krb5_not_machine_creds(struct clnt_info *clp, uid_t uid, char *tgtname,
int *downcall_err, int *chg_err, CLIENT **rpc_clnt)
{
@@ -519,7 +519,7 @@ out:
return auth;
}

-AUTH *
+static AUTH *
krb5_use_machine_creds(struct clnt_info *clp, uid_t uid, char *tgtname,
char *service, CLIENT **rpc_clnt)
{
diff --git a/utils/gssd/svcgssd.c b/utils/gssd/svcgssd.c
index 23f0c0b..8e918cc 100644
--- a/utils/gssd/svcgssd.c
+++ b/utils/gssd/svcgssd.c
@@ -65,7 +65,7 @@

struct state_paths etab;

-void
+static void
sig_die(int signal)
{
/* destroy krb5 machine creds */
@@ -73,7 +73,7 @@ sig_die(int signal)
exit(0);
}

-void
+static void
sig_hup(int signal)
{
/* don't exit on SIGHUP */
diff --git a/utils/gssd/svcgssd_mech2file.c b/utils/gssd/svcgssd_mech2file.c
index ecd908b..c26b435 100644
--- a/utils/gssd/svcgssd_mech2file.c
+++ b/utils/gssd/svcgssd_mech2file.c
@@ -41,6 +41,7 @@
#include <gssapi/gssapi.h>
#include <string.h>

+char * mech2file(gss_OID mech);

#define g_OID_equal(o1,o2) \
(((o1)->length == (o2)->length) && \
diff --git a/utils/idmapd/idmapd.c b/utils/idmapd/idmapd.c
index 2b9ecea..c7e75bd 100644
--- a/utils/idmapd/idmapd.c
+++ b/utils/idmapd/idmapd.c
@@ -196,7 +196,7 @@ flush_nfsd_idmap_cache(void)
return ret;
}

-void usage(char *progname)
+static void usage(char *progname)
{
fprintf(stderr, "Usage: %s [-hfvCS] [-p path] [-c path]\n",
basename(progname));
diff --git a/utils/mount/configfile.c b/utils/mount/configfile.c
index 64688bf..b48b25e 100644
--- a/utils/mount/configfile.c
+++ b/utils/mount/configfile.c
@@ -35,6 +35,10 @@
#include "network.h"
#include "conffile.h"

+char *mountopts_convert(char *value);
+char *is_alias(char *opt);
+char *conf_get_mntopts(char *spec, char *mount_point, char *mount_opts);
+
#define KBYTES(x) ((x) * (1024))
#define MEGABYTES(x) ((x) * (1048576))
#define GIGABYTES(x) ((x) * (1073741824))
diff --git a/utils/mount/mount_libmount.c b/utils/mount/mount_libmount.c
index 2d40657..aa4ac5c 100644
--- a/utils/mount/mount_libmount.c
+++ b/utils/mount/mount_libmount.c
@@ -45,6 +45,8 @@
#include "error.h"
#include "utils.h"

+char *retrieve_mount_options(struct libmnt_fs *fs);
+
char *progname;
int nfs_mount_data_version;
int verbose;
diff --git a/utils/mountd/svc_run.c b/utils/mountd/svc_run.c
index a572441..41b96d7 100644
--- a/utils/mountd/svc_run.c
+++ b/utils/mountd/svc_run.c
@@ -57,6 +57,7 @@
#include <rpc/rpc_com.h>
#endif

+void my_svc_run(void);
void cache_set_fds(fd_set *fdset);
int cache_process_req(fd_set *readfds);

diff --git a/utils/nfsdcltrack/sqlite.c b/utils/nfsdcltrack/sqlite.c
index 1552eba..c59f777 100644
--- a/utils/nfsdcltrack/sqlite.c
+++ b/utils/nfsdcltrack/sqlite.c
@@ -51,6 +51,7 @@
#include <linux/limits.h>

#include "xlog.h"
+#include "sqlite.h"

#define CLTRACK_SQLITE_LATEST_SCHEMA_VERSION 2

@@ -203,7 +204,7 @@ rollback:
* then insert schema version into the parameters table and commit the
* transaction. On any error, rollback the transaction.
*/
-int
+static int
sqlite_maindb_init_v2(void)
{
int ret, ret2;
diff --git a/utils/nfsstat/nfsstat.c b/utils/nfsstat/nfsstat.c
index eddbe9a..43fe0a8 100644
--- a/utils/nfsstat/nfsstat.c
+++ b/utils/nfsstat/nfsstat.c
@@ -300,7 +300,7 @@ int versions[] = {
PRNT_V4
};

-void usage(char *name)
+static void usage(char *name)
{
printf("Usage: %s [OPTION]...\n\
\n\
diff --git a/utils/statd/svc_run.c b/utils/statd/svc_run.c
index 28c1ad6..d1dbd74 100644
--- a/utils/statd/svc_run.c
+++ b/utils/statd/svc_run.c
@@ -56,6 +56,7 @@
#include "statd.h"
#include "notlist.h"

+void my_svc_exit(void);
static int svc_stop = 0;

/*
--
2.14.3


2018-02-20 18:50:36

by Steve Dickson

[permalink] [raw]
Subject: [PATCH 1/7] configure.ac: clean up

Remove ARCHFLAGS since it has not been needed for years.

Signed-off-by: Steve Dickson <[email protected]>
---
configure.ac | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/configure.ac b/configure.ac
index 95991c1..b3f6b97 100644
--- a/configure.ac
+++ b/configure.ac
@@ -543,20 +543,12 @@ AC_SUBST(CXXFLAGS_FOR_BUILD)
AC_SUBST(CPPFLAGS_FOR_BUILD)
AC_SUBST(LDFLAGS_FOR_BUILD)

-dnl *************************************************************
-dnl Set up "global" CFLAGS
-dnl *************************************************************
-dnl Use architecture-specific compile flags
-dnl (We use $host and not $build in case we are cross-compiling)
-dnl *************************************************************
-dnl Note: we no longer have arch specific compile flags, but
-dnl the stub is left here in case they are needed one day.
-case $host in
- *)
- ARCHFLAGS="" ;;
-esac
-
-my_am_cflags="-Wall -Wextra -Wstrict-prototypes $ARCHFLAGS -pipe"
+my_am_cflags="\
+ -pipe \
+ -Wall \
+ -Wextra \
+ -Wstrict-prototypes \
+"

AC_SUBST([AM_CFLAGS], ["$my_am_cflags"])

--
2.14.3


2018-02-20 18:50:36

by Steve Dickson

[permalink] [raw]
Subject: [PATCH 4/7] Removed format=2 warnings

Added the -Werror=format=2 warning flag
and added couple pragma statments to ignore
the warning where it could not be avoided.

Signed-off-by: Steve Dickson <[email protected]>
---
configure.ac | 1 +
utils/mount/stropts.c | 2 ++
utils/nfsstat/nfsstat.c | 2 ++
3 files changed, 5 insertions(+)

diff --git a/configure.ac b/configure.ac
index 4f9d8c4..11b994b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -551,6 +551,7 @@ my_am_cflags="\
-Werror=missing-prototypes \
-Werror=missing-declarations \
-Werror=format-overflow=2 \
+ -Werror=format=2 \
"

AC_SUBST([AM_CFLAGS], ["$my_am_cflags"])
diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
index 1217823..777de39 100644
--- a/utils/mount/stropts.c
+++ b/utils/mount/stropts.c
@@ -761,9 +761,11 @@ static int nfs_do_mount_v4(struct nfsmount_info *mi,
fmt = "vers=%lu.%lu";
break;
}
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
snprintf(version_opt, sizeof(version_opt) - 1,
fmt, mi->version.major,
mi->version.minor);
+#pragma GCC diagnostic warning "-Wformat-nonliteral"

if (po_append(options, version_opt) == PO_FAILED) {
errno = EINVAL;
diff --git a/utils/nfsstat/nfsstat.c b/utils/nfsstat/nfsstat.c
index 43fe0a8..c779053 100644
--- a/utils/nfsstat/nfsstat.c
+++ b/utils/nfsstat/nfsstat.c
@@ -980,8 +980,10 @@ more_stats:
}
bufp = buf;
for (; curindex < numvals; curindex++) {
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
n = sscanf(bufp, fmt, &ip->valptr[curindex],
&numconsumed);
+#pragma GCC diagnostic warning "-Wformat-nonliteral"
if (n != 1)
break;
if (is_proc) {
--
2.14.3


2018-02-20 18:50:36

by Steve Dickson

[permalink] [raw]
Subject: [PATCH 5/7] Removed undef warnings

Added the -Werror=undef warning flag and
then fixed a few #ifdefs

Signed-off-by: Steve Dickson <[email protected]>
---
configure.ac | 1 +
utils/gssd/krb5_util.c | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 11b994b..2364275 100644
--- a/configure.ac
+++ b/configure.ac
@@ -552,6 +552,7 @@ my_am_cflags="\
-Werror=missing-declarations \
-Werror=format-overflow=2 \
-Werror=format=2 \
+ -Werror=undef \
"

AC_SUBST([AM_CFLAGS], ["$my_am_cflags"])
diff --git a/utils/gssd/krb5_util.c b/utils/gssd/krb5_util.c
index b64818a..6e61da2 100644
--- a/utils/gssd/krb5_util.c
+++ b/utils/gssd/krb5_util.c
@@ -333,7 +333,7 @@ gssd_get_single_krb5_cred(krb5_context context,
struct gssd_k5_kt_princ *ple,
int nocache)
{
-#if HAVE_KRB5_GET_INIT_CREDS_OPT_SET_ADDRESSLESS
+#ifdef HAVE_KRB5_GET_INIT_CREDS_OPT_SET_ADDRESSLESS
krb5_get_init_creds_opt *init_opts = NULL;
#else
krb5_get_init_creds_opt options;
@@ -372,7 +372,7 @@ gssd_get_single_krb5_cred(krb5_context context,
if ((krb5_unparse_name(context, ple->princ, &pname)))
pname = NULL;

-#if HAVE_KRB5_GET_INIT_CREDS_OPT_SET_ADDRESSLESS
+#ifdef HAVE_KRB5_GET_INIT_CREDS_OPT_SET_ADDRESSLESS
code = krb5_get_init_creds_opt_alloc(context, &init_opts);
if (code) {
k5err = gssd_k5_err_msg(context, code);
@@ -454,7 +454,7 @@ gssd_get_single_krb5_cred(krb5_context context,
code = 0;
printerr(2, "%s: principal '%s' ccache:'%s'\n", __func__, pname, cc_name);
out:
-#if HAVE_KRB5_GET_INIT_CREDS_OPT_SET_ADDRESSLESS
+#ifdef HAVE_KRB5_GET_INIT_CREDS_OPT_SET_ADDRESSLESS
if (init_opts)
krb5_get_init_creds_opt_free(context, init_opts);
#endif
--
2.14.3


2018-02-20 18:50:36

by Steve Dickson

[permalink] [raw]
Subject: [PATCH 6/7] Removed missing-include-dirs warnings

Added the -Werror=missing-include-dirs warning flag
then moved some include directories around.

Signed-off-by: Steve Dickson <[email protected]>
---
configure.ac | 3 ++-
support/nfs/wildmat.c | 6 ++++++
utils/gssd/Makefile.am | 2 ++
utils/idmapd/Makefile.am | 2 ++
utils/nfsidmap/Makefile.am | 2 ++
5 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 2364275..b849f43 100644
--- a/configure.ac
+++ b/configure.ac
@@ -448,7 +448,7 @@ if test -n "$path_plugins" ; then
fi
AM_CONDITIONAL(PATH_PLUGINS, test -n "$path_plugins")

-AC_SUBST(AM_CPPFLAGS, "$AM_CPPFLAGS -I../../support/nfsidmap")
+AC_SUBST(AM_CPPFLAGS, "$AM_CPPFLAGS")
AC_DEFINE([HAVE_NFS4_SET_DEBUG], 1,
[Bundled lib always has the `nfs4_set_debug' function.])

@@ -553,6 +553,7 @@ my_am_cflags="\
-Werror=format-overflow=2 \
-Werror=format=2 \
-Werror=undef \
+ -Werror=missing-include-dirs \
"

AC_SUBST([AM_CFLAGS], ["$my_am_cflags"])
diff --git a/support/nfs/wildmat.c b/support/nfs/wildmat.c
index 2f40358..437b2d1 100644
--- a/support/nfs/wildmat.c
+++ b/support/nfs/wildmat.c
@@ -43,8 +43,14 @@
#include <ctype.h>
#include "nfslib.h"

+#ifndef TRUE
#define TRUE 1
+#endif
+
+#ifndef FALSE
#define FALSE 0
+#endif
+
#define ABORT -1


diff --git a/utils/gssd/Makefile.am b/utils/gssd/Makefile.am
index beb3e8e..321046b 100644
--- a/utils/gssd/Makefile.am
+++ b/utils/gssd/Makefile.am
@@ -5,6 +5,8 @@ if CONFIG_SVCGSS
man8_MANS += svcgssd.man
endif

+AM_CPPFLAGS += -I ../../support/nfsidmap
+
RPCPREFIX = rpc.
KPREFIX = @kprefix@
sbin_PREFIXED = gssd
diff --git a/utils/idmapd/Makefile.am b/utils/idmapd/Makefile.am
index d768eec..e09e8c5 100644
--- a/utils/idmapd/Makefile.am
+++ b/utils/idmapd/Makefile.am
@@ -2,6 +2,8 @@

man8_MANS = idmapd.man

+AM_CPPFLAGS += -I ../../support/nfsidmap
+
RPCPREFIX = rpc.
KPREFIX = @kprefix@
sbin_PROGRAMS = idmapd
diff --git a/utils/nfsidmap/Makefile.am b/utils/nfsidmap/Makefile.am
index 49158df..e5d7d04 100644
--- a/utils/nfsidmap/Makefile.am
+++ b/utils/nfsidmap/Makefile.am
@@ -3,6 +3,8 @@
man8_MANS = nfsidmap.man
sbin_PROGRAMS = nfsidmap

+AM_CPPFLAGS += -I ../../support/nfsidmap
+
nfsidmap_SOURCES = nfsidmap.c
nfsidmap_LDADD = -lkeyutils \
../../support/nfs/libnfs.la \
--
2.14.3


2018-02-20 18:50:36

by Steve Dickson

[permalink] [raw]
Subject: [PATCH 7/7] Added more -Werror= warning flags

Add some more -Werror warning flags that
didn't cause warnings but could catch
some in the future.

Signed-off-by: Steve Dickson <[email protected]>
---
configure.ac | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/configure.ac b/configure.ac
index b849f43..f4eba1f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -554,6 +554,19 @@ my_am_cflags="\
-Werror=format=2 \
-Werror=undef \
-Werror=missing-include-dirs \
+ -Werror=strict-aliasing=2 \
+ -Werror=init-self \
+ -Werror=implicit-function-declaration \
+ -Werror=return-type \
+ -Werror=switch \
+ -Werror=overflow \
+ -Werror=int-conversion \
+ -Werror=parentheses \
+ -Werror=incompatible-pointer-types \
+ -Werror=misleading-indentation \
+ -Werror=aggregate-return \
+ -Werror=unused-result \
+ -fno-strict-aliasing \
"

AC_SUBST([AM_CFLAGS], ["$my_am_cflags"])
--
2.14.3


2018-02-20 18:50:36

by Steve Dickson

[permalink] [raw]
Subject: [PATCH 3/7] Removed format-overflow=2 warnings

Added the -Werror=format-overflow=2 warning flag
and then cleaned up the mess

Signed-off-by: Steve Dickson <[email protected]>
---
configure.ac | 1 +
support/nfs/cacheio.c | 2 +-
utils/idmapd/idmapd.c | 2 +-
3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 31990c3..4f9d8c4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -550,6 +550,7 @@ my_am_cflags="\
-Werror=strict-prototypes \
-Werror=missing-prototypes \
-Werror=missing-declarations \
+ -Werror=format-overflow=2 \
"

AC_SUBST([AM_CFLAGS], ["$my_am_cflags"])
diff --git a/support/nfs/cacheio.c b/support/nfs/cacheio.c
index 9912afa..9dc4cf1 100644
--- a/support/nfs/cacheio.c
+++ b/support/nfs/cacheio.c
@@ -212,7 +212,7 @@ cache_flush(int force)
{
struct stat stb;
int c;
- char stime[20];
+ char stime[32];
char path[200];
time_t now;
/* Note: the order of these caches is important.
diff --git a/utils/idmapd/idmapd.c b/utils/idmapd/idmapd.c
index c7e75bd..67d115d 100644
--- a/utils/idmapd/idmapd.c
+++ b/utils/idmapd/idmapd.c
@@ -169,7 +169,7 @@ static int
flush_nfsd_cache(char *path, time_t now)
{
int fd;
- char stime[20];
+ char stime[32];

sprintf(stime, "%ld\n", now);
fd = open(path, O_RDWR);
--
2.14.3


2018-02-23 14:21:42

by Steve Dickson

[permalink] [raw]
Subject: Re: [PATCH 0/7] nfs-utils: Use -Werror warning flags to clean up the code.



On 02/20/2018 01:50 PM, Steve Dickson wrote:
> I received a patch that tried to turns on some
> of these -Werror flags but could not get passed
> the warning that were being generated by
> the rpcgen code.
>
> After taking care of the rpcgen warnings, I
> took over the patch and finished it off.
>
> The warning flags I choose to use are pattern
> after the list in the libostree and the
> systemd list.
>
> Steve Dickson (7):
> configure.ac: clean up
> Removed missing-prototypes warnings.
> Removed format-overflow=2 warnings
> Removed format=2 warnings
> Removed undef warnings
> Removed missing-include-dirs warnings
> Added more -Werror= warning flags
>
> configure.ac | 41 ++++++++++++++++++++++++--------------
> support/misc/mountpoint.c | 1 +
> support/nfs/atomicio.c | 2 ++
> support/nfs/cacheio.c | 2 +-
> support/nfs/closeall.c | 2 ++
> support/nfs/rpcmisc.c | 1 +
> support/nfs/strlcat.c | 2 ++
> support/nfs/strlcpy.c | 2 ++
> support/nfs/svc_socket.c | 2 ++
> support/nfs/wildmat.c | 7 +++++++
> support/nfsidmap/libnfsidmap.c | 3 ++-
> support/nfsidmap/nfsidmap_plugin.h | 1 +
> support/nfsidmap/nss.c | 2 +-
> systemd/systemd.c | 1 +
> utils/blkmapd/device-discovery.c | 10 +++++-----
> utils/blkmapd/dm-device.c | 2 +-
> utils/gssd/Makefile.am | 2 ++
> utils/gssd/err_util.c | 1 +
> utils/gssd/gss_names.c | 1 +
> utils/gssd/gssd_proc.c | 4 ++--
> utils/gssd/krb5_util.c | 6 +++---
> utils/gssd/svcgssd.c | 4 ++--
> utils/gssd/svcgssd_mech2file.c | 1 +
> utils/idmapd/Makefile.am | 2 ++
> utils/idmapd/idmapd.c | 4 ++--
> utils/mount/configfile.c | 4 ++++
> utils/mount/mount_libmount.c | 2 ++
> utils/mount/stropts.c | 2 ++
> utils/mountd/svc_run.c | 1 +
> utils/nfsdcltrack/sqlite.c | 3 ++-
> utils/nfsidmap/Makefile.am | 2 ++
> utils/nfsstat/nfsstat.c | 4 +++-
> utils/statd/svc_run.c | 1 +
> 33 files changed, 90 insertions(+), 35 deletions(-)
>
Series committed...

steved.