public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx.manpages@gmail.com>
To: Vincent Lefevre <vincent@vinc17.net>, libc-alpha@sourceware.org
Subject: Re: Bad interaction between signal constants and -Wsign-conversion
Date: Thu, 30 Mar 2023 16:09:12 +0200	[thread overview]
Message-ID: <9d23a09f-31d6-17ce-5bd1-37f7035d1371@gmail.com> (raw)
In-Reply-To: <20230330135911.GA2458@cventin.lip.ens-lyon.fr>


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

Hi Vincent,

On 3/30/23 15:59, Vincent Lefevre wrote:
> On 2023-03-29 02:08:39 +0200, Alejandro Colomar via Libc-alpha wrote:
> [about sa_flags in struct sigaction]
>> Well, probably not doable now, but is switching to the unsigned counterpart
>> still possible now?  It would require investigating how this member is
>> being used out there, to know if we're going to break anyones code, and
>> integer conversions are very tricky, so it's hard to know, but for a flags
>> field that is to be used in bitwise operations, I don't expect anyone to
>> actually use it as an int, but rather as an unsigned that for historic
>> reasons happens to be signed.
>>
>> This is also a reminder that new such fields in structures and function
>> parameters should always be of unsigned types if they're going to hold
>> flags (or in general, if they're to be treated as something that requires
>> bitwise operations).
> 
> I entirely agree.
> 
> But concerning struct sigaction in particular, shouldn't this be fixed
> in POSIX?

IMHO, POSIX, and in general, standards, should follow implementations
rather than lead them.  I think changes should start as vendor
extensions.

For example, timespec::tv_nsec was mandated to be long by POSIX and
C11, but glibc used 'long long' in some cases, because it was
necessary.  I would say using 'unsigned int' here would be a nice GNU
extension, and if it proves its value, POSIX could later pick it.

However, as Zack said, I'm not sure how we could check if any programs
out there are using this member unreasonably.

Cheers,

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

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

  reply	other threads:[~2023-03-30 14:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-28  1:23 Zack Weinberg
2023-03-28  1:58 ` Paul Eggert
2023-03-28 14:03   ` Cyril Hrubis
2023-03-28 14:53     ` Florian Weimer
2023-03-28 15:04       ` Andreas Schwab
2023-03-28 18:50         ` Florian Weimer
2023-03-29  0:08 ` Alejandro Colomar
2023-03-30 13:45   ` Zack Weinberg
2023-03-30 13:59   ` Vincent Lefevre
2023-03-30 14:09     ` Alejandro Colomar [this message]
2023-03-31 15:31       ` Vincent Lefevre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9d23a09f-31d6-17ce-5bd1-37f7035d1371@gmail.com \
    --to=alx.manpages@gmail.com \
    --cc=libc-alpha@sourceware.org \
    --cc=vincent@vinc17.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).