Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compile warnings #605

Merged
merged 2 commits into from
Nov 21, 2024
Merged

Conversation

ofaaland
Copy link
Collaborator

Fix three compile warnings observed when building with gcc (GCC) 12.2.1 20221121 (Red Hat 12.2.1-7)

  1. Extra token at end of #endif
            [ 21%] Building C object src/common/CMakeFiles/mfu_o.dir/mfu_io.c.o
            src/common/mfu_io.c:1673:8: warning: extra tokens at end of #endif directive [-Wendif-labels]
             1673 | #endif DCOPY_USE_XATTRS
                  |        ^~~~~~~~~~~~~~~~
  1. Implicit declaration of setgroups()
            src/dcp/dcp.c:416:13: warning: implicit declaration of function ‘setgroups’; did you mean ‘getgroups’? [-Wimplicit-function-declaration]
              416 |         if (setgroups(0, NULL) < 0) {
                  |             ^~~~~~~~~
                  |             getgroups
            [ 50%] Linking C executable dcp
  1. Incorrect type passed to getgroups()
            src/dcp/dcp.c:407:42: warning: passing argument 2 of ‘getgroups’ from incompatible pointer type [-Wincompatible-pointer-types]
              407 |         gids_count = getgroups(MAX_GIDS, &gids);
                  |                                          ^~~~~
                  |                                          |
                  |                                          uid_t (*)[100] {aka unsigned int (*)[100]}
            In file included from src/dcp/dcp.c:7:
            /usr/include/unistd.h:689:43: note: expected ‘__gid_t *’ {aka ‘unsigned int *’} but argument is of type ‘uid_t (*)[100]’ {aka ‘unsigned int (*)[100]’}
              689 | extern int getgroups (int __size, __gid_t __list[]) __THROW __wur;

The use of setgroups() requires including <grp.h>.

Fixes warning:

	src/dcp/dcp.c:416:13: warning: implicit declaration of function ‘setgroups’; did you mean ‘getgroups’? [-Wimplicit-function-declaration]
	  416 |         if (setgroups(0, NULL) < 0) {
	      |             ^~~~~~~~~
	      |             getgroups
	[ 50%] Linking C executable dcp

gids[MAX_GIDS] is used by getgroups().  The second argument should be of type gid_t *.

Fixes warning:

	src/dcp/dcp.c:407:42: warning: passing argument 2 of ‘getgroups’ from incompatible pointer type [-Wincompatible-pointer-types]
	  407 |         gids_count = getgroups(MAX_GIDS, &gids);
	      |                                          ^~~~~
	      |                                          |
	      |                                          uid_t (*)[100] {aka unsigned int (*)[100]}
	In file included from src/dcp/dcp.c:7:
	/usr/include/unistd.h:689:43: note: expected ‘__gid_t *’ {aka ‘unsigned int *’} but argument is of type ‘uid_t (*)[100]’ {aka ‘unsigned int (*)[100]’}
	  689 | extern int getgroups (int __size, __gid_t __list[]) __THROW __wur;

Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
Fix this warning:

	[ 21%] Building C object src/common/CMakeFiles/mfu_o.dir/mfu_io.c.o
	src/common/mfu_io.c:1673:8: warning: extra tokens at end of #endif directive [-Wendif-labels]
	 1673 | #endif DCOPY_USE_XATTRS
	      |        ^~~~~~~~~~~~~~~~

The DCOPY_USE_XATTRS is a helpful clue to which #if corresponds to the
endif, but the endif pragma does not take an argument.

Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
@ofaaland ofaaland self-assigned this Nov 21, 2024
@ofaaland
Copy link
Collaborator Author

@bdevcich see above minor fixes to gid-related code.

@bdevcich
Copy link
Contributor

Thanks @ofaaland. Not sure how I missed this.

@ofaaland ofaaland merged commit 27426d7 into hpc:main Nov 21, 2024
@ofaaland ofaaland deleted the faaland-compile-warnings-1 branch November 21, 2024 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants