glibc misc/sys/cdefs.h nonull - typo in comment

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Tue Apr 11 13:39:05 GMT 2023



On 11/04/23 06:09, Jonny Grant wrote:
> Hi
> 
> There are two small changes I suggest if someone has a moment?
> 
> misc/sys/cdefs.h  nonull  - typo in comment
> Should be "nonnull"

This is already being fixed by c8ba52ab3350c334d (2.34).

> 
> Also
> 
> /posix/glob.c has an unused macro
> # define _GL_ARG_NONNULL(params)
> 
> Could that be removed?

This definition is used by gnulib code, since it defined for !_LIBC,
Different than glibc, gnulib defines the function as:

lib/glob.in.h

103 #if @GNULIB_GLOB@
104 # if @REPLACE_GLOB@
105 _GL_FUNCDECL_RPL (glob, int, (const char *_Restrict_ __pattern, int __flags,
106                               _gl_glob_errfunc_fn __errfunc,
107                               glob_t *_Restrict_ __pglob)
108                               _GL_ARG_NONNULL ((1)));
109 _GL_CXXALIAS_RPL (glob, int, (const char *_Restrict_ __pattern, int __flags,
110                               _gl_glob_errfunc_fn __errfunc,
111                               glob_t *_Restrict_ __pglob));
112 # else
113 #  if !@HAVE_GLOB@
114 _GL_FUNCDECL_SYS (glob, int, (const char *_Restrict_ __pattern, int __flags,
115                               _gl_glob_errfunc_fn __errfunc,
116                               glob_t *_Restrict_ __pglob)
117                               _GL_ARG_NONNULL ((1)));
118 #  endif
119 _GL_CXXALIAS_SYS (glob, int, (const char *_Restrict_ __pattern, int __flags,
120                               _gl_glob_errfunc_fn __errfunc,
121                               glob_t *_Restrict_ __pglob));
122 # endif

Which then at the implementation is also check for pattern == NULL:

lib/glob.c:

 316   if (pattern == NULL || pglob == NULL || (flags & ~__GLOB_FLAGS) != 0)
 317     {
 318       __set_errno (EINVAL);
 319       return -1;
 320     }

So the comment is right that compiler might indeed remove the test. 
Different than gnulib, glibc prototype does not add the 
__attribute__ ((nonnul)).

> 
> Seems _GL_ARG_NONNULL is only used in misc/error.c which again just compiles it out. So maybe it can be removed overall in both files?

This was added as a sync with gnulib code by 888c679ba40, because it is
used in error_tail definition and glibc does not define it.  So we can not
remove without also adjusting error_tail, and since the code is originally
from gnulib maybe it would be better to use __nonnull macro.

> 
> Kind regards
> Jonny


More information about the Libc-alpha mailing list