Use the noreturn attribute, rather than comments

This will allow the compiler to understand these functions better.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar 2023-02-07 19:50:36 +01:00 committed by Serge Hallyn
parent b34387745a
commit 416707b087
16 changed files with 83 additions and 41 deletions

View File

@ -66,7 +66,7 @@ static long inactdays;
static long expdate;
/* local function prototypes */
static /*@noreturn@*/void usage (int status);
NORETURN static void usage (int status);
static int new_fields (void);
static void print_date (time_t date);
static void list_fields (void);
@ -75,12 +75,14 @@ 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 /*@noreturn@*/void fail_exit (int code);
NORETURN static void fail_exit (int code);
/*
* fail_exit - do some cleanup and exit with the given error code
*/
static /*@noreturn@*/void fail_exit (int code)
NORETURN
static void
fail_exit (int code)
{
if (spw_locked) {
if (spw_unlock () == 0) {
@ -112,7 +114,9 @@ static /*@noreturn@*/void fail_exit (int code)
/*
* usage - print command line syntax and exit
*/
static /*@noreturn@*/void usage (int status)
NORETURN
static void
usage (int status)
{
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
(void) fprintf (usageout,

View File

@ -55,7 +55,7 @@ static bool pw_locked = false;
/* local function prototypes */
static void fail_exit (int code);
static /*@noreturn@*/void usage (int status);
NORETURN static void usage (int status);
static bool may_change_field (int);
static void new_fields (void);
static char *copy_field (char *, char *, char *);
@ -86,7 +86,9 @@ static void fail_exit (int code)
/*
* usage - print command line syntax and exit
*/
static /*@noreturn@*/void usage (int status)
NORETURN
static void
usage (int status)
{
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
(void) fprintf (usageout,

View File

@ -63,7 +63,7 @@ static bool gr_locked = false;
/* local function prototypes */
static void fail_exit (int code);
static /*@noreturn@*/void usage (int status);
NORETURN static void usage (int status);
static void process_flags (int argc, char **argv);
static void check_flags (void);
static void check_perms (void);
@ -99,7 +99,9 @@ static void fail_exit (int code)
/*
* usage - display usage message and exit
*/
static /*@noreturn@*/void usage (int status)
NORETURN
static void
usage (int status)
{
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
(void) fprintf (usageout,

View File

@ -60,7 +60,7 @@ static bool spw_locked = false;
/* local function prototypes */
static void fail_exit (int code);
static /*@noreturn@*/void usage (int status);
NORETURN static void usage (int status);
static void process_flags (int argc, char **argv);
static void check_flags (void);
static void check_perms (void);
@ -94,7 +94,9 @@ static void fail_exit (int code)
/*
* usage - display usage message and exit
*/
static /*@noreturn@*/void usage (int status)
NORETURN
static void
usage (int status)
{
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
(void) fprintf (usageout,

View File

@ -53,8 +53,8 @@ static bool pw_locked = false;
/* external identifiers */
/* local function prototypes */
static /*@noreturn@*/void fail_exit (int code);
static /*@noreturn@*/void usage (int status);
NORETURN static void fail_exit (int code);
NORETURN static void usage (int status);
static void new_fields (void);
static bool shell_is_listed (const char *);
static bool is_restricted_shell (const char *);
@ -65,7 +65,9 @@ static void update_shell (const char *user, char *loginsh);
/*
* fail_exit - do some cleanup and exit with the given error code
*/
static /*@noreturn@*/void fail_exit (int code)
NORETURN
static void
fail_exit (int code)
{
if (pw_locked) {
if (pw_unlock () == 0) {
@ -83,7 +85,9 @@ static /*@noreturn@*/void fail_exit (int code)
/*
* usage - print command line syntax and exit
*/
static /*@noreturn@*/void usage (int status)
NORETURN
static void
usage (int status)
{
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
(void) fprintf (usageout,

View File

@ -28,7 +28,7 @@ static bool cflg = false;
/* local function prototypes */
static void catch_signals (unused int sig);
static /*@noreturn@*/void usage (int status);
NORETURN static void usage (int status);
static void process_flags (int argc, char **argv);
/*
@ -42,7 +42,9 @@ static void catch_signals (unused int sig)
/*
* usage - print syntax message and exit
*/
static /*@noreturn@*/void usage (int status)
NORETURN
static void
usage (int status)
{
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
(void) fprintf (usageout,

View File

@ -26,7 +26,7 @@
#include "shadowlog.h"
/* local function prototypes */
static /*@noreturn@*/void usage (int status);
NORETURN static void usage (int status);
static void print_one (/*@null@*/const struct passwd *pw, bool force);
static void set_locktime (long locktime);
static bool set_locktime_one (uid_t uid, long locktime);
@ -59,7 +59,9 @@ static struct stat statbuf; /* fstat buffer for file size */
#define NOW time(NULL)
static /*@noreturn@*/void usage (int status)
NORETURN
static void
usage (int status)
{
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
(void) fprintf (usageout,

View File

@ -70,7 +70,7 @@ static bool is_shadow_grp;
#endif
/* local function prototypes */
static /*@noreturn@*/void usage (int status);
NORETURN static void usage (int status);
static void new_grent (struct group *grent);
#ifdef SHADOWGRP
@ -87,7 +87,9 @@ static void check_perms (void);
/*
* usage - display usage message and exit
*/
static /*@noreturn@*/void usage (int status)
NORETURN
static void
usage (int status)
{
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
(void) fprintf (usageout,

View File

@ -58,7 +58,7 @@ static bool is_shadow_grp;
#define E_GRP_UPDATE 10 /* can't update group file */
/* local function prototypes */
static /*@noreturn@*/void usage (int status);
NORETURN static void usage (int status);
static void grp_update (void);
static void close_files (void);
static void open_files (void);
@ -68,7 +68,9 @@ static void process_flags (int argc, char **argv);
/*
* usage - display usage message and exit
*/
static /*@noreturn@*/void usage (int status)
NORETURN
static void
usage (int status)
{
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
(void) fprintf (usageout,

View File

@ -66,7 +66,7 @@ static void remove_user (const char *user,
const struct group *grp);
static void purge_members (const struct group *grp);
static void display_members (const char *const *members);
static /*@noreturn@*/void usage (int status);
NORETURN static void usage (int status);
static void process_flags (int argc, char **argv);
static void check_perms (void);
static void fail_exit (int code);
@ -339,7 +339,9 @@ static void display_members (const char *const *members)
}
}
static /*@noreturn@*/void usage (int status)
NORETURN
static void
usage (int status)
{
FILE *usageout = (EXIT_SUCCESS != status) ? stderr : stdout;
(void) fprintf (usageout,

View File

@ -62,7 +62,7 @@ static bool silence_warnings = false;
/* local function prototypes */
static void fail_exit (int status);
static /*@noreturn@*/void usage (int status);
NORETURN static void usage (int status);
static void delete_member (char **, const char *);
static void process_flags (int argc, char **argv);
static void open_files (void);
@ -114,7 +114,9 @@ static void fail_exit (int status)
/*
* usage - print syntax message and exit
*/
static /*@noreturn@*/void usage (int status)
NORETURN
static void
usage (int status)
{
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
#ifdef SHADOWGRP

View File

@ -58,7 +58,9 @@ static bool Sflg = false; /* set record for user */
#define NOW time(NULL)
static /*@noreturn@*/void usage (int status)
NORETURN
static void
usage (int status)
{
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
(void) fprintf (usageout,

View File

@ -104,7 +104,7 @@ static bool do_update_pwd = false;
*/
/* local function prototypes */
static /*@noreturn@*/void usage (int);
NORETURN static void usage (int);
#ifndef USE_PAM
static bool reuse (const char *, const struct passwd *);
@ -114,8 +114,8 @@ static void check_password (const struct passwd *, const struct spwd *);
#endif /* !USE_PAM */
static /*@observer@*/const char *pw_status (const char *);
static void print_status (const struct passwd *);
static /*@noreturn@*/void fail_exit (int);
static /*@noreturn@*/void oom (void);
NORETURN static void fail_exit (int);
NORETURN static void oom (void);
static char *update_crypt_pw (char *);
static void update_noshadow (void);
@ -124,7 +124,9 @@ static void update_shadow (void);
/*
* usage - print command usage and exit
*/
static /*@noreturn@*/void usage (int status)
NORETURN
static void
usage (int status)
{
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
(void) fprintf (usageout,
@ -466,7 +468,9 @@ static void print_status (const struct passwd *pw)
}
static /*@noreturn@*/void fail_exit (int status)
NORETURN
static void
fail_exit (int status)
{
if (pw_locked) {
if (pw_unlock () == 0) {
@ -487,7 +491,9 @@ static /*@noreturn@*/void fail_exit (int status)
exit (status);
}
static /*@noreturn@*/void oom (void)
NORETURN
static void
oom (void)
{
(void) fprintf (stderr, _("%s: out of memory\n"), Prog);
fail_exit (E_FAILURE);

View File

@ -66,7 +66,7 @@ static bool quiet = false; /* don't report warnings, only errors */
/* local function prototypes */
static void fail_exit (int code);
static /*@noreturn@*/void usage (int status);
NORETURN static void usage (int status);
static void process_flags (int argc, char **argv);
static void open_files (void);
static void close_files (bool changed);
@ -109,7 +109,9 @@ static void fail_exit (int code)
/*
* usage - print syntax message and exit
*/
static /*@noreturn@*/void usage (int status)
NORETURN
static void
usage (int status)
{
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
#ifdef WITH_TCB

View File

@ -111,7 +111,7 @@ static void die (int);
static bool iswheel (const char *);
#endif /* !USE_PAM */
static bool restricted_shell (const char *shellname);
static /*@noreturn@*/void su_failure (const char *tty, bool su_to_root);
NORETURN static void su_failure (const char *tty, bool su_to_root);
static /*@only@*/struct passwd * check_perms (void);
#ifdef USE_PAM
static void check_perms_pam (const struct passwd *pw);
@ -185,7 +185,9 @@ static bool restricted_shell (const char *shellname)
return true;
}
static /*@noreturn@*/void su_failure (const char *tty, bool su_to_root)
NORETURN
static void
su_failure (const char *tty, bool su_to_root)
{
sulog (tty, false, caller_name, name); /* log failed attempt */
if (getdef_bool ("SYSLOG_SU_ENAB")) {

View File

@ -163,10 +163,10 @@ static bool sub_gid_locked = false;
/* local function prototypes */
static int get_groups (char *);
static /*@noreturn@*/void usage (int status);
NORETURN static void usage (int status);
static void new_pwent (struct passwd *);
static void new_spent (struct spwd *);
static /*@noreturn@*/void fail_exit (int);
NORETURN static void fail_exit (int);
static void update_group (void);
#ifdef SHADOWGRP
@ -359,7 +359,9 @@ static int prepend_range(const char *str, struct ulong_range_list_entry **head)
/*
* usage - display usage message and exit
*/
static /*@noreturn@*/void usage (int status)
NORETURN
static void
usage (int status)
{
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
(void) fprintf (usageout,
@ -627,7 +629,9 @@ static void new_spent (struct spwd *spent)
/*
* fail_exit - exit with an error code after unlocking files
*/
static /*@noreturn@*/void fail_exit (int code)
NORETURN
static void
fail_exit (int code)
{
if (gr_locked) {
if (gr_unlock () == 0) {