Declare read-only lookup pointers const

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);
      |                       ^
This commit is contained in:
Christian Göttsche 2022-01-03 12:26:25 +01:00
parent a74114fe34
commit 7909308285
2 changed files with 6 additions and 6 deletions

View File

@ -455,7 +455,7 @@ static void check_grp_file (int *errors, bool *changed)
struct commonio_entry *gre, *tgre; struct commonio_entry *gre, *tgre;
struct group *grp; struct group *grp;
#ifdef SHADOWGRP #ifdef SHADOWGRP
struct sgrp *sgr; const struct sgrp *sgr;
#endif #endif
/* /*
@ -596,7 +596,7 @@ static void check_grp_file (int *errors, bool *changed)
*/ */
if (is_shadow) { if (is_shadow) {
sgr = (struct sgrp *) sgr_locate (grp->gr_name); sgr = sgr_locate (grp->gr_name);
if (sgr == NULL) { if (sgr == NULL) {
printf (_("no matching group file entry in %s\n"), printf (_("no matching group file entry in %s\n"),
sgr_file); sgr_file);
@ -663,7 +663,7 @@ static void check_grp_file (int *errors, bool *changed)
*/ */
static void check_sgr_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 commonio_entry *sge, *tsge;
struct sgrp *sgr; 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. * 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) { if (grp == NULL) {
printf (_("no matching group file entry in %s\n"), printf (_("no matching group file entry in %s\n"),
grp_file); grp_file);

View File

@ -366,7 +366,7 @@ static void check_pw_file (int *errors, bool *changed)
{ {
struct commonio_entry *pfe, *tpfe; struct commonio_entry *pfe, *tpfe;
struct passwd *pwd; 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 min_sys_id = (uid_t) getdef_ulong ("SYS_UID_MIN", 101UL);
uid_t max_sys_id = (uid_t) getdef_ulong ("SYS_UID_MAX", 999UL); 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; spw_opened = true;
} }
#endif /* WITH_TCB */ #endif /* WITH_TCB */
spw = (struct spwd *) spw_locate (pwd->pw_name); spw = spw_locate (pwd->pw_name);
if (NULL == spw) { if (NULL == spw) {
printf (_("no matching password file entry in %s\n"), printf (_("no matching password file entry in %s\n"),
spw_dbname ()); spw_dbname ());