Skip to content
Snippets Groups Projects

Fix -Wincompatible-pointer-types warning from gcc (issue #15)

Merged Alan Coopersmith requested to merge alanc/xdm:gcc into master

Fix warning that gcc 14 will make into an error

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Thanks, this lgtm and it also fixes the reported issue.

  • Jeremy Huddleston Sequoia approved this merge request

    approved this merge request

    • Looks like still some cleanups are necessary and this commit is not enough

      make[2]: Entering directory '/home/tkloczko/rpmbuild/BUILD/xdm-1.1.14/greeter'
      /bin/sh ../libtool  --tag=CC   --mode=compile /usr/bin/gcc -DHAVE_CONFIG_H -I. -I..  -I../include  -fno-strict-aliasing -I/usr/include/freetype2   -DGREET_LIB -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -O2 -g -grecord-gcc-switches -pipe -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdata-sections -ffunction-sections -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -flto=auto -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -Wall -Werror=format-security -Os -c -o greet.lo greet.c
      libtool: compile:  /usr/bin/gcc -DHAVE_CONFIG_H -I. -I.. -I../include -fno-strict-aliasing -I/usr/include/freetype2 -DGREET_LIB -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -O2 -g -grecord-gcc-switches -pipe -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdata-sections -ffunction-sections -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -flto=auto -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -Wall -Werror=format-security -Os -c greet.c  -fPIC -DPIC -o .libs/greet.o
      greet.c: In function 'log_to_audit_system':
      greet.c:435:40: error: passing argument 3 of 'pam_get_item' from incompatible pointer type [-Wincompatible-pointer-types]
        435 |         pam_get_item(pamhp, PAM_RHOST, &hostname);
            |                                        ^~~~~~~~~
            |                                        |
            |                                        char **
      In file included from /usr/include/security/pam_appl.h:18,
                       from ../include/dm.h:105,
                       from greet.c:73:
      /usr/include/security/_pam_types.h:175:68: note: expected 'const void **' but argument is of type 'char **'
        175 | pam_get_item(const pam_handle_t *pamh, int item_type, const void **item);
            |                                                       ~~~~~~~~~~~~~^~~~
      greet.c:436:38: error: passing argument 3 of 'pam_get_item' from incompatible pointer type [-Wincompatible-pointer-types]
        436 |         pam_get_item(pamhp, PAM_TTY, &tty);
            |                                      ^~~~
            |                                      |
            |                                      char **
      /usr/include/security/_pam_types.h:175:68: note: expected 'const void **' but argument is of type 'char **'
        175 | pam_get_item(const pam_handle_t *pamh, int item_type, const void **item);
            |                                                       ~~~~~~~~~~~~~^~~~
      greet.c:437:39: error: passing argument 3 of 'pam_get_item' from incompatible pointer type [-Wincompatible-pointer-types]
        437 |         pam_get_item(pamhp, PAM_USER, &login);
            |                                       ^~~~~~
            |                                       |
            |                                       char **
      /usr/include/security/_pam_types.h:175:68: note: expected 'const void **' but argument is of type 'char **'
        175 | pam_get_item(const pam_handle_t *pamh, int item_type, const void **item);
            |                                                       ~~~~~~~~~~~~~^~~~
      greet.c:440:9: warning: ignoring return value of 'audit_log_acct_message' declared with attribute 'warn_unused_result' [-Wunused-result]
        440 |         audit_log_acct_message(audit_fd, AUDIT_USER_LOGIN,
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        441 |                 NULL, "login", login ? login : "(unknown)",
            |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        442 |                 pw ? pw->pw_uid : -1, hostname, NULL, tty, success);
            |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      make[2]: *** [Makefile:539: greet.lo] Error 1
    • Ah, I didn't see those in my Solaris builds because the Solaris pam_appl.h has:

      extern int
      pam_get_item(
              const pam_handle_t *__pamh,     /* PAM handle */
              int __item_type,                /* Type of object - see below */
              void ** __item                  /* Address of place to put pointer */
                                              /*   to object */
      );
    • Strangely, I also don't see any warnings for pam_get_item() in our CI logs when building on Debian stable.

    • !19 (merged) is my attempt to fix.

    • Strangely, I also don't see any warnings for pam_get_item() in our CI logs when building on Debian stable.

      Please try to build with -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3. This define is used by devel glibc so testing this on top of Debian stable does not make to much sense.

      Edited by Tomasz Kłoczko
    • Building on a Linux system with those flags gives me a few more warnings, but no new errors. If you're having problems with your particular setup after pulling the changes I merged for the PAM functions already, you can submit a merge request to fix them.

    • Please register or sign in to reply
  • mentioned in issue #16 (closed)

Please register or sign in to reply
Loading