8000 [RFC] use unsigned chars by t-8ch · Pull Request #2768 · util-linux/util-linux · GitHub
[go: up one dir, main page]

Skip to content

[RFC] use unsigned chars #2768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

t-8ch
Copy link
Member
@t-8ch t-8ch commented Feb 5, 2024

This matches was the kernel does.
It also aligns meson with autotools.

t-8ch added 2 commits February 5, 2024 09:15
This matches what the kernel does.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
This matches what the kernel does.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
@t-8ch
Copy link
Member Author
t-8ch commented Feb 6, 2024

In any case I think meson should be aligned with Autotools, which currently is not the case.

@karelzak
Copy link
Collaborator
karelzak commented Apr 2, 2024

I agree that we need to sync meson and autotools. Personally, I prefer when developers are explicit and always use "unsigned" in the code.

Is there anything we can break with the change? I mean things like any encoding, etc. For example, in the very old lib/mangle.c is used "const char" rather than "unsigned" (probably no issue as it uses 'signed' in all the code) etc.

@t-8ch
Copy link
Member Author
t-8ch commented Apr 3, 2024

Is there anything we can break with the change?

There are things that could break. But given that the signedness of plain 'char' already changes per architecture. (signed for x86, unsigned for arm), things should already be broken.

@karelzak
Copy link
Collaborator
karelzak commented Apr 3, 2024

We use -fsigned-char, so architecture-specific creativity should not affect our char (I hope).

@t-8ch
Copy link
Member Author
t-8ch commented Apr 3, 2024

We use -fsigned-char

Not on meson.
Which is used at least by ArchLinux (on ARM) and OpenWRT.

@karelzak
Copy link
Collaborator
karelzak commented Apr 3, 2024

Ah, now I understand ;-) OK, so let's go ...

@t-8ch t-8ch marked this pull request as ready for review April 3, 2024 10:58
@t-8ch
Copy link
Member Author
t-8ch commented Apr 3, 2024

We should check if char is used in headers somewhere.

@t-8ch
Copy link
Member Author
t-8ch commented Apr 3, 2024

used in headers somewhere

All over the place. Which means we already had mismatches between API users and API implementations in the autotools binaries.

@karelzak
Copy link
Collaborator
karelzak commented Apr 3, 2024

That's a good point. It's also more complicated because we do not control how public libs API header files are interpreted if a signed/unsigned keyword is missing.

Hmm... the libmount or libblkid headers are full of 'char'; adding 'unsigned' everywhere will be an API change.

@t-8ch
Copy link
Member Author
t-8ch commented Apr 3, 2024

On the other hand there is already a mismatch between what the users expect (naive char) with what util-linux interprets (signed char with autotools).

I guess as a first step we can align meson to autotools with -fsigned-char.

t-8ch added a commit to t-8ch/util-linux that referenced this pull request Apr 7, 2024
This matches what the autotools build is doing.
Also see util-linux#2768 .

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
@crrodriguez
Copy link
Contributor

It is my opinion or understanding that most stuff out there assumes chars are unsigned, this is a naive assumption but it is what most programs assume.
Now, chars are unsigned for the kernel, in all arches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0