]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Declare read-only lookup pointers const
authorChristian Göttsche <cgzones@googlemail.com>
Mon, 3 Jan 2022 11:26:25 +0000 (12:26 +0100)
committerChristian Göttsche <cgzones@googlemail.com>
Mon, 3 Jan 2022 14:09:17 +0000 (15:09 +0100)
pwck.c:587:31: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
  587 |                         spw = (struct spwd *) spw_locate (pwd->pw_name);
      |                               ^

grpck.c:599:31: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
  599 |                         sgr = (struct sgrp *) sgr_locate (grp->gr_name);
      |                               ^

grpck.c:761:23: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
  761 |                 grp = (struct group *) gr_locate (sgr->sg_name);
      |                       ^

src/grpck.c
src/pwck.c

index 7accac946cbc6ce8a7c8273c0e42826be19fc065..881fb4de716dae65530753be97f7622e92d0a86a 100644 (file)
@@ -455,7 +455,7 @@ static void check_grp_file (int *errors, bool *changed)
        struct commonio_entry *gre, *tgre;
        struct group *grp;
 #ifdef SHADOWGRP
-       struct sgrp *sgr;
+       const struct sgrp *sgr;
 #endif
 
        /*
@@ -596,7 +596,7 @@ static void check_grp_file (int *errors, bool *changed)
                 */
 
                if (is_shadow) {
-                       sgr = (struct sgrp *) sgr_locate (grp->gr_name);
+                       sgr = sgr_locate (grp->gr_name);
                        if (sgr == NULL) {
                                printf (_("no matching group file entry in %s\n"),
                                        sgr_file);
@@ -663,7 +663,7 @@ static void check_grp_file (int *errors, bool *changed)
  */
 static void check_sgr_file (int *errors, bool *changed)
 {
-       struct group *grp;
+       const struct group *grp;
        struct commonio_entry *sge, *tsge;
        struct sgrp *sgr;
 
@@ -758,7 +758,7 @@ static void check_sgr_file (int *errors, bool *changed)
                /*
                 * Make sure this entry exists in the /etc/group file.
                 */
-               grp = (struct group *) gr_locate (sgr->sg_name);
+               grp = gr_locate (sgr->sg_name);
                if (grp == NULL) {
                        printf (_("no matching group file entry in %s\n"),
                                grp_file);
index ee1df500ff0587b1cd16d19be9f08d7196ffa1b2..28209131d2413805a7c6575dd31ade22d8067be9 100644 (file)
@@ -366,7 +366,7 @@ static void check_pw_file (int *errors, bool *changed)
 {
        struct commonio_entry *pfe, *tpfe;
        struct passwd *pwd;
-       struct spwd *spw;
+       const struct spwd *spw;
        uid_t min_sys_id = (uid_t) getdef_ulong ("SYS_UID_MIN", 101UL);
        uid_t max_sys_id = (uid_t) getdef_ulong ("SYS_UID_MAX", 999UL);
 
@@ -584,7 +584,7 @@ static void check_pw_file (int *errors, bool *changed)
                                spw_opened = true;
                        }
 #endif                         /* WITH_TCB */
-                       spw = (struct spwd *) spw_locate (pwd->pw_name);
+                       spw = spw_locate (pwd->pw_name);
                        if (NULL == spw) {
                                printf (_("no matching password file entry in %s\n"),
                                        spw_dbname ());