]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
last: use min() from c.h
authorKarel Zak <kzak@redhat.com>
Wed, 23 May 2012 08:07:57 +0000 (10:07 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 23 May 2012 08:07:57 +0000 (10:07 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/last.c

index 34558bb9d3a5b6667b1e85d801da39626b8de11e..1b1bee1190b2beb7f3aaf8083b05e46fbe17f928 100644 (file)
@@ -72,15 +72,11 @@ static struct utmp  utmpbuf;
 #define        LMAX    (int)sizeof(utmpbuf.ut_line)    /* size of utmp tty field */
 #define        NMAX    (int)sizeof(utmpbuf.ut_name)    /* size of utmp name field */
 
-#ifndef MIN
-#define MIN(a,b)       (((a) < (b)) ? (a) : (b))
-#endif
-
 /* maximum sizes used for printing */
 /* probably we want a two-pass version that computes the right length */
-int hmax = MIN(HMAX, 16);
-int lmax = MIN(LMAX, 8);
-int nmax = MIN(NMAX, 16);
+#define P_HMAX min(HMAX, 16)
+#define P_LMAX min(LMAX, 8)
+#define P_NMAX min(NMAX, 16)
 
 typedef struct arg {
        char    *name;                          /* argument */
@@ -187,19 +183,19 @@ print_partial_line(struct utmp *bp) {
     char *ct;
 
     ct = utmp_ctime(bp);
-    printf("%-*.*s  %-*.*s ", nmax, nmax, bp->ut_name, 
-          lmax, lmax, bp->ut_line);
+    printf("%-*.*s  %-*.*s ", P_NMAX, P_NMAX, bp->ut_name,
+          P_LMAX, P_LMAX, bp->ut_line);
 
     if (dolong) {
        if (bp->ut_addr) {
            struct in_addr foo;
            foo.s_addr = bp->ut_addr;
-           printf("%-*.*s ", hmax, hmax, inet_ntoa(foo));
+           printf("%-*.*s ", P_HMAX, P_HMAX, inet_ntoa(foo));
        } else {
-           printf("%-*.*s ", hmax, hmax, "");
+           printf("%-*.*s ", P_HMAX, P_HMAX, "");
        }
     } else {
-       printf("%-*.*s ", hmax, hmax, bp->ut_host);
+       printf("%-*.*s ", P_HMAX, P_HMAX, bp->ut_host);
     }
 
     if (doyear) {