From: Todd C. Miller Date: Thu, 21 May 2015 17:07:13 +0000 (-0600) Subject: Add target for "make splint". A few files need extra guards to avoid X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1298ea91070261fa1666dad00dca2cbe040cff92;p=sudo Add target for "make splint". A few files need extra guards to avoid errors on systems where they would not otherwise be compiled. No warnings from splint. --- diff --git a/Makefile.in b/Makefile.in index 4098f5200..e5b9a5614 100644 --- a/Makefile.in +++ b/Makefile.in @@ -86,6 +86,9 @@ XGETTEXT_OPTS = -F -k_ -kN_ -kU_ --copyright-holder="Todd C. Miller" \ # Default cppcheck options when run from the top-level Makefile CPPCHECK_OPTS = -q --force --enable=warning,performance,portability --suppress=constStatement --error-exitcode=1 --inline-suppr -Dva_copy=va_copy -U__cplusplus -UQUAD_MAX -UQUAD_MIN -UUQUAD_MAX -U_POSIX_HOST_NAME_MAX -U_POSIX_PATH_MAX -U__NBBY -DNSIG=64 +# Default splint options when run from the top-level Makefile +SPLINT_OPTS = -D__restrict= -checks + all: config.status for d in $(SUBDIRS); do \ (cd $$d && exec $(MAKE) $@) && continue; \ @@ -106,6 +109,14 @@ cppcheck: config.status done; \ exit $$rval +splint: config.status + rval=0; \ + for d in $(SUBDIRS); do \ + echo splinting $$d; \ + (cd $$d && exec $(MAKE) SPLINT_OPTS="$(SPLINT_OPTS)" $@) || rval=`expr $$rval + $$?`; \ + done; \ + exit $$rval + install-dirs install-binaries install-includes install-plugin: config.status pre-install for d in $(SUBDIRS); do \ (cd $$d && exec $(MAKE) "INSTALL_OWNER=$(INSTALL_OWNER)" $@) && continue; \ diff --git a/doc/Makefile.in b/doc/Makefile.in index c85496bd0..a6f2ea23f 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -338,6 +338,8 @@ uninstall: $(DESTDIR)$(mandirform)/sudoers.$(mansectform) \ $(DESTDIR)$(mandirform)/sudoers.ldap.$(mansectform) +splint: + cppcheck: check: diff --git a/examples/Makefile.in b/examples/Makefile.in index c82dd788e..784650469 100644 --- a/examples/Makefile.in +++ b/examples/Makefile.in @@ -77,6 +77,8 @@ install-plugin: uninstall: -rm -rf $(DESTDIR)$(exampledir) +splint: + cppcheck: check: diff --git a/include/Makefile.in b/include/Makefile.in index 61ab18f5f..bb96fba04 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -73,6 +73,8 @@ install-plugin: uninstall: -rm -f $(DESTDIR)$(includedir)/sudo_plugin.h +splint: + cppcheck: check: diff --git a/lib/util/Makefile.in b/lib/util/Makefile.in index ab59c913e..b9cd86f37 100644 --- a/lib/util/Makefile.in +++ b/lib/util/Makefile.in @@ -77,6 +77,9 @@ SHLIB_VERSION = 0:0:0 # cppcheck options, usually set in the top-level Makefile CPPCHECK_OPTS = -q --force --enable=warning,performance,portability --suppress=constStatement --error-exitcode=1 --inline-suppr -Dva_copy=va_copy -U__cplusplus -UQUAD_MAX -UQUAD_MIN -UUQUAD_MAX -U_POSIX_HOST_NAME_MAX -U_POSIX_PATH_MAX -U__NBBY -DNSIG=64 +# splint options, usually set in the top-level Makefile +SPLINT_OPTS = -D__restrict= -checks + # Regression tests TEST_PROGS = atofoo_test conf_test hltq_test parseln_test progname_test @COMPAT_TEST_PROGS@ TEST_LIBS = @LIBS@ @@ -211,6 +214,9 @@ install-plugin: uninstall: $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libexecdir)/sudo/libsudo_util.la +splint: + splint $(SPLINT_OPTS) -I$(incdir) -I$(top_builddir) -I$(top_srcdir) $(srcdir)/*.c + cppcheck: cppcheck $(CPPCHECK_OPTS) -I$(incdir) -I$(top_builddir) -I$(top_srcdir) $(srcdir)/*.c diff --git a/lib/zlib/Makefile.in b/lib/zlib/Makefile.in index fda77ab38..55dabae92 100644 --- a/lib/zlib/Makefile.in +++ b/lib/zlib/Makefile.in @@ -134,6 +134,8 @@ install-plugin: uninstall: $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libexecdir)/sudo/libsudo_z.la +splint: + cppcheck: check: diff --git a/plugins/group_file/Makefile.in b/plugins/group_file/Makefile.in index 302715ee2..eb23af87c 100644 --- a/plugins/group_file/Makefile.in +++ b/plugins/group_file/Makefile.in @@ -61,6 +61,9 @@ SSP_LDFLAGS = @SSP_LDFLAGS@ # cppcheck options, usually set in the top-level Makefile CPPCHECK_OPTS = -q --force --enable=warning,performance,portability --suppress=constStatement --error-exitcode=1 --inline-suppr -Dva_copy=va_copy -U__cplusplus -UQUAD_MAX -UQUAD_MIN -UUQUAD_MAX -U_POSIX_HOST_NAME_MAX -U_POSIX_PATH_MAX -U__NBBY -DNSIG=64 +# splint options, usually set in the top-level Makefile +SPLINT_OPTS = -D__restrict= -checks + # Where to install things... prefix = @prefix@ exec_prefix = @exec_prefix@ @@ -137,6 +140,9 @@ uninstall: -$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(plugindir)/group_file.la -rm -f $(DESTDIR)$(plugindir)/group_file.so~ +splint: + splint $(SPLINT_OPTS) -I$(incdir) -I$(top_builddir) -I$(top_srcdir) $(srcdir)/*.c + cppcheck: cppcheck $(CPPCHECK_OPTS) -I$(incdir) -I$(top_builddir) -I$(top_srcdir) $(srcdir)/*.c diff --git a/plugins/sample/Makefile.in b/plugins/sample/Makefile.in index 23661af96..1520fe567 100644 --- a/plugins/sample/Makefile.in +++ b/plugins/sample/Makefile.in @@ -60,6 +60,9 @@ SSP_LDFLAGS = @SSP_LDFLAGS@ # cppcheck options, usually set in the top-level Makefile CPPCHECK_OPTS = -q --force --enable=warning,performance,portability --suppress=constStatement --error-exitcode=1 --inline-suppr -Dva_copy=va_copy -U__cplusplus -UQUAD_MAX -UQUAD_MIN -UUQUAD_MAX -U_POSIX_HOST_NAME_MAX -U_POSIX_PATH_MAX -U__NBBY -DNSIG=64 +# splint options, usually set in the top-level Makefile +SPLINT_OPTS = -D__restrict= -checks + # Where to install things... prefix = @prefix@ exec_prefix = @exec_prefix@ @@ -136,6 +139,9 @@ uninstall: -$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(plugindir)/sample_plugin.la -rm -f $(DESTDIR)$(plugindir)/sample_plugin.so~ +splint: + splint $(SPLINT_OPTS) -I$(incdir) -I$(top_builddir) -I$(top_srcdir) $(srcdir)/*.c + cppcheck: cppcheck $(CPPCHECK_OPTS) -I$(incdir) -I$(top_builddir) -I$(top_srcdir) $(srcdir)/*.c diff --git a/plugins/sudoers/Makefile.in b/plugins/sudoers/Makefile.in index 8d8486e50..f0d8187ec 100644 --- a/plugins/sudoers/Makefile.in +++ b/plugins/sudoers/Makefile.in @@ -79,6 +79,9 @@ SSP_LDFLAGS = @SSP_LDFLAGS@ # cppcheck options, usually set in the top-level Makefile CPPCHECK_OPTS = -q --force --enable=warning,performance,portability --suppress=constStatement --error-exitcode=1 --inline-suppr -Dva_copy=va_copy -U__cplusplus -UQUAD_MAX -UQUAD_MIN -UUQUAD_MAX -U_POSIX_HOST_NAME_MAX -U_POSIX_PATH_MAX -U__NBBY -DNSIG=64 +# splint options, usually set in the top-level Makefile +SPLINT_OPTS = -D__restrict= -checks + # Where to install things... prefix = @prefix@ exec_prefix = @exec_prefix@ @@ -341,6 +344,9 @@ uninstall: -cmp $(DESTDIR)$(sudoersdir)/sudoers $(srcdir)/sudoers >/dev/null && \ rm -f $(DESTDIR)$(sudoersdir)/sudoers +splint: + splint $(SPLINT_OPTS) -I$(incdir) -I$(top_builddir) -I$(devdir) -I$(srcdir) -I$(top_srcdir) $(srcdir)/*.c $(srcdir)/auth/*.c + cppcheck: cppcheck $(CPPCHECK_OPTS) -I$(incdir) -I$(top_builddir) -I$(devdir) -I$(srcdir) -I$(top_srcdir) $(srcdir)/*.c $(srcdir)/auth/*.c diff --git a/plugins/sudoers/auth/afs.c b/plugins/sudoers/auth/afs.c index a19804396..c18c71b7d 100644 --- a/plugins/sudoers/auth/afs.c +++ b/plugins/sudoers/auth/afs.c @@ -21,6 +21,8 @@ #include +#ifdef HAVE_AFS + #include #include #ifdef STDC_HEADERS @@ -81,3 +83,5 @@ sudo_afs_verify(struct passwd *pw, char *pass, sudo_auth *auth) debug_return_int(AUTH_FAILURE); } + +#endif HAVE_AFS diff --git a/plugins/sudoers/auth/aix_auth.c b/plugins/sudoers/auth/aix_auth.c index 7202e81c2..7c89d71d0 100644 --- a/plugins/sudoers/auth/aix_auth.c +++ b/plugins/sudoers/auth/aix_auth.c @@ -20,6 +20,8 @@ #include +#ifdef HAVE_AIXAUTH + #include #include #ifdef STDC_HEADERS @@ -183,3 +185,5 @@ sudo_aix_cleanup(struct passwd *pw, sudo_auth *auth) debug_return_int(AUTH_SUCCESS); } + +#endif /* HAVE_AIXAUTH */ diff --git a/plugins/sudoers/auth/bsdauth.c b/plugins/sudoers/auth/bsdauth.c index 6881b59dc..484bdda64 100644 --- a/plugins/sudoers/auth/bsdauth.c +++ b/plugins/sudoers/auth/bsdauth.c @@ -21,6 +21,8 @@ #include +#ifdef HAVE_BSD_AUTH_H + #include #include #ifdef STDC_HEADERS @@ -183,3 +185,5 @@ bsdauth_cleanup(struct passwd *pw, sudo_auth *auth) debug_return_int(AUTH_SUCCESS); } + +#endif /* HAVE_BSD_AUTH_H */ diff --git a/plugins/sudoers/auth/dce.c b/plugins/sudoers/auth/dce.c index 97bdd1c05..34e215518 100644 --- a/plugins/sudoers/auth/dce.c +++ b/plugins/sudoers/auth/dce.c @@ -35,6 +35,8 @@ #include +#ifdef HAVE_DCE + #include #include #ifdef STDC_HEADERS @@ -196,3 +198,5 @@ check_dce_status(error_status_t input_status, char *comment) (void) fprintf(stderr, "%s %s\n", comment, error_string); debug_return_int(1); } + +#endif /* HAVE_DCE */ diff --git a/plugins/sudoers/auth/fwtk.c b/plugins/sudoers/auth/fwtk.c index f2195976d..120be77c7 100644 --- a/plugins/sudoers/auth/fwtk.c +++ b/plugins/sudoers/auth/fwtk.c @@ -21,6 +21,8 @@ #include +#ifdef HAVE_FWTK + #include #include #ifdef STDC_HEADERS @@ -152,3 +154,5 @@ sudo_fwtk_cleanup(struct passwd *pw, sudo_auth *auth) auth_close(); debug_return_int(AUTH_SUCCESS); } + +#endif /* HAVE_FWTK */ diff --git a/plugins/sudoers/auth/kerb5.c b/plugins/sudoers/auth/kerb5.c index 2b3bd46fd..c91c0de68 100644 --- a/plugins/sudoers/auth/kerb5.c +++ b/plugins/sudoers/auth/kerb5.c @@ -24,6 +24,8 @@ #include +#ifdef HAVE_KERB5 + #include #include #ifdef STDC_HEADERS @@ -326,3 +328,5 @@ verify_krb_v5_tgt(krb5_context sudo_context, krb5_creds *cred, char *auth_name) debug_return_int(error); } #endif + +#endif /* HAVE_KERB5 */ diff --git a/plugins/sudoers/auth/pam.c b/plugins/sudoers/auth/pam.c index 635d5adc4..2df852d7e 100644 --- a/plugins/sudoers/auth/pam.c +++ b/plugins/sudoers/auth/pam.c @@ -20,6 +20,8 @@ #include +#ifdef HAVE_PAM + #include #include #ifdef STDC_HEADERS @@ -408,3 +410,5 @@ done: } debug_return_int(ret); } + +#endif /* HAVE_PAM */ diff --git a/plugins/sudoers/auth/rfc1938.c b/plugins/sudoers/auth/rfc1938.c index ca6f1e64d..b893dda8a 100644 --- a/plugins/sudoers/auth/rfc1938.c +++ b/plugins/sudoers/auth/rfc1938.c @@ -21,6 +21,8 @@ #include +#if defined(HAVE_SKEY) || defined(HAVE_OPIE) + #include #include #ifdef STDC_HEADERS @@ -133,3 +135,5 @@ sudo_rfc1938_verify(struct passwd *pw, char *pass, sudo_auth *auth) else debug_return_int(AUTH_FAILURE); } + +#endif /* HAVE_SKEY || HAVE_OPIE */ diff --git a/plugins/sudoers/auth/secureware.c b/plugins/sudoers/auth/secureware.c index 50ebdb070..1f29dad43 100644 --- a/plugins/sudoers/auth/secureware.c +++ b/plugins/sudoers/auth/secureware.c @@ -20,6 +20,8 @@ #include +#ifdef HAVE_GETPRPWNAM + #include #include #ifdef STDC_HEADERS @@ -116,3 +118,5 @@ sudo_secureware_cleanup(pw, auth) } debug_return_int(AUTH_SUCCESS); } + +#endif /* HAVE_GETPRPWNAM */ diff --git a/plugins/sudoers/auth/securid5.c b/plugins/sudoers/auth/securid5.c index b495f76f7..e4fd32290 100644 --- a/plugins/sudoers/auth/securid5.c +++ b/plugins/sudoers/auth/securid5.c @@ -25,6 +25,8 @@ #include +#ifdef HAVE_SECURID + #include #include #ifdef STDC_HEADERS @@ -222,3 +224,5 @@ then enter the new token code.\n", \ /* Return stored state to calling process */ debug_return_int(rval); } + +#endif /* HAVE_SECURID */ diff --git a/plugins/sudoers/auth/sia.c b/plugins/sudoers/auth/sia.c index 27f0e0858..c8d2ff036 100644 --- a/plugins/sudoers/auth/sia.c +++ b/plugins/sudoers/auth/sia.c @@ -23,6 +23,8 @@ #include +#ifdef HAVE_SIA_SES_INIT + #include #include #ifdef STDC_HEADERS @@ -153,3 +155,5 @@ sudo_sia_cleanup(struct passwd *pw, sudo_auth *auth) sudo_efree(sudo_argv); debug_return_int(AUTH_SUCCESS); } + +#endif /* HAVE_SIA_SES_INIT */ diff --git a/plugins/sudoers/bsm_audit.c b/plugins/sudoers/bsm_audit.c index 7ced6b836..5fe8b0403 100644 --- a/plugins/sudoers/bsm_audit.c +++ b/plugins/sudoers/bsm_audit.c @@ -17,6 +17,8 @@ #include +#ifdef HAVE_BSM_AUDIT + #include #include @@ -260,3 +262,5 @@ bsm_audit_failure(char *exec_args[], char const *const fmt, va_list ap) } debug_return_int(0); } + +#endif /* HAVE_BSM_AUDIT */ diff --git a/plugins/sudoers/linux_audit.c b/plugins/sudoers/linux_audit.c index a2c236da8..ba6fd88b9 100644 --- a/plugins/sudoers/linux_audit.c +++ b/plugins/sudoers/linux_audit.c @@ -16,6 +16,8 @@ #include +#ifdef HAVE_LINUX_AUDIT + #include #include #ifdef STDC_HEADERS @@ -103,3 +105,5 @@ done: debug_return_int(rc); } + +#endif /* HAVE_LINUX_AUDIT */ diff --git a/plugins/sudoers/solaris_audit.c b/plugins/sudoers/solaris_audit.c index 0b19a7338..13612e290 100644 --- a/plugins/sudoers/solaris_audit.c +++ b/plugins/sudoers/solaris_audit.c @@ -16,6 +16,8 @@ #include +#ifdef HAVE_SOLARIS_AUDIT + #include #include #include @@ -123,3 +125,5 @@ solaris_audit_failure(int argc, char *argv[], char const *const fmt, va_list ap) return 0; } + +#endif /* HAVE_SOLARIS_AUDIT */ diff --git a/plugins/sudoers/sssd.c b/plugins/sudoers/sssd.c index a0ea804b2..eeaa3d069 100644 --- a/plugins/sudoers/sssd.c +++ b/plugins/sudoers/sssd.c @@ -19,6 +19,8 @@ #include +#ifdef HAVE_SSSD + #include #include #include @@ -1463,3 +1465,5 @@ sudo_sss_display_privs(struct sudo_nss *nss, struct passwd *pw, debug_return_int(count); } + +#endif /* HAVE_SSSD */ diff --git a/plugins/system_group/Makefile.in b/plugins/system_group/Makefile.in index 9c5dfecd7..4794a8ad1 100644 --- a/plugins/system_group/Makefile.in +++ b/plugins/system_group/Makefile.in @@ -61,6 +61,9 @@ SSP_LDFLAGS = @SSP_LDFLAGS@ # cppcheck options, usually set in the top-level Makefile CPPCHECK_OPTS = -q --force --enable=warning,performance,portability --suppress=constStatement --error-exitcode=1 --inline-suppr -Dva_copy=va_copy -U__cplusplus -UQUAD_MAX -UQUAD_MIN -UUQUAD_MAX -U_POSIX_HOST_NAME_MAX -U_POSIX_PATH_MAX -U__NBBY -DNSIG=64 +# splint options, usually set in the top-level Makefile +SPLINT_OPTS = -D__restrict= -checks + # Where to install things... prefix = @prefix@ exec_prefix = @exec_prefix@ @@ -137,6 +140,9 @@ uninstall: -$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(plugindir)/system_group.la -rm -f $(DESTDIR)$(plugindir)/system_group.so~ +splint: + splint $(SPLINT_OPTS) -I$(incdir) -I$(top_builddir) -I$(top_srcdir) $(srcdir)/*.c + cppcheck: cppcheck $(CPPCHECK_OPTS) -I$(incdir) -I$(top_builddir) -I$(top_srcdir) $(srcdir)/*.c diff --git a/src/Makefile.in b/src/Makefile.in index e5eca3f70..791993026 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -62,6 +62,9 @@ SSP_LDFLAGS = @SSP_LDFLAGS@ # cppcheck options, usually set in the top-level Makefile CPPCHECK_OPTS = -q --force --enable=warning,performance,portability --suppress=constStatement --error-exitcode=1 --inline-suppr -Dva_copy=va_copy -U__cplusplus -UQUAD_MAX -UQUAD_MIN -UUQUAD_MAX -U_POSIX_HOST_NAME_MAX -U_POSIX_PATH_MAX -U__NBBY -DNSIG=64 +# splint options, usually set in the top-level Makefile +SPLINT_OPTS = -D__restrict= -checks + # Where to install things... prefix = @prefix@ exec_prefix = @exec_prefix@ @@ -194,6 +197,9 @@ uninstall: -test -n "$(INIT_SCRIPT)" && \ rm -f $(DESTDIR)$(RC_LINK) $(DESTDIR)$(INIT_DIR)/sudo +splint: + splint $(SPLINT_OPTS) -I$(incdir) -I$(top_builddir) -I. -I$(srcdir) -I$(top_srcdir) $(srcdir)/*.c + cppcheck: cppcheck $(CPPCHECK_OPTS) -I$(incdir) -I$(top_builddir) -I. -I$(srcdir) -I$(top_srcdir) $(srcdir)/*.c diff --git a/src/selinux.c b/src/selinux.c index c459ccfa4..af3c2b06f 100644 --- a/src/selinux.c +++ b/src/selinux.c @@ -26,6 +26,8 @@ #include +#ifdef HAVE_SELINUX + #include #include #include @@ -418,3 +420,5 @@ selinux_execve(const char *path, char *const argv[], char *const envp[], errno = serrno; debug_return; } + +#endif /* HAVE_SELINUX */