shadow-maint / shadow

Upstream shadow tree
Other
292 stars 228 forks source link

su.c: build failure with GCC 14 (-Wincompatible-pointer-types) #915

Closed thesamesam closed 7 months ago

thesamesam commented 7 months ago

GCC 14 will make -Wincompatible-pointer-types as well as some other serious warnings errors by default. See https://wiki.gentoo.org/wiki/Modern_C_porting#What_changed.3F for the full list.

shadow master at 08ae7af111aaf8eb399b6ca2d473f4fc0c353dc6 fails to build with:

su.c:669:44: error: passing argument 3 of ‘pam_get_item’ from incompatible pointer type [-Wincompatible-pointer-types]
  669 |         ret = pam_get_item(pamh, PAM_USER, &tmp_name);
      |                                            ^~~~~~~~~
      |                                            |
      |                                            const char **
In file included from /usr/include/security/pam_appl.h:18,
                 from ../lib/pam_defs.h:9,
                 from su.c:56:
/usr/include/security/_pam_types.h:181:68: note: expected ‘const void **’ but argument is of type ‘const char **’
  181 | pam_get_item(const pam_handle_t *pamh, int item_type, const void **item);
      |                                                       ~~~~~~~~~~~~~^~~~
su.c: In function ‘main’:
su.c:1229:26: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
 1229 |                 argv[-1] = cp;
      |                          ^
make[2]: *** [Makefile:1213: su.o] Error 1
thesamesam commented 7 months ago

Introduced by ef95bb7ed1395ee60212ad615eca3d7a1c2d013d (@alejandro-colomar).

alejandro-colomar commented 7 months ago

Hmmm, I'll try to fix this without reintroducing the fprintf(3) warning and without resorting to casts. Thanks!