From: Zhixu Liu <zhixu.liu@gmail.com>
To: supervision@list.skarnet.org
Subject: runit: tryshsgr.c: why not test whether gid_t is short by using "sizeof(short) == sizeof(gid_t)"
Date: Wed, 4 Sep 2024 19:35:23 +0800 [thread overview]
Message-ID: <CALMA0xY=c645szSMUED3FUCS+a+GX2XNUdD7AyCWxSFq0m4HqA@mail.gmail.com> (raw)
Hi,
I'm trying to keep runit remaining available in gentoo's official portage tree,
see https://bugs.gentoo.org/938282 . I setup a github repo at
https://github.com/clan/runit/ for this purpose, following is what I'm doing
now:
1. fix all the compilation error(s)
2. eliminate the compilation warning(s) as much as possible
Now I 'm in stage 2, when fixing the warning of
-Wincompatible-pointer-types, see
https://github.com/clan/runit/blob/master/admin/runit-2.1.2/src/tryshsgr.c
As G. Pape has commented at
https://github.com/clan/runit/commit/5a7b8099ae638ce72abae2c4d8cac7ce33477522
> "tryshsgr" is specifically there to check whether the size of gid_t is short,
> it doesn't matter if it fails at compile time or run time. But with this
> change, it always succeeds, and so always size short is
> assumed, even though most systems should have unsigned int I guess.
At first, what Pape said is correct, I didn't fully understand the semantic
meaning of this check before fixing. I should use debian's patch
(0029-fix-ftbfs-with-gcc14.patch) which casts x by (gid_t *) instead of
changing from short x[4] to gid_t x[4] in my current patch (which is wrong).
But I'm just wondering why we don't use "sizeof(short) == sizeof(gid_t)" to do
the test which is more intuitive?
Part of the reason is that I found the test of the result depends on the
running user's supplement group config after I changed short to gid_t, which
is very confusing. If I run as root with many supplement groups, the test
fails, if running as another user w/o supplement groups, the test succeeds.
Of course, after the change from short to gid_t, the test logic or assumption
is wrong from the beginning.
Thanks.
next reply other threads:[~2024-09-04 11:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-04 11:35 Zhixu Liu [this message]
2024-09-04 11:56 ` Leah Neukirchen
2024-09-04 14:03 ` Zhixu Liu
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='CALMA0xY=c645szSMUED3FUCS+a+GX2XNUdD7AyCWxSFq0m4HqA@mail.gmail.com' \
--to=zhixu.liu@gmail.com \
--cc=supervision@list.skarnet.org \
/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 NNTP newsgroup(s).