[Pkg-shadow-commits] r2078 - in upstream/trunk: . src
nekral-guest at alioth.debian.org
nekral-guest at alioth.debian.org
Mon Jun 9 19:15:28 UTC 2008
Author: nekral-guest
Date: 2008-06-09 19:15:27 +0000 (Mon, 09 Jun 2008)
New Revision: 2078
Modified:
upstream/trunk/ChangeLog
upstream/trunk/src/lastlog.c
Log:
* src/lastlog.c: Use a bool when possible instead of int integers.
* src/lastlog.c: Avoid implicit conversion of pointers / integers
/ chars to booleans.
* src/lastlog.c: Add brackets and parenthesis.
* src/lastlog.c: Ignore return value of setlocale(),
bindtextdomain(), and textdomain().
Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog 2008-06-09 19:10:44 UTC (rev 2077)
+++ upstream/trunk/ChangeLog 2008-06-09 19:15:27 UTC (rev 2078)
@@ -1,5 +1,14 @@
2008-06-09 Nicolas François <nicolas.francois at centraliens.net>
+ * src/lastlog.c: Use a bool when possible instead of int integers.
+ * src/lastlog.c: Avoid implicit conversion of pointers / integers
+ / chars to booleans.
+ * src/lastlog.c: Add brackets and parenthesis.
+ * src/lastlog.c: Ignore return value of setlocale(),
+ bindtextdomain(), and textdomain().
+
+2008-06-09 Nicolas François <nicolas.francois at centraliens.net>
+
* src/userdel.c: Use a bool for the is_shadow_pwd, is_shadow_grp,
deleted_user_group, was_member, was_admin, and the
options' flags.
Modified: upstream/trunk/src/lastlog.c
===================================================================
--- upstream/trunk/src/lastlog.c 2008-06-09 19:10:44 UTC (rev 2077)
+++ upstream/trunk/src/lastlog.c 2008-06-09 19:15:27 UTC (rev 2078)
@@ -43,12 +43,14 @@
#include <time.h>
#include "defines.h"
#include "prototypes.h"
+
/*
* Needed for MkLinux DR1/2/2.1 - J.
*/
#ifndef LASTLOG_FILE
#define LASTLOG_FILE "/var/log/lastlog"
#endif
+
/*
* Global variables
*/
@@ -61,9 +63,9 @@
static time_t inverse_seconds; /* that number of days in seconds */
-static int uflg = 0; /* print only an user of range of users */
-static int tflg = 0; /* print is restricted to most recent days */
-static int bflg = 0; /* print excludes most recent days */
+static bool uflg = false; /* print only an user of range of users */
+static bool tflg = false; /* print is restricted to most recent days */
+static bool bflg = false; /* print excludes most recent days */
static struct lastlog lastlog; /* scratch structure to play with ... */
static struct passwd *pwent;
@@ -84,7 +86,7 @@
static void print_one (const struct passwd *pw)
{
- static int once;
+ static bool once = false;
char *cp;
struct tm *tm;
time_t ll_time;
@@ -93,8 +95,9 @@
char ptime[80];
#endif
- if (!pw)
+ if (NULL == pw) {
return;
+ }
if (!once) {
#ifdef HAVE_LL_HOST
@@ -102,7 +105,7 @@
#else
puts (_("Username Port Latest"));
#endif
- once++;
+ once = true;
}
ll_time = lastlog.ll_time;
tm = localtime (&ll_time);
@@ -114,8 +117,9 @@
cp[24] = '\0';
#endif
- if (lastlog.ll_time == (time_t) 0)
+ if (lastlog.ll_time == (time_t) 0) {
cp = _("**Never logged in**\0");
+ }
#ifdef HAVE_LL_HOST
printf ("%-16s %-8.8s %-16.16s %s\n", pw->pw_name,
@@ -133,22 +137,26 @@
setpwent ();
while ( (pwent = getpwent ()) != NULL ) {
user = pwent->pw_uid;
- if (uflg &&
- ((umin != -1 && user < (uid_t)umin) ||
- (umax != -1 && user > (uid_t)umax)))
+ if ( uflg
+ && ( (umin != -1 && user < (uid_t)umin)
+ || (umax != -1 && user > (uid_t)umax))) {
continue;
+ }
offset = user * sizeof lastlog;
fseeko (lastlogfile, offset, SEEK_SET);
if (fread ((char *) &lastlog, sizeof lastlog, 1,
- lastlogfile) != 1)
+ lastlogfile) != 1) {
continue;
+ }
- if (tflg && NOW - lastlog.ll_time > seconds)
+ if (tflg && ((NOW - lastlog.ll_time) > seconds)) {
continue;
+ }
- if (bflg && NOW - lastlog.ll_time < inverse_seconds)
+ if (bflg && ((NOW - lastlog.ll_time) < inverse_seconds)) {
continue;
+ }
print_one (pwent);
}
@@ -157,9 +165,9 @@
int main (int argc, char **argv)
{
- setlocale (LC_ALL, "");
- bindtextdomain (PACKAGE, LOCALEDIR);
- textdomain (PACKAGE);
+ (void) setlocale (LC_ALL, "");
+ (void) bindtextdomain (PACKAGE, LOCALEDIR);
+ (void) textdomain (PACKAGE);
{
int c;
@@ -181,12 +189,12 @@
case 't':
days = atoi (optarg);
seconds = days * DAY;
- tflg++;
+ tflg = true;
break;
case 'b':
inverse_days = atoi (optarg);
inverse_seconds = inverse_days * DAY;
- bflg++;
+ bflg = true;
break;
case 'u':
/*
@@ -196,7 +204,7 @@
* - a numerical login ID
* - a range (-x, x-, x-y)
*/
- uflg++;
+ uflg = true;
pwent = xgetpwnam (optarg);
if (NULL != pwent) {
umin = pwent->pw_uid;
@@ -253,3 +261,4 @@
fclose (lastlogfile);
exit (0);
}
+
More information about the Pkg-shadow-commits
mailing list