public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [BUG] mq_[gs]etattr(3): NULL passed to __nonnull argument
@ 2023-07-11 13:40 Alejandro Colomar
  2023-07-11 13:45 ` Alejandro Colomar
  0 siblings, 1 reply; 2+ messages in thread
From: Alejandro Colomar @ 2023-07-11 13:40 UTC (permalink / raw)
  To: GNU C Library


[-- Attachment #1.1: Type: text/plain, Size: 1019 bytes --]

Hi!

Using __nonnull internally uncovered something:

../sysdeps/unix/sysv/linux/mq_getattr.c: In function ‘__mq_getattr’:
../sysdeps/unix/sysv/linux/mq_getattr.c:28:10: error: argument 2 null where non-null expected [-Werror=nonnull]
   28 |   return mq_setattr (mqdes, NULL, mqstat);
      |          ^~~~~~~~~~

This is not a bug in the use of mq_setattr(3), since it accepts NULL
with the meaning of mq_getattr(3), per the manual page.

I'm not sure about if this is a bug in the declaration of mq_setattr(3),
though.  If we want __nonnull because we want to disallow users from
using it in that way, then we need to use a #pragma in that specific
use.

Or maybe it was only added by accident, and we want to allow users to
call it with NULL.  In that case, we should remove __nonnull from the
declaration.  I guess this is more likely.

What do you think about it?

Thanks,
Alex

-- 
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [BUG] mq_[gs]etattr(3): NULL passed to __nonnull argument
  2023-07-11 13:40 [BUG] mq_[gs]etattr(3): NULL passed to __nonnull argument Alejandro Colomar
@ 2023-07-11 13:45 ` Alejandro Colomar
  0 siblings, 0 replies; 2+ messages in thread
From: Alejandro Colomar @ 2023-07-11 13:45 UTC (permalink / raw)
  To: GNU C Library


[-- Attachment #1.1: Type: text/plain, Size: 1463 bytes --]

On 2023-07-11 15:40, Alejandro Colomar wrote:
> Hi!
> 
> Using __nonnull internally uncovered something:
> 
> ../sysdeps/unix/sysv/linux/mq_getattr.c: In function ‘__mq_getattr’:
> ../sysdeps/unix/sysv/linux/mq_getattr.c:28:10: error: argument 2 null where non-null expected [-Werror=nonnull]
>    28 |   return mq_setattr (mqdes, NULL, mqstat);
>       |          ^~~~~~~~~~
> 
> This is not a bug in the use of mq_setattr(3), since it accepts NULL
> with the meaning of mq_getattr(3), per the manual page.
> 
> I'm not sure about if this is a bug in the declaration of mq_setattr(3),
> though.  If we want __nonnull because we want to disallow users from
> using it in that way, then we need to use a #pragma in that specific
> use.

Ah, no, I misunderstood the man page.  It doesn't seem to be allowed to
be NULL, but it seems glibc does use it for internal purposes only.  If
that's the case, we should maybe use an internal function that accepts
NULL, which would be used for the implementation of mq_getattr(3), and
then the public wrapper would have __nonnull.

> 
> Or maybe it was only added by accident, and we want to allow users to
> call it with NULL.  In that case, we should remove __nonnull from the
> declaration.  I guess this is more likely.
> 
> What do you think about it?
> 
> Thanks,
> Alex
> 

-- 
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-11 13:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-11 13:40 [BUG] mq_[gs]etattr(3): NULL passed to __nonnull argument Alejandro Colomar
2023-07-11 13:45 ` Alejandro Colomar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).