bug#20923: mgetgroups.c vs getgrouplist warning on OS X
On Tue, Jun 30, 2015 at 9:36 AM, Paul Eggert wrote: > Jim Meyering wrote: > >> same result as before: > > OK, let's give up on this approach and try something more direct. I > installed the attached patch; does it work on OS X? Perfect. I made latest coreutils use latest from gnulib, and now it all compiles warning-free there with --enable-gcc-warnings and gcc-6.x Thank you!
bug#20923: mgetgroups.c vs getgrouplist warning on OS X
Jim Meyering wrote: same result as before: OK, let's give up on this approach and try something more direct. I installed the attached patch; does it work on OS X? >From b1a1450d454698a765a625804fe336305209c696 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 30 Jun 2015 09:32:07 -0700 Subject: [PATCH] mgetgroups: port to strict OS X The previous fix wasn't working, so use a bigger hammer (Bug#20923). * lib/mgetgroups.c: Ignore -Wpointer-sign diagnostics. (getgrouplist_gids) [HAVE_GETGROUPLIST]: Remove. All uses removed. * m4/mgetgroups.m4 (gl_MGETGROUPS): Revert recent changes. --- ChangeLog| 8 lib/mgetgroups.c | 14 +++--- m4/mgetgroups.m4 | 35 +-- 3 files changed, 16 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index cb6ca08..37120cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2015-06-30 Paul Eggert + + mgetgroups: port to strict OS X + The previous fix wasn't working, so use a bigger hammer (Bug#20923). + * lib/mgetgroups.c: Ignore -Wpointer-sign diagnostics. + (getgrouplist_gids) [HAVE_GETGROUPLIST]: Remove. All uses removed. + * m4/mgetgroups.m4 (gl_MGETGROUPS): Revert recent changes. + 2015-06-29 Paul Eggert mgetgroups: port to strict OS X diff --git a/lib/mgetgroups.c b/lib/mgetgroups.c index dd0c7a5..6acb019 100644 --- a/lib/mgetgroups.c +++ b/lib/mgetgroups.c @@ -33,6 +33,12 @@ #include "getugroups.h" #include "xalloc-oversized.h" +/* Work around an incompatibility of OS X 10.11: getgrouplist + accepts int *, not gid_t *, and int and gid_t differ in sign. */ +#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) +# pragma GCC diagnostic ignored "-Wpointer-sign" +#endif + static gid_t * realloc_groupbuf (gid_t *g, size_t num) { @@ -64,11 +70,6 @@ mgetgroups (char const *username, gid_t gid, gid_t **groups) gid_t *g; #if HAVE_GETGROUPLIST -# if HAVE_GETGROUPLIST_WITH_INT -# define getgrouplist_gids(g) ((int *) (g)) -# else -# define getgrouplist_gids(g) (g) -# endif /* We prefer to use getgrouplist if available, because it has better performance characteristics. @@ -92,8 +93,7 @@ mgetgroups (char const *username, gid_t gid, gid_t **groups) int last_n_groups = max_n_groups; /* getgrouplist updates max_n_groups to num required. */ - ng = getgrouplist (username, gid, getgrouplist_gids (g), - &max_n_groups); + ng = getgrouplist (username, gid, g, &max_n_groups); /* Some systems (like Darwin) have a bug where they never increase max_n_groups. */ diff --git a/m4/mgetgroups.m4 b/m4/mgetgroups.m4 index 5747148..42b5cf8 100644 --- a/m4/mgetgroups.m4 +++ b/m4/mgetgroups.m4 @@ -1,4 +1,4 @@ -#serial 7 +#serial 5 dnl Copyright (C) 2007-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,38 +6,5 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_MGETGROUPS], [ - AC_CHECK_HEADERS_ONCE([grp.h]) AC_CHECK_FUNCS_ONCE([getgrouplist]) - if test "$ac_cv_func_getgrouplist" = yes; then -AC_CACHE_CHECK([for getgrouplist with int signature], - [gl_cv_getgrouplist_with_int], - [gl_cv_getgrouplist_with_int=no - gl_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( -[[#if HAVE_GRP_H - #include - #endif - int groups[1]; - int ngroups = 1; -]], -[[return - getgrouplist ("root", 0, groups, &ngroups);]])], - [], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[#if HAVE_GRP_H - #include -#endif -int groups[sizeof (gid_t) == sizeof (int) ? 1 : -1]; -int ngroups = 1; - ]], - [[return - getgrouplist ("root", 0, groups, &ngroups);]])], -[gl_cv_getgrouplist_with_int=yes])]) - ac_c_werror_flag=$gl_save_c_werror_flag]) -if test "$gl_cv_getgrouplist_with_int" = yes; then - AC_DEFINE([HAVE_GETGROUPLIST_WITH_INT], 1, -[Define to 1 if getgrouplist accepts and returns int and not gid_t.]) -fi - fi ]) -- 2.1.0
bug#20923: mgetgroups.c vs getgrouplist warning on OS X
On Mon, Jun 29, 2015 at 7:19 PM, Paul Eggert wrote: > Jim Meyering wrote: >> >> Darn it. I see that I mistakenly pushed one of your patches >> when I pushed the linkat.m4 fix, Paul. Sorry about that. >> Happy to revert, if you'd like that. Let me know. > > No problem. I installed the attached further patch; does it fix things for > you? If we can't get this to work I can revert the whole thing. Thanks. I adjusted via the attached patch (the declaration of getgrouplist is in , and the "then"-block should use gid_t), and tested: there was not even a warning for the test program emitted by the "then"-block, so same result as before: lib/mgetgroups.c: In function 'mgetgroups': lib/mgetgroups.c:70:32: error: pointer targets in passing argument 3 of 'getgrouplist' differ in signedness [-Werror=pointer-sign] # define getgrouplist_gids(g) (g) ^ mgetgroups.m4.patch Description: Binary data
bug#20923: mgetgroups.c vs getgrouplist warning on OS X
Jim Meyering wrote: Darn it. I see that I mistakenly pushed one of your patches when I pushed the linkat.m4 fix, Paul. Sorry about that. Happy to revert, if you'd like that. Let me know. No problem. I installed the attached further patch; does it fix things for you? If we can't get this to work I can revert the whole thing. >From 3722df12ad7d5f13dc8bf2cf0ddc329f0541fb86 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 29 Jun 2015 19:12:07 -0700 Subject: [PATCH] mgetgroups: fix port to strict OS X * m4/mgetgroups.m4 (gl_MGETGROUPS): Use more-sensitive -Werror setting if available. --- ChangeLog| 11 +++ m4/mgetgroups.m4 | 17 +++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 465bf0e..cb6ca08 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2015-06-29 Paul Eggert + + mgetgroups: port to strict OS X + * doc/glibc-functions/getgrouplist.texi (getgrouplist): + Document the getgrouplist problem. + * lib/mgetgroups.c (getgrouplist_gids) [HAVE_GETGROUPLIST]: + New macro. + (mgetgroups): Use it. + * m4/mgetgroups.m4 (gl_MGETGROUPS): + Check for OS X signature for getgrouplist. + 2015-06-29 Jim Meyering linkat: fix invalid definition of LINKAT_SYMLINK_NOTSUP on OS X diff --git a/m4/mgetgroups.m4 b/m4/mgetgroups.m4 index 5f19d4f..5747148 100644 --- a/m4/mgetgroups.m4 +++ b/m4/mgetgroups.m4 @@ -1,4 +1,4 @@ -#serial 6 +#serial 7 dnl Copyright (C) 2007-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,6 +12,8 @@ AC_DEFUN([gl_MGETGROUPS], AC_CACHE_CHECK([for getgrouplist with int signature], [gl_cv_getgrouplist_with_int], [gl_cv_getgrouplist_with_int=no + gl_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[#if HAVE_GRP_H @@ -19,11 +21,8 @@ AC_DEFUN([gl_MGETGROUPS], #endif int groups[1]; int ngroups = 1; - int getgrouplist (char const *, gid_t, gid_t *, int *); ]], -[[ - return - getgrouplist ("root", 0, groups, &ngroups); -]])], +[[return - getgrouplist ("root", 0, groups, &ngroups);]])], [], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( @@ -32,12 +31,10 @@ AC_DEFUN([gl_MGETGROUPS], #endif int groups[sizeof (gid_t) == sizeof (int) ? 1 : -1]; int ngroups = 1; -int getgrouplist (char const *, int, int *, int *); ]], - [[ -return - getgrouplist ("root", 0, groups, &ngroups); - ]])], -[gl_cv_getgrouplist_with_int=yes])])]) + [[return - getgrouplist ("root", 0, groups, &ngroups);]])], +[gl_cv_getgrouplist_with_int=yes])]) + ac_c_werror_flag=$gl_save_c_werror_flag]) if test "$gl_cv_getgrouplist_with_int" = yes; then AC_DEFINE([HAVE_GETGROUPLIST_WITH_INT], 1, [Define to 1 if getgrouplist accepts and returns int and not gid_t.]) -- 2.1.0
bug#20923: mgetgroups.c vs getgrouplist warning on OS X
On Mon, Jun 29, 2015 at 2:01 PM, Jim Meyering wrote: > On Mon, Jun 29, 2015 at 11:39 AM, Paul Eggert wrote: >> Jim Meyering wrote: >>> >>> the first variant compiled >>> just fine here (and probably everywhere), >>> so HAVE_GETGROUPLIST_WITH_INT was not defined. >> >> >> Yes, well, it did work on GNU/Linux, which is what I tested it on. >> >> How about if we make the check pickier, so that it is likely to be triggered >> even without --enable-gcc-warnings, as in the attached? > > Thanks for another patch! Unfortunately, that still evokes only a > warning at least > with gcc 6.0.0 20150426. Darn it. I see that I mistakenly pushed one of your patches when I pushed the linkat.m4 fix, Paul. Sorry about that. Happy to revert, if you'd like that. Let me know.
bug#20923: mgetgroups.c vs getgrouplist warning on OS X
On Mon, Jun 29, 2015 at 11:39 AM, Paul Eggert wrote: > Jim Meyering wrote: >> >> the first variant compiled >> just fine here (and probably everywhere), >> so HAVE_GETGROUPLIST_WITH_INT was not defined. > > > Yes, well, it did work on GNU/Linux, which is what I tested it on. > > How about if we make the check pickier, so that it is likely to be triggered > even without --enable-gcc-warnings, as in the attached? Thanks for another patch! Unfortunately, that still evokes only a warning at least with gcc 6.0.0 20150426.
bug#20923: mgetgroups.c vs getgrouplist warning on OS X
Jim Meyering wrote: the first variant compiled just fine here (and probably everywhere), so HAVE_GETGROUPLIST_WITH_INT was not defined. Yes, well, it did work on GNU/Linux, which is what I tested it on. How about if we make the check pickier, so that it is likely to be triggered even without --enable-gcc-warnings, as in the attached? >From 99cda43b0f8d5a375a7641eb203e524714947946 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 28 Jun 2015 23:43:35 -0700 Subject: [PATCH] mgetgroups: port to strict OS X * doc/glibc-functions/getgrouplist.texi (getgrouplist): Document the getgrouplist problem. * lib/mgetgroups.c (getgrouplist_gids) [HAVE_GETGROUPLIST]: New macro. (mgetgroups): Use it. * m4/mgetgroups.m4 (gl_MGETGROUPS): Check for OS X signature for getgrouplist. --- ChangeLog | 11 +++ doc/glibc-functions/getgrouplist.texi | 4 lib/mgetgroups.c | 8 +++- m4/mgetgroups.m4 | 29 - 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5525922..1023d87 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2015-06-29 Paul Eggert + + mgetgroups: port to strict OS X + * doc/glibc-functions/getgrouplist.texi (getgrouplist): + Document the getgrouplist problem. + * lib/mgetgroups.c (getgrouplist_gids) [HAVE_GETGROUPLIST]: + New macro. + (mgetgroups): Use it. + * m4/mgetgroups.m4 (gl_MGETGROUPS): + Check for OS X signature for getgrouplist. + 2015-06-28 Jim Meyering mountlist: avoid an unused-label warning on OS X diff --git a/doc/glibc-functions/getgrouplist.texi b/doc/glibc-functions/getgrouplist.texi index 8a37cb1..0295cae 100644 --- a/doc/glibc-functions/getgrouplist.texi +++ b/doc/glibc-functions/getgrouplist.texi @@ -11,6 +11,10 @@ Portability problems fixed by Gnulib: Portability problems not fixed by Gnulib: @itemize @item +This function takes @code{int} instead of @code{gid_t} parameters +on some platforms: OS X 10.11. + +@item This function is missing on some platforms: Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 11 2011-11, Cygwin 1.7.9, mingw, MSVC 9, BeOS. @end itemize diff --git a/lib/mgetgroups.c b/lib/mgetgroups.c index f31f4d1..dd0c7a5 100644 --- a/lib/mgetgroups.c +++ b/lib/mgetgroups.c @@ -64,6 +64,11 @@ mgetgroups (char const *username, gid_t gid, gid_t **groups) gid_t *g; #if HAVE_GETGROUPLIST +# if HAVE_GETGROUPLIST_WITH_INT +# define getgrouplist_gids(g) ((int *) (g)) +# else +# define getgrouplist_gids(g) (g) +# endif /* We prefer to use getgrouplist if available, because it has better performance characteristics. @@ -87,7 +92,8 @@ mgetgroups (char const *username, gid_t gid, gid_t **groups) int last_n_groups = max_n_groups; /* getgrouplist updates max_n_groups to num required. */ - ng = getgrouplist (username, gid, g, &max_n_groups); + ng = getgrouplist (username, gid, getgrouplist_gids (g), + &max_n_groups); /* Some systems (like Darwin) have a bug where they never increase max_n_groups. */ diff --git a/m4/mgetgroups.m4 b/m4/mgetgroups.m4 index 42b5cf8..9413559 100644 --- a/m4/mgetgroups.m4 +++ b/m4/mgetgroups.m4 @@ -1,4 +1,4 @@ -#serial 5 +#serial 6 dnl Copyright (C) 2007-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,5 +6,32 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_MGETGROUPS], [ + AC_CHECK_HEADERS_ONCE([grp.h]) AC_CHECK_FUNCS_ONCE([getgrouplist]) + if test "$ac_cv_func_getgrouplist" = yes; then +AC_CACHE_CHECK([for getgrouplist with int signature], + [gl_cv_getgrouplist_with_int], + [gl_cv_getgrouplist_with_int=no + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( +[[#if HAVE_GRP_H + #include + #endif + int (*f) (char const *, gid_t, gid_t *, int *) = getgrouplist; +]])], + [], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#if HAVE_GRP_H + #include +#endif +int groups[sizeof (gid_t) == sizeof (int) ? 1 : -1]; +int (*f) (char const *, int, int *, int *) = getgrouplist; + ]])], +[gl_cv_getgrouplist_with_int=yes])])]) +if test "$gl_cv_getgrouplist_with_int" = yes; then + AC_DEFINE([HAVE_GETGROUPLIST_WITH_INT], 1, +[Define to 1 if getgrouplist accepts and returns int and not gid_t.]) +fi + fi ]) -- 2.1.0
bug#20923: mgetgroups.c vs getgrouplist warning on OS X
On Sun, Jun 28, 2015 at 11:48 PM, Paul Eggert wrote: > Jim Meyering wrote: >> >> I compiled the just-published snapshot on OS X configured with >> --enable-gcc-warnings, and saw this: >> >> lib/mgetgroups.c: In function 'mgetgroups': >> lib/mgetgroups.c:90:45: error: pointer targets in passing argument 3 >> of 'getgrouplist' differ in signedness [-Werror=pointer-sign] >> ng = getgrouplist (username, gid, g, &max_n_groups); > > > Does the attached gnulib patch fix things for you on OS X? > > Its documentation lists OS X 10.11 (released this month), as I assume the > incompatiblity is in the latest version of OS X and that Apple's never going > to fix it Hi Paul, Thanks for writing that, but it did not help: the first variant compiled just fine here (and probably everywhere), so HAVE_GETGROUPLIST_WITH_INT was not defined. The problem arises only when using --enable-gcc-warnings and the prototype- required int* (type of argument 3) conflicts with the gid_t* argument.
bug#20923: mgetgroups.c vs getgrouplist warning on OS X
Jim Meyering wrote: I compiled the just-published snapshot on OS X configured with --enable-gcc-warnings, and saw this: lib/mgetgroups.c: In function 'mgetgroups': lib/mgetgroups.c:90:45: error: pointer targets in passing argument 3 of 'getgrouplist' differ in signedness [-Werror=pointer-sign] ng = getgrouplist (username, gid, g, &max_n_groups); Does the attached gnulib patch fix things for you on OS X? Its documentation lists OS X 10.11 (released this month), as I assume the incompatiblity is in the latest version of OS X and that Apple's never going to fix it >From f805d38258639f45d95b01139e669752651cd1d7 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 28 Jun 2015 23:43:35 -0700 Subject: [PATCH] mgetgroups: port to strict OS X * doc/glibc-functions/getgrouplist.texi (getgrouplist): Document the getgrouplist problem. * lib/mgetgroups.c (getgrouplist_gids) [HAVE_GETGROUPLIST]: New macro. (mgetgroups): Use it. * m4/mgetgroups.m4 (gl_MGETGROUPS): Check for OS X signature for getgrouplist. --- ChangeLog | 11 ++ doc/glibc-functions/getgrouplist.texi | 4 lib/mgetgroups.c | 8 +++- m4/mgetgroups.m4 | 38 ++- 4 files changed, 59 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5525922..5dc6f80 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2015-06-28 Paul Eggert + + mgetgroups: port to strict OS X + * doc/glibc-functions/getgrouplist.texi (getgrouplist): + Document the getgrouplist problem. + * lib/mgetgroups.c (getgrouplist_gids) [HAVE_GETGROUPLIST]: + New macro. + (mgetgroups): Use it. + * m4/mgetgroups.m4 (gl_MGETGROUPS): + Check for OS X signature for getgrouplist. + 2015-06-28 Jim Meyering mountlist: avoid an unused-label warning on OS X diff --git a/doc/glibc-functions/getgrouplist.texi b/doc/glibc-functions/getgrouplist.texi index 8a37cb1..0295cae 100644 --- a/doc/glibc-functions/getgrouplist.texi +++ b/doc/glibc-functions/getgrouplist.texi @@ -11,6 +11,10 @@ Portability problems fixed by Gnulib: Portability problems not fixed by Gnulib: @itemize @item +This function takes @code{int} instead of @code{gid_t} parameters +on some platforms: OS X 10.11. + +@item This function is missing on some platforms: Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 11 2011-11, Cygwin 1.7.9, mingw, MSVC 9, BeOS. @end itemize diff --git a/lib/mgetgroups.c b/lib/mgetgroups.c index f31f4d1..dd0c7a5 100644 --- a/lib/mgetgroups.c +++ b/lib/mgetgroups.c @@ -64,6 +64,11 @@ mgetgroups (char const *username, gid_t gid, gid_t **groups) gid_t *g; #if HAVE_GETGROUPLIST +# if HAVE_GETGROUPLIST_WITH_INT +# define getgrouplist_gids(g) ((int *) (g)) +# else +# define getgrouplist_gids(g) (g) +# endif /* We prefer to use getgrouplist if available, because it has better performance characteristics. @@ -87,7 +92,8 @@ mgetgroups (char const *username, gid_t gid, gid_t **groups) int last_n_groups = max_n_groups; /* getgrouplist updates max_n_groups to num required. */ - ng = getgrouplist (username, gid, g, &max_n_groups); + ng = getgrouplist (username, gid, getgrouplist_gids (g), + &max_n_groups); /* Some systems (like Darwin) have a bug where they never increase max_n_groups. */ diff --git a/m4/mgetgroups.m4 b/m4/mgetgroups.m4 index 42b5cf8..5f19d4f 100644 --- a/m4/mgetgroups.m4 +++ b/m4/mgetgroups.m4 @@ -1,4 +1,4 @@ -#serial 5 +#serial 6 dnl Copyright (C) 2007-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,5 +6,41 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_MGETGROUPS], [ + AC_CHECK_HEADERS_ONCE([grp.h]) AC_CHECK_FUNCS_ONCE([getgrouplist]) + if test "$ac_cv_func_getgrouplist" = yes; then +AC_CACHE_CHECK([for getgrouplist with int signature], + [gl_cv_getgrouplist_with_int], + [gl_cv_getgrouplist_with_int=no + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( +[[#if HAVE_GRP_H + #include + #endif + int groups[1]; + int ngroups = 1; + int getgrouplist (char const *, gid_t, gid_t *, int *); +]], +[[ + return - getgrouplist ("root", 0, groups, &ngroups); +]])], + [], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#if HAVE_GRP_H + #include +#endif +int groups[sizeof (gid_t) == sizeof (int) ? 1 : -1]; +int ngroups = 1; +int getgrouplist (char const *, int, int *, int *); + ]], + [[ +return - getgrouplist ("root", 0, groups, &ngroups); +
bug#20923: mgetgroups.c vs getgrouplist warning on OS X
I compiled the just-published snapshot on OS X configured with --enable-gcc-warnings, and saw this: lib/mgetgroups.c: In function 'mgetgroups': lib/mgetgroups.c:90:45: error: pointer targets in passing argument 3 of 'getgrouplist' differ in signedness [-Werror=pointer-sign] ng = getgrouplist (username, gid, g, &max_n_groups); ^