* lib/prototypes.h, libmisc/cleanup.c, lib/spawn.c, src/chage.c:

Add splint annotations.
This commit is contained in:
nekral-guest 2011-10-18 20:23:33 +00:00
parent edbdb4bf03
commit 704f28df98
5 changed files with 28 additions and 21 deletions

View File

@ -3,6 +3,8 @@
* src/newusers.c: Fix typo. * src/newusers.c: Fix typo.
* src/useradd.c: Likewise. * src/useradd.c: Likewise.
* lib/nscd.c: Remove unused variable. * 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> 2011-10-15 Nicolas François <nicolas.francois@centraliens.net>

View File

@ -83,9 +83,9 @@ extern int chown_tree (const char *root,
extern void chown_tty (const struct passwd *); extern void chown_tty (const struct passwd *);
/* cleanup.c */ /* cleanup.c */
typedef void (*cleanup_function) (/*@null@*/void *arg); typedef /*@null@*/void (*cleanup_function) (/*@null@*/void *arg);
void add_cleanup (cleanup_function pcf, /*@null@*/void *arg); void add_cleanup (/*@notnull@*/cleanup_function pcf, /*@null@*/void *arg);
void del_cleanup (cleanup_function pcf); void del_cleanup (/*@notnull@*/cleanup_function pcf);
void do_cleanups (void); void do_cleanups (void);
/* cleanup_group.c */ /* cleanup_group.c */
@ -340,7 +340,7 @@ extern int shell (const char *file, /*@null@*/const char *arg, char *const envp[
/* spawn.c */ /* spawn.c */
extern int run_command (const char *cmd, const char *argv[], extern int run_command (const char *cmd, const char *argv[],
const char *envp[], int *status); /*@null@*/const char *envp[], /*@out@*/int *status);
/* system.c */ /* system.c */
extern int safe_system (const char *command, extern int safe_system (const char *command,

View File

@ -38,8 +38,8 @@
#include "exitcodes.h" #include "exitcodes.h"
#include "prototypes.h" #include "prototypes.h"
int run_command (const char *cmd, const char *argv[], const char *envp[], int run_command (const char *cmd, const char *argv[],
int *status) /*@null@*/const char *envp[], /*@out@*/int *status)
{ {
pid_t pid, wpid; pid_t pid, wpid;

View File

@ -38,8 +38,11 @@
* The cleanup_functions stack. * The cleanup_functions stack.
*/ */
#define CLEANUP_FUNCTIONS 10 #define CLEANUP_FUNCTIONS 10
typedef /*@null@*/void * parg_t;
static cleanup_function cleanup_functions[CLEANUP_FUNCTIONS]; 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; 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. * 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; unsigned int i;
assert (NULL != pcf); 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. * 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; unsigned int i;
assert (NULL != pcf); assert (NULL != pcf);

View File

@ -91,7 +91,7 @@ static long inactdays;
static long expdate; static long expdate;
/* local function prototypes */ /* 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 void date_to_str (char *buf, size_t maxsize, time_t date);
static int new_fields (void); static int new_fields (void);
static void print_date (time_t date); 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 check_perms (void);
static void open_files (bool readonly); static void open_files (bool readonly);
static void close_files (void); 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 * 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_locked) {
if (spw_unlock () == 0) { if (spw_unlock () == 0) {
@ -138,8 +138,9 @@ static void fail_exit (int code)
/* /*
* usage - print command line syntax and exit * 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" fputs (_("Usage: chage [options] LOGIN\n"
"\n" "\n"
"Options:\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 (_("Enter the new value, or press ENTER for the default"));
(void) puts (""); (void) puts ("");
snprintf (buf, sizeof buf, "%ld", mindays); (void) snprintf (buf, sizeof buf, "%ld", mindays);
change_field (buf, sizeof buf, _("Minimum Password Age")); change_field (buf, sizeof buf, _("Minimum Password Age"));
if ( (getlong (buf, &mindays) == 0) if ( (getlong (buf, &mindays) == 0)
|| (mindays < -1)) { || (mindays < -1)) {
return 0; return 0;
} }
snprintf (buf, sizeof buf, "%ld", maxdays); (void) snprintf (buf, sizeof buf, "%ld", maxdays);
change_field (buf, sizeof buf, _("Maximum Password Age")); change_field (buf, sizeof buf, _("Maximum Password Age"));
if ( (getlong (buf, &maxdays) == 0) if ( (getlong (buf, &maxdays) == 0)
|| (maxdays < -1)) { || (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")); change_field (buf, sizeof buf, _("Password Expiration Warning"));
if ( (getlong (buf, &warndays) == 0) if ( (getlong (buf, &warndays) == 0)
|| (warndays < -1)) { || (warndays < -1)) {
return 0; return 0;
} }
snprintf (buf, sizeof buf, "%ld", inactdays); (void) snprintf (buf, sizeof buf, "%ld", inactdays);
change_field (buf, sizeof buf, _("Password Inactive")); change_field (buf, sizeof buf, _("Password Inactive"));
if ( (getlong (buf, &inactdays) == 0) if ( (getlong (buf, &inactdays) == 0)
|| (inactdays < -1)) { || (inactdays < -1)) {
@ -261,7 +262,7 @@ static void print_date (time_t date)
tp = gmtime (&date); tp = gmtime (&date);
if (NULL == tp) { if (NULL == tp) {
(void) printf ("time_t: %lu\n", date); (void) printf ("time_t: %lu\n", (unsigned long)date);
} else { } else {
(void) strftime (buf, sizeof buf, "%b %d, %Y", tp); (void) strftime (buf, sizeof buf, "%b %d, %Y", tp);
(void) puts (buf); (void) puts (buf);
@ -420,7 +421,7 @@ static void process_flags (int argc, char **argv)
break; break;
case 'h': case 'h':
usage (E_SUCCESS); usage (E_SUCCESS);
break; /*@notreached@*/break;
case 'I': case 'I':
Iflg = true; Iflg = true;
if ( (getlong (optarg, &inactdays) == 0) if ( (getlong (optarg, &inactdays) == 0)
@ -657,7 +658,8 @@ static void close_files (void)
* *
* It will not return in case of error * 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; 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 * 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 * Set the fields that aren't being set from the command line from