mirror of
git://git.sv.gnu.org/coreutils.git
synced 2026-04-21 03:12:48 +02:00
maint: prefer STRUCT_UTMP to struct gl_utmp
* cfg.mk (sc_prohibit-struct-gl_utmp): New rule for 'make syntax-check'. * src/pinky.c (time_string, print_entry, scan_entries, short_pinky): Use STRUCT_UTMP instead of struct gl_utmp. * src/uptime.c (print_uptime, print_uptime, uptime): Likewise. * src/users.c (list_entries_users, users): Likewise. * src/who.c (time_string, print_user, print_boottime, print_deadprocs) (print_login, print_initspawn, print_clockchange, print_runlevel) list_entries_who, scan_entries, who): Likewise.
This commit is contained in:
7
cfg.mk
7
cfg.mk
@@ -311,6 +311,13 @@ sc_prohibit-_gl-attributes:
|
||||
halt='Use ATTRIBUTE_... instead of _GL_ATTRIBUTE_...' \
|
||||
$(_sc_search_regexp)
|
||||
|
||||
# Prefer the STRUCT_UTMP typedef over struct gl_utmp.
|
||||
sc_prohibit-struct-gl_utmp:
|
||||
@prohibit='struct gl_utmp' \
|
||||
in_vc_files='\.[ch]$$' \
|
||||
halt='Use STRUCT_UTMP, not struct gl_utmp' \
|
||||
$(_sc_search_regexp)
|
||||
|
||||
# Prefer the const declaration form, with const following the type
|
||||
sc_prohibit-const-char:
|
||||
@prohibit='const char \*' \
|
||||
|
||||
@@ -179,7 +179,7 @@ idle_string (time_t when)
|
||||
|
||||
/* Return a time string. */
|
||||
static char const *
|
||||
time_string (struct gl_utmp const *utmp_ent)
|
||||
time_string (STRUCT_UTMP const *utmp_ent)
|
||||
{
|
||||
static char buf[INT_STRLEN_BOUND (intmax_t) + sizeof "-%m-%d %H:%M"];
|
||||
struct tm *tmp = localtime (&utmp_ent->ut_ts.tv_sec);
|
||||
@@ -196,7 +196,7 @@ time_string (struct gl_utmp const *utmp_ent)
|
||||
/* Display a line of information about UTMP_ENT. */
|
||||
|
||||
static void
|
||||
print_entry (struct gl_utmp const *utmp_ent)
|
||||
print_entry (STRUCT_UTMP const *utmp_ent)
|
||||
{
|
||||
struct stat stats;
|
||||
time_t last_change;
|
||||
@@ -428,7 +428,7 @@ print_heading (void)
|
||||
/* Display UTMP_BUF, which should have N entries. */
|
||||
|
||||
static void
|
||||
scan_entries (idx_t n, struct gl_utmp const *utmp_buf,
|
||||
scan_entries (idx_t n, STRUCT_UTMP const *utmp_buf,
|
||||
const int argc_names, char *const argv_names[])
|
||||
{
|
||||
if (hard_locale (LC_TIME))
|
||||
@@ -472,7 +472,7 @@ short_pinky (char const *filename,
|
||||
const int argc_names, char *const argv_names[])
|
||||
{
|
||||
idx_t n_users;
|
||||
struct gl_utmp *utmp_buf;
|
||||
STRUCT_UTMP *utmp_buf;
|
||||
if (read_utmp (filename, &n_users, &utmp_buf, READ_UTMP_USER_PROCESS) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (filename));
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
proper_name ("Kaveh Ghazi")
|
||||
|
||||
static int
|
||||
print_uptime (idx_t n, struct gl_utmp const *utmp_buf)
|
||||
print_uptime (idx_t n, STRUCT_UTMP const *utmp_buf)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
time_t boot_time = 0;
|
||||
@@ -47,7 +47,7 @@ print_uptime (idx_t n, struct gl_utmp const *utmp_buf)
|
||||
idx_t entries = 0;
|
||||
for (idx_t i = 0; i < n; i++)
|
||||
{
|
||||
struct gl_utmp const *this = &utmp_buf[i];
|
||||
STRUCT_UTMP const *this = &utmp_buf[i];
|
||||
entries += IS_USER_PROCESS (this);
|
||||
if (UT_TYPE_BOOT_TIME (this))
|
||||
boot_time = this->ut_ts.tv_sec;
|
||||
@@ -125,7 +125,7 @@ static _Noreturn void
|
||||
uptime (char const *filename, int options)
|
||||
{
|
||||
idx_t n_users;
|
||||
struct gl_utmp *utmp_buf;
|
||||
STRUCT_UTMP *utmp_buf;
|
||||
int read_utmp_status = (read_utmp (filename, &n_users, &utmp_buf, options) < 0
|
||||
? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
if (read_utmp_status != EXIT_SUCCESS)
|
||||
|
||||
@@ -42,7 +42,7 @@ userid_compare (const void *v_a, const void *v_b)
|
||||
}
|
||||
|
||||
static void
|
||||
list_entries_users (idx_t n, struct gl_utmp const *this)
|
||||
list_entries_users (idx_t n, STRUCT_UTMP const *this)
|
||||
{
|
||||
char **u = xinmalloc (n, sizeof *u);
|
||||
idx_t i;
|
||||
@@ -83,7 +83,7 @@ static void
|
||||
users (char const *filename, int options)
|
||||
{
|
||||
idx_t n_users;
|
||||
struct gl_utmp *utmp_buf;
|
||||
STRUCT_UTMP *utmp_buf;
|
||||
options |= READ_UTMP_USER_PROCESS;
|
||||
if (read_utmp (filename, &n_users, &utmp_buf, options) != 0)
|
||||
error (EXIT_FAILURE, errno, "%s", quotef (filename));
|
||||
|
||||
24
src/who.c
24
src/who.c
@@ -205,7 +205,7 @@ idle_string (time_t when, time_t boottime)
|
||||
|
||||
/* Return a time string. */
|
||||
static char const *
|
||||
time_string (struct gl_utmp const *utmp_ent)
|
||||
time_string (STRUCT_UTMP const *utmp_ent)
|
||||
{
|
||||
static char buf[INT_STRLEN_BOUND (intmax_t) + sizeof "-%m-%d %H:%M"];
|
||||
struct tm *tmp = localtime (&utmp_ent->ut_ts.tv_sec);
|
||||
@@ -312,7 +312,7 @@ is_tty_writable (struct stat const *pstat)
|
||||
/* Send properly parsed USER_PROCESS info to print_line. The most
|
||||
recent boot time is BOOTTIME. */
|
||||
static void
|
||||
print_user (struct gl_utmp const *utmp_ent, time_t boottime)
|
||||
print_user (STRUCT_UTMP const *utmp_ent, time_t boottime)
|
||||
{
|
||||
struct stat stats;
|
||||
time_t last_change;
|
||||
@@ -426,14 +426,14 @@ print_user (struct gl_utmp const *utmp_ent, time_t boottime)
|
||||
}
|
||||
|
||||
static void
|
||||
print_boottime (struct gl_utmp const *utmp_ent)
|
||||
print_boottime (STRUCT_UTMP const *utmp_ent)
|
||||
{
|
||||
print_line ("", ' ', _("system boot"),
|
||||
time_string (utmp_ent), "", "", "", "");
|
||||
}
|
||||
|
||||
static char *
|
||||
make_id_equals_comment (struct gl_utmp const *utmp_ent)
|
||||
make_id_equals_comment (STRUCT_UTMP const *utmp_ent)
|
||||
{
|
||||
char const *id = UT_ID (utmp_ent);
|
||||
idx_t idlen = strlen (id);
|
||||
@@ -447,7 +447,7 @@ make_id_equals_comment (struct gl_utmp const *utmp_ent)
|
||||
}
|
||||
|
||||
static void
|
||||
print_deadprocs (struct gl_utmp const *utmp_ent)
|
||||
print_deadprocs (STRUCT_UTMP const *utmp_ent)
|
||||
{
|
||||
static char *exitstr;
|
||||
char *comment = make_id_equals_comment (utmp_ent);
|
||||
@@ -470,7 +470,7 @@ print_deadprocs (struct gl_utmp const *utmp_ent)
|
||||
}
|
||||
|
||||
static void
|
||||
print_login (struct gl_utmp const *utmp_ent)
|
||||
print_login (STRUCT_UTMP const *utmp_ent)
|
||||
{
|
||||
char *comment = make_id_equals_comment (utmp_ent);
|
||||
PIDSTR_DECL_AND_INIT (pidstr, utmp_ent);
|
||||
@@ -483,7 +483,7 @@ print_login (struct gl_utmp const *utmp_ent)
|
||||
}
|
||||
|
||||
static void
|
||||
print_initspawn (struct gl_utmp const *utmp_ent)
|
||||
print_initspawn (STRUCT_UTMP const *utmp_ent)
|
||||
{
|
||||
char *comment = make_id_equals_comment (utmp_ent);
|
||||
PIDSTR_DECL_AND_INIT (pidstr, utmp_ent);
|
||||
@@ -494,7 +494,7 @@ print_initspawn (struct gl_utmp const *utmp_ent)
|
||||
}
|
||||
|
||||
static void
|
||||
print_clockchange (struct gl_utmp const *utmp_ent)
|
||||
print_clockchange (STRUCT_UTMP const *utmp_ent)
|
||||
{
|
||||
/* FIXME: handle NEW_TIME & OLD_TIME both */
|
||||
print_line ("", ' ', _("clock change"),
|
||||
@@ -502,7 +502,7 @@ print_clockchange (struct gl_utmp const *utmp_ent)
|
||||
}
|
||||
|
||||
static void
|
||||
print_runlevel (struct gl_utmp const *utmp_ent)
|
||||
print_runlevel (STRUCT_UTMP const *utmp_ent)
|
||||
{
|
||||
static char *runlevline, *comment;
|
||||
unsigned char last = utmp_ent->ut_pid / 256;
|
||||
@@ -525,7 +525,7 @@ print_runlevel (struct gl_utmp const *utmp_ent)
|
||||
/* Print the username of each valid entry and the number of valid entries
|
||||
in UTMP_BUF, which should have N elements. */
|
||||
static void
|
||||
list_entries_who (idx_t n, struct gl_utmp const *utmp_buf)
|
||||
list_entries_who (idx_t n, STRUCT_UTMP const *utmp_buf)
|
||||
{
|
||||
idx_t entries = 0;
|
||||
char const *separator = "";
|
||||
@@ -557,7 +557,7 @@ print_heading (void)
|
||||
|
||||
/* Display UTMP_BUF, which should have N entries. */
|
||||
static void
|
||||
scan_entries (idx_t n, struct gl_utmp const *utmp_buf)
|
||||
scan_entries (idx_t n, STRUCT_UTMP const *utmp_buf)
|
||||
{
|
||||
char *ttyname_b IF_LINT ( = nullptr);
|
||||
time_t boottime = TYPE_MINIMUM (time_t);
|
||||
@@ -611,7 +611,7 @@ static void
|
||||
who (char const *filename, int options)
|
||||
{
|
||||
idx_t n_users;
|
||||
struct gl_utmp *utmp_buf;
|
||||
STRUCT_UTMP *utmp_buf;
|
||||
if (short_list)
|
||||
options |= READ_UTMP_USER_PROCESS;
|
||||
if (read_utmp (filename, &n_users, &utmp_buf, options) != 0)
|
||||
|
||||
Reference in New Issue
Block a user