]> granicus.if.org Git - shadow/commitdiff
Fix some compilation warnings:
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Mon, 19 Nov 2007 20:25:36 +0000 (20:25 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Mon, 19 Nov 2007 20:25:36 +0000 (20:25 +0000)
 * src/login.c: "dereferencing type-punned pointer will break
   strict-aliasing rules", add a variable indirection: ptr_pam_user.
 * lib/commonio.c: do not initialize the sb stat structure.
 * lib/pwio.c, lib/shadowio.c, lib/sgroupio.c, lib/groupio.c:
   initialize the security context if WITH_SELINUX.
 * lib/nscd.c: The service argument is not const (used in the exec*
   parameters). This matches with the prototype definition.
 * src/groupmems.c: Avoid ++i when i is also used in the same line.
 * src/newusers.c: i is positive every time it is compared. Add
   cast to unsigned int.
 * src/nologin.c: Use a main() prototype with no arguments.
 * libmisc/getdate.y: Initialize the type and value fields of the
   terminating entry for each TABLE.
 * libmisc/tz.c: Use "TZ=CST6CDT" as the default timezone.

13 files changed:
ChangeLog
lib/commonio.c
lib/groupio.c
lib/nscd.c
lib/pwio.c
lib/sgroupio.c
lib/shadowio.c
libmisc/getdate.y
libmisc/tz.c
src/groupmems.c
src/login.c
src/newusers.c
src/nologin.c

index 559dfaef3b9eb18b26b7e6b6f9ad688e25ab6a5a..53697ebd53a943e4e2724747e36522f60ef11e83 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2007-11-19  Nicolas François  <nicolas.francois@centraliens.net>
+
+       Fix some compilation warnings:
+       * src/login.c: "dereferencing type-punned pointer will break
+       strict-aliasing rules", add a variable indirection: ptr_pam_user.
+       * lib/commonio.c: do not initialize the sb stat structure.
+       * lib/pwio.c, lib/shadowio.c, lib/sgroupio.c, lib/groupio.c:
+       initialize the security context if WITH_SELINUX.
+       * lib/nscd.c: The service argument is not const (used in the exec*
+       parameters). This matches with the prototype definition.
+       * src/groupmems.c: Avoid ++i when i is also used in the same line.
+       * src/newusers.c: i is positive every time it is compared. Add
+       cast to unsigned int.
+       * src/nologin.c: Use a main() prototype with no arguments.
+       * libmisc/getdate.y: Initialize the type and value fields of the
+       terminating entry for each TABLE.
+       * libmisc/tz.c: Use "TZ=CST6CDT" as the default timezone.
+
 2007-11-19  Nicolas François  <nicolas.francois@centraliens.net>
 
        * man/pl/Makefile.am: Add getspnam.3 to EXTRA_DIST since it is
index 85eb7c416831dc899abec226650e38e17ff4eeff..a1e7e1efd38e8924ace90f0de7d858102712e5d0 100644 (file)
@@ -53,7 +53,7 @@ int lrename (const char *old, const char *new)
        int res;
 
 #if defined(S_ISLNK)
-       struct stat sb = { 0 };
+       struct stat sb;
        if (lstat (new, &sb) == 0 && S_ISLNK (sb.st_mode)) {
                if (realpath (new, resolved_path) == NULL) {
                        perror ("realpath in lrename()");
index 18a8f49a0a9a096af4eace489cfe5a9ed8a5f113..686dca954b9ffc5db7ae3f41362e77d6600149bb 100644 (file)
@@ -63,6 +63,9 @@ static struct commonio_db group_db = {
        GROUP_FILE,             /* filename */
        &group_ops,             /* ops */
        NULL,                   /* fp */
+#ifdef WITH_SELINUX
+       NULL,                   /* scontext */
+#endif
        NULL,                   /* head */
        NULL,                   /* tail */
        NULL,                   /* cursor */
index d897af74c098da82e92c347296322aa9eac264e1..baa5f6e5759e6284ee16f5c98774efcf53e14dbf 100644 (file)
@@ -16,7 +16,7 @@
 /*
  * nscd_flush_cache - flush specified service buffer in nscd cache
  */
-int nscd_flush_cache (const char *service)
+int nscd_flush_cache (char *service)
 {
        pid_t pid, termpid;
        int err, status;
index 14702ff51279e47b6a6bcb54d4d30f9ddde33317..ae99b411360c2ba31da56e7c02409252cb135342 100644 (file)
@@ -64,6 +64,9 @@ static struct commonio_db passwd_db = {
        PASSWD_FILE,            /* filename */
        &passwd_ops,            /* ops */
        NULL,                   /* fp */
+#ifdef WITH_SELINUX
+       NULL,                   /* scontext */
+#endif
        NULL,                   /* head */
        NULL,                   /* tail */
        NULL,                   /* cursor */
index 4666b08511378a1f85cd45c67cd89291e1864dc5..cf3f2dd142a6fcb2a796daf72c7c5aed4c3dc075 100644 (file)
@@ -107,6 +107,9 @@ static struct commonio_db gshadow_db = {
        SGROUP_FILE,            /* filename */
        &gshadow_ops,           /* ops */
        NULL,                   /* fp */
+#ifdef WITH_SELINUX
+       NULL,                   /* scontext */
+#endif
        NULL,                   /* head */
        NULL,                   /* tail */
        NULL,                   /* cursor */
index b7bd2e1bd21efb2d39ad623802aa90f3a8ba9d8b..d22f0c6ea4e9425e930f0654ed4a260562dd4c6e 100644 (file)
@@ -61,6 +61,9 @@ static struct commonio_db shadow_db = {
        SHADOW_FILE,            /* filename */
        &shadow_ops,            /* ops */
        NULL,                   /* fp */
+#ifdef WITH_SELINUX
+       NULL,                   /* scontext */
+#endif
        NULL,                   /* head */
        NULL,                   /* tail */
        NULL,                   /* cursor */
index e4504e3e920f5ee232db1b7c92d4f9e79086270c..134b3f19d40f3eea93307ab69e83a0a1956088a5 100644 (file)
@@ -464,7 +464,7 @@ static TABLE const MonthDayTable[] = {
     { "thurs",         tDAY, 4 },
     { "friday",                tDAY, 5 },
     { "saturday",      tDAY, 6 },
-    { NULL }
+    { NULL, 0, 0 }
 };
 
 /* Time units table. */
@@ -479,7 +479,7 @@ static TABLE const UnitsTable[] = {
     { "min",           tMINUTE_UNIT,   1 },
     { "second",                tSEC_UNIT,      1 },
     { "sec",           tSEC_UNIT,      1 },
-    { NULL }
+    { NULL, 0, 0 }
 };
 
 /* Assorted relative-time words. */
@@ -504,7 +504,7 @@ static TABLE const OtherTable[] = {
     { "eleventh",      tUNUMBER,       11 },
     { "twelfth",       tUNUMBER,       12 },
     { "ago",           tAGO,   1 },
-    { NULL }
+    { NULL, 0, 0 }
 };
 
 /* The timezone table. */
@@ -559,7 +559,7 @@ static TABLE const TimezoneTable[] = {
     { "nzst",  tZONE,     -HOUR (12) },        /* New Zealand Standard */
     { "nzdt",  tDAYZONE,  -HOUR (12) },        /* New Zealand Daylight */
     { "idle",  tZONE,     -HOUR (12) },        /* International Date Line East */
-    {  NULL  }
+    { NULL, 0, 0 }
 };
 
 /* Military timezone table. */
@@ -589,7 +589,7 @@ static TABLE const MilitaryTable[] = {
     { "x",     tZONE,  HOUR (-11) },
     { "y",     tZONE,  HOUR (-12) },
     { "z",     tZONE,  HOUR (  0) },
-    { NULL }
+    { NULL, 0, 0 }
 };
 
 \f
index 73829d75a4e0b302f1105e32abf173f40b0064a5..6ea0fcebd74fa7764e0cfacf90cd77f290a34c05 100644 (file)
@@ -45,7 +45,7 @@ char *tz (const char *fname)
 {
        FILE *fp = 0;
        static char tzbuf[BUFSIZ];
-       const char *def_tz;
+       const char *def_tz = "TZ=CST6CDT";
 
        if ((fp = fopen (fname, "r")) == NULL ||
            fgets (tzbuf, sizeof (tzbuf), fp) == NULL) {
index 97252e9ddb0413a00b0de4831a00910478bdca11..cb78ce24cd02552cc31ccf1ffd08536e948bc933 100644 (file)
@@ -126,7 +126,8 @@ static void rmfromgroup (char *user, char **members)
        }
 
        while (found && NULL != members[i]) {
-               members[i] = members[++i];
+               members[i] = members[i+1];
+               i++;
        }
 
        if (!found) {
index beb55f838063b312b912caa29f7fad594538f8ba..1120d2635929758f023d9e603c5ebed2aa5cca77 100644 (file)
@@ -348,6 +348,7 @@ int main (int argc, char **argv)
        int retcode;
        pid_t child;
        char *pam_user;
+       char **ptr_pam_user = &pam_user;
 #else
        struct spwd *spwd = NULL;
 #endif
@@ -620,7 +621,7 @@ int main (int argc, char **argv)
                        /* if we didn't get a user on the command line,
                           set it to NULL */
                        pam_get_item (pamh, PAM_USER,
-                                     (const void **) &pam_user);
+                                     (const void **)ptr_pam_user);
                        if (pam_user[0] == '\0')
                                pam_set_item (pamh, PAM_USER, NULL);
 
@@ -644,7 +645,7 @@ int main (int argc, char **argv)
                          retcode = pam_authenticate (pamh, 0);
 
                          pam_get_item (pamh, PAM_USER,
-                                       (const void **) &pam_user);
+                                       (const void **) ptr_pam_user);
 
                          if (pam_user && pam_user[0]) {
                            pwd = xgetpwnam(pam_user);
@@ -737,7 +738,7 @@ int main (int argc, char **argv)
                   First get the username that we are actually using, though.
                 */
                retcode =
-                   pam_get_item (pamh, PAM_USER, (const void **) &pam_user);
+                   pam_get_item (pamh, PAM_USER, (const void **)ptr_pam_user);
                setpwent ();
                pwd = xgetpwnam (pam_user);
                if (!pwd) {
index f2885902575a5777ae2ed3d2ea972be7f4d027cb..ce27fb9cc03775a4d6920546ba197fa9fb618615 100644 (file)
@@ -116,11 +116,11 @@ static int add_group (const char *name, const char *gid, gid_t * ngid)
        if (gid[0] == '\0') {
                i = 100;
                for (pw_rewind (); (pwd = pw_next ());) {
-                       if (pwd->pw_uid >= i)
+                       if (pwd->pw_uid >= (unsigned int)i)
                                i = pwd->pw_uid + 1;
                }
                for (gr_rewind (); (grp = gr_next ());) {
-                       if (grp->gr_gid == i) {
+                       if (grp->gr_gid == (unsigned int)i) {
                                i = -1;
                                break;
                        }
@@ -133,7 +133,7 @@ static int add_group (const char *name, const char *gid, gid_t * ngid)
                 */
                i = atoi (gid);
                for (gr_rewind (); (grp = gr_next ());)
-                       if (grp->gr_gid == i)
+                       if (grp->gr_gid == (unsigned int)i)
                                goto add_member;
        } else
                /*
@@ -149,7 +149,7 @@ static int add_group (const char *name, const char *gid, gid_t * ngid)
         */
        if (i == -1) {
                for (i = 100, gr_rewind (); (grp = gr_next ());)
-                       if (grp->gr_gid >= i)
+                       if (grp->gr_gid >= (unsigned int)i)
                                i = grp->gr_gid + 1;
        }
 
index 85d5463194f769a406d9a6f85befb768994f1f4f..3fa7edb401e9d7dfaa336dba6c97aaf6fa9306b4 100644 (file)
@@ -30,7 +30,7 @@
 #include <unistd.h>
 #include "exitcodes.h"
 
-int main (int argc, char **argv)
+int main ()
 {
        const char *user, *tty;