Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libpam/modules/pam_lastlog Introduce a few more temporar...



details:   https://anonhg.NetBSD.org/src/rev/e97d0ed2b53a
branches:  trunk
changeset: 573662:e97d0ed2b53a
user:      he <he%NetBSD.org@localhost>
date:      Fri Feb 04 15:11:35 2005 +0000

description:
Introduce a few more temporary variables, in order to avoid an ugly
double cast in the pam_get_item() invocations.  The double cast
triggered a "discards qualifier" warning/error from gcc 2.95.3, while
trying to fix that by adding "cost" to the "void *" cast produced
a similar warning from gcc 3.3.  This now compiles without warning
with both compilers.

Approved by christos

diffstat:

 lib/libpam/modules/pam_lastlog/pam_lastlog.c |  25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)

diffs (70 lines):

diff -r e218cb3bd43d -r e97d0ed2b53a lib/libpam/modules/pam_lastlog/pam_lastlog.c
--- a/lib/libpam/modules/pam_lastlog/pam_lastlog.c      Fri Feb 04 15:07:54 2005 +0000
+++ b/lib/libpam/modules/pam_lastlog/pam_lastlog.c      Fri Feb 04 15:11:35 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pam_lastlog.c,v 1.3 2005/02/01 17:54:48 christos Exp $ */
+/*     $NetBSD: pam_lastlog.c,v 1.4 2005/02/04 15:11:35 he Exp $       */
 
 /*-
  * Copyright (c) 1980, 1987, 1988, 1991, 1993, 1994
@@ -47,7 +47,7 @@
 #ifdef __FreeBSD__
 __FBSDID("$FreeBSD: src/lib/libpam/modules/pam_lastlog/pam_lastlog.c,v 1.20 2004/01/26 19:28:37 des Exp $");
 #else
-__RCSID("$NetBSD: pam_lastlog.c,v 1.3 2005/02/01 17:54:48 christos Exp $");
+__RCSID("$NetBSD: pam_lastlog.c,v 1.4 2005/02/04 15:11:35 he Exp $");
 #endif
 
 #include <sys/param.h>
@@ -92,6 +92,7 @@
        struct passwd *pwd;
        struct timeval now;
        const char *user, *rhost, *tty;
+       const void *vrhost, *vtty, *vss;
        const struct sockaddr_storage *ss;
        int pam_err;
 
@@ -104,20 +105,20 @@
 
        PAM_LOG("Got user: %s", user);
 
-       pam_err = pam_get_item(pamh, PAM_RHOST,
-           (const void **)(void *)&rhost);
+       pam_err = pam_get_item(pamh, PAM_RHOST, &vrhost);
        if (pam_err != PAM_SUCCESS)
                goto err;
+       rhost = (const char *)vrhost;
 
-       pam_err = pam_get_item(pamh, PAM_SOCKADDR,
-           (const void **)(void *)&ss);
+       pam_err = pam_get_item(pamh, PAM_SOCKADDR, &vss);
        if (pam_err != PAM_SUCCESS)
                goto err;
+       ss = (const struct sockaddr_storage *)vss;
 
-       pam_err = pam_get_item(pamh, PAM_TTY,
-           (const void **)(void *)&tty);
+       pam_err = pam_get_item(pamh, PAM_TTY, &vtty);
        if (pam_err != PAM_SUCCESS)
                goto err;
+       tty = (const char *)vtty;
 
        if (tty == NULL) {
                pam_err = PAM_SERVICE_ERR;
@@ -152,11 +153,13 @@
 pam_sm_close_session(pam_handle_t *pamh __unused, int flags __unused,
     int argc __unused, const char *argv[] __unused)
 {
-        const char *tty;
+       const void *vtty;
+       const char *tty;
 
-        pam_get_item(pamh, PAM_TTY, (const void **)(void *)&tty);
-       if (tty == NULL)
+       pam_get_item(pamh, PAM_TTY, &vtty);
+       if (vtty == NULL)
                return PAM_SERVICE_ERR;
+       tty = (const char *)vtty;
 
        if (strncmp(tty, _PATH_DEV, strlen(_PATH_DEV)) == 0)
                tty = tty + strlen(_PATH_DEV);



Home | Main Index | Thread Index | Old Index