Module Name: src Committed By: martin Date: Thu Apr 18 16:10:17 UTC 2024
Modified Files: src/usr.bin/who [netbsd-8]: utmpentry.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #1958): usr.bin/who/utmpentry.c: revision 1.22 PR/56013: Kouichi Hashikawa: Move setutent/setutxent right before the loops. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.18.8.1 src/usr.bin/who/utmpentry.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/who/utmpentry.c diff -u src/usr.bin/who/utmpentry.c:1.18 src/usr.bin/who/utmpentry.c:1.18.8.1 --- src/usr.bin/who/utmpentry.c:1.18 Sat Nov 21 15:01:43 2015 +++ src/usr.bin/who/utmpentry.c Thu Apr 18 16:10:17 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: utmpentry.c,v 1.18 2015/11/21 15:01:43 christos Exp $ */ +/* $NetBSD: utmpentry.c,v 1.18.8.1 2024/04/18 16:10:17 martin Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: utmpentry.c,v 1.18 2015/11/21 15:01:43 christos Exp $"); +__RCSID("$NetBSD: utmpentry.c,v 1.18.8.1 2024/04/18 16:10:17 martin Exp $"); #endif #include <sys/stat.h> @@ -95,14 +95,7 @@ setup(const char *fname) struct stat st; const char *sfname; - if (fname == NULL) { -#ifdef SUPPORT_UTMPX - setutxent(); -#endif -#ifdef SUPPORT_UTMP - setutent(); -#endif - } else { + if (fname != NULL) { size_t len = strlen(fname); if (len == 0) errx(1, "Filename cannot be 0 length."); @@ -133,9 +126,9 @@ setup(const char *fname) what &= ~1; } else { if (timespeccmp(&st.st_mtimespec, &utmpxtime, >)) - utmpxtime = st.st_mtimespec; + utmpxtime = st.st_mtimespec; else - what &= ~1; + what &= ~1; } } #endif @@ -204,10 +197,11 @@ getutentries(const char *fname, struct u #endif #ifdef SUPPORT_UTMPX + setutxent(); while ((what & 1) && (utx = getutxent()) != NULL) { if (fname == NULL && ((1 << utx->ut_type) & etype) == 0) continue; - if ((ep = calloc(1, sizeof(struct utmpentry))) == NULL) { + if ((ep = calloc(1, sizeof(*ep))) == NULL) { warn(NULL); return 0; } @@ -218,6 +212,7 @@ getutentries(const char *fname, struct u #endif #ifdef SUPPORT_UTMP + setutent(); if ((etype & (1 << USER_PROCESS)) != 0) { while ((what & 2) && (ut = getutent()) != NULL) { if (fname == NULL && (*ut->ut_name == '\0' ||