]> granicus.if.org Git - shadow/commitdiff
* lib/prototypes.h, libmisc/cleanup.c, lib/spawn.c, src/chage.c:
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Tue, 18 Oct 2011 20:23:33 +0000 (20:23 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Tue, 18 Oct 2011 20:23:33 +0000 (20:23 +0000)
Add splint annotations.

ChangeLog
lib/prototypes.h
lib/spawn.c
libmisc/cleanup.c
src/chage.c

index 2406f93f78d66f280f338d761cb791edbb3a5499..c0c9fe05d69c477cd83524fd821a34d1ce1e4344 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,8 @@
        * src/newusers.c: Fix typo.
        * src/useradd.c: Likewise.
        * lib/nscd.c: Remove unused variable.
+       * lib/prototypes.h, libmisc/cleanup.c, lib/spawn.c, src/chage.c:
+       Add splint annotations.
 
 2011-10-15  Nicolas François  <nicolas.francois@centraliens.net>
 
index 2332744a46c0800d8c3cbcaacf6187940b2b4d9f..7a0bb2f787270903ac2f388b48996a4ea40900b6 100644 (file)
@@ -83,9 +83,9 @@ extern int chown_tree (const char *root,
 extern void chown_tty (const struct passwd *);
 
 /* cleanup.c */
-typedef void (*cleanup_function) (/*@null@*/void *arg);
-void add_cleanup (cleanup_function pcf, /*@null@*/void *arg);
-void del_cleanup (cleanup_function pcf);
+typedef /*@null@*/void (*cleanup_function) (/*@null@*/void *arg);
+void add_cleanup (/*@notnull@*/cleanup_function pcf, /*@null@*/void *arg);
+void del_cleanup (/*@notnull@*/cleanup_function pcf);
 void do_cleanups (void);
 
 /* cleanup_group.c */
@@ -340,7 +340,7 @@ extern int shell (const char *file, /*@null@*/const char *arg, char *const envp[
 
 /* spawn.c */
 extern int run_command (const char *cmd, const char *argv[],
-                        const char *envp[], int *status);
+                        /*@null@*/const char *envp[], /*@out@*/int *status);
 
 /* system.c */
 extern int safe_system (const char *command,
index 472f64db1ff8a2ad6b4c8add135044a0a0cf2e6b..da984019eaeed94c66dae32bdf4ac156d84f6164 100644 (file)
@@ -38,8 +38,8 @@
 #include "exitcodes.h"
 #include "prototypes.h"
 
-int run_command (const char *cmd, const char *argv[], const char *envp[],
-                 int *status)
+int run_command (const char *cmd, const char *argv[],
+                 /*@null@*/const char *envp[], /*@out@*/int *status)
 {
        pid_t pid, wpid;
 
index def7c475720dfa8f3ac83047221fed9215486106..bd83a2309be5d33ecad65e9ed5eb94c53884ae6a 100644 (file)
  * The cleanup_functions stack.
  */
 #define CLEANUP_FUNCTIONS 10
+
+typedef /*@null@*/void * parg_t;
+
 static cleanup_function cleanup_functions[CLEANUP_FUNCTIONS];
-static void * cleanup_function_args[CLEANUP_FUNCTIONS];
+static parg_t cleanup_function_args[CLEANUP_FUNCTIONS];
 static pid_t cleanup_pid = 0;
 
 /*
@@ -83,7 +86,7 @@ void do_cleanups (void)
 /*
  * add_cleanup - Add a cleanup_function to the cleanup_functions stack.
  */
-void add_cleanup (cleanup_function pcf, /*@null@*/void *arg)
+void add_cleanup (/*@notnull@*/cleanup_function pcf, /*@null@*/void *arg)
 {
        unsigned int i;
        assert (NULL != pcf);
@@ -103,7 +106,7 @@ void add_cleanup (cleanup_function pcf, /*@null@*/void *arg)
 /*
  * del_cleanup - Remove a cleanup_function from the cleanup_functions stack.
  */
-void del_cleanup (cleanup_function pcf)
+void del_cleanup (/*@notnull@*/cleanup_function pcf)
 {
        unsigned int i;
        assert (NULL != pcf);
index c5e8b469c42fb6d3eb662ab61b84a60d40ddccd1..37a610d2337c4a86a3aab7c2fa0278a7a511c8a1 100644 (file)
@@ -91,7 +91,7 @@ static long inactdays;
 static long expdate;
 
 /* local function prototypes */
-static void usage (int status);
+static /*@noreturn@*/void usage (int status);
 static void date_to_str (char *buf, size_t maxsize, time_t date);
 static int new_fields (void);
 static void print_date (time_t date);
@@ -101,12 +101,12 @@ static void check_flags (int argc, int opt_index);
 static void check_perms (void);
 static void open_files (bool readonly);
 static void close_files (void);
-static void fail_exit (int code);
+static /*@noreturn@*/void fail_exit (int code);
 
 /*
  * fail_exit - do some cleanup and exit with the given error code
  */
-static void fail_exit (int code)
+static /*@noreturn@*/void fail_exit (int code)
 {
        if (spw_locked) {
                if (spw_unlock () == 0) {
@@ -138,8 +138,9 @@ static void fail_exit (int code)
 /*
  * usage - print command line syntax and exit
  */
-static void usage (int status)
+static /*@noreturn@*/void usage (int status)
 {
+       (void)
        fputs (_("Usage: chage [options] LOGIN\n"
                 "\n"
                 "Options:\n"
@@ -187,14 +188,14 @@ static int new_fields (void)
        (void) puts (_("Enter the new value, or press ENTER for the default"));
        (void) puts ("");
 
-       snprintf (buf, sizeof buf, "%ld", mindays);
+       (void) snprintf (buf, sizeof buf, "%ld", mindays);
        change_field (buf, sizeof buf, _("Minimum Password Age"));
        if (   (getlong (buf, &mindays) == 0)
            || (mindays < -1)) {
                return 0;
        }
 
-       snprintf (buf, sizeof buf, "%ld", maxdays);
+       (void) snprintf (buf, sizeof buf, "%ld", maxdays);
        change_field (buf, sizeof buf, _("Maximum Password Age"));
        if (   (getlong (buf, &maxdays) == 0)
            || (maxdays < -1)) {
@@ -218,14 +219,14 @@ static int new_fields (void)
                }
        }
 
-       snprintf (buf, sizeof buf, "%ld", warndays);
+       (void) snprintf (buf, sizeof buf, "%ld", warndays);
        change_field (buf, sizeof buf, _("Password Expiration Warning"));
        if (   (getlong (buf, &warndays) == 0)
            || (warndays < -1)) {
                return 0;
        }
 
-       snprintf (buf, sizeof buf, "%ld", inactdays);
+       (void) snprintf (buf, sizeof buf, "%ld", inactdays);
        change_field (buf, sizeof buf, _("Password Inactive"));
        if (   (getlong (buf, &inactdays) == 0)
            || (inactdays < -1)) {
@@ -261,7 +262,7 @@ static void print_date (time_t date)
 
        tp = gmtime (&date);
        if (NULL == tp) {
-               (void) printf ("time_t: %lu\n", date);
+               (void) printf ("time_t: %lu\n", (unsigned long)date);
        } else {
                (void) strftime (buf, sizeof buf, "%b %d, %Y", tp);
                (void) puts (buf);
@@ -420,7 +421,7 @@ static void process_flags (int argc, char **argv)
                        break;
                case 'h':
                        usage (E_SUCCESS);
-                       break;
+                       /*@notreached@*/break;
                case 'I':
                        Iflg = true;
                        if (   (getlong (optarg, &inactdays) == 0)
@@ -657,7 +658,8 @@ static void close_files (void)
  *
  *     It will not return in case of error
  */
-static void update_age (const struct spwd *sp, const struct passwd *pw)
+static void update_age (/*@null@*/const struct spwd *sp,
+                        /*@notnull@*/const struct passwd *pw)
 {
        struct spwd spwent;
 
@@ -709,7 +711,7 @@ static void update_age (const struct spwd *sp, const struct passwd *pw)
 /*
  * get_defaults - get the value of the fields not set from the command line
  */
-static void get_defaults (const struct spwd *sp)
+static void get_defaults (/*@null@*/const struct spwd *sp)
 {
        /*
         * Set the fields that aren't being set from the command line from