Add and use strnlen_a() instead of more complex code - #1298
Open
alejandro-colomar wants to merge 3 commits into
Open
Add and use strnlen_a() instead of more complex code#1298alejandro-colomar wants to merge 3 commits into
alejandro-colomar wants to merge 3 commits into
Conversation
alejandro-colomar
force-pushed
the
strnlen
branch
from
July 16, 2025 23:15
bb5de4c to
e7383e9
Compare
alejandro-colomar
marked this pull request as ready for review
July 16, 2025 23:16
alejandro-colomar
force-pushed
the
strnlen
branch
2 times, most recently
from
July 16, 2025 23:34
b3cf6f6 to
fd97871
Compare
alejandro-colomar
force-pushed
the
strnlen
branch
2 times, most recently
from
July 16, 2025 23:54
83fbc58 to
166e380
Compare
alejandro-colomar
force-pushed
the
strnlen
branch
4 times, most recently
from
July 18, 2025 20:13
0fd00af to
1db0235
Compare
alejandro-colomar
marked this pull request as draft
July 22, 2025 10:14
alejandro-colomar
force-pushed
the
strnlen
branch
from
July 22, 2025 10:15
1db0235 to
1218c16
Compare
alejandro-colomar
force-pushed
the
strnlen
branch
from
July 22, 2025 12:43
1218c16 to
d2657a7
Compare
alejandro-colomar
force-pushed
the
strnlen
branch
2 times, most recently
from
August 16, 2025 12:37
9fc9da5 to
ca7a891
Compare
alejandro-colomar
force-pushed
the
strnlen
branch
2 times, most recently
from
September 30, 2025 18:30
a2e44f5 to
f199c2c
Compare
alejandro-colomar
force-pushed
the
strnlen
branch
from
October 7, 2025 13:37
f199c2c to
979b0aa
Compare
alejandro-colomar
force-pushed
the
strnlen
branch
from
October 19, 2025 09:11
979b0aa to
4c2b5ff
Compare
alejandro-colomar
force-pushed
the
strnlen
branch
2 times, most recently
from
October 28, 2025 09:30
0dd1f2d to
8c6f14a
Compare
alejandro-colomar
force-pushed
the
strnlen
branch
from
November 9, 2025 19:50
8c6f14a to
3613524
Compare
alejandro-colomar
force-pushed
the
strnlen
branch
from
November 28, 2025 15:17
3613524 to
ee77619
Compare
alejandro-colomar
force-pushed
the
strnlen
branch
from
December 6, 2025 01:10
ee77619 to
11fc0de
Compare
alejandro-colomar
force-pushed
the
strnlen
branch
from
December 7, 2025 14:25
11fc0de to
d61a48c
Compare
alejandro-colomar
force-pushed
the
strnlen
branch
from
December 23, 2025 22:21
d61a48c to
2a6a836
Compare
alejandro-colomar
force-pushed
the
strnlen
branch
from
December 31, 2025 02:34
2a6a836 to
ff4949a
Compare
alejandro-colomar
force-pushed
the
strnlen
branch
from
January 1, 2026 14:54
ff4949a to
b916035
Compare
alejandro-colomar
marked this pull request as ready for review
January 1, 2026 14:55
Collaborator
Author
|
Cc: @kees |
alejandro-colomar
force-pushed
the
strnlen
branch
from
February 23, 2026 14:29
b916035 to
d432752
Compare
alejandro-colomar
force-pushed
the
strnlen
branch
from
March 4, 2026 16:42
d432752 to
5e69906
Compare
alejandro-colomar
force-pushed
the
strnlen
branch
from
June 20, 2026 21:56
5e69906 to
4fcee5e
Compare
alejandro-colomar
force-pushed
the
strnlen
branch
from
August 19, 2026 09:43
4fcee5e to
7c40975
Compare
alejandro-colomar
force-pushed
the
strnlen
branch
2 times, most recently
from
August 24, 2026 11:26
7d9243b to
7186a48
Compare
alejandro-colomar
force-pushed
the
strnlen
branch
from
August 25, 2026 11:36
7186a48 to
788fa0c
Compare
alejandro-colomar
force-pushed
the
strnlen
branch
from
August 25, 2026 15:22
788fa0c to
fa7ae64
Compare
ikerexxe
reviewed
Aug 26, 2026
alejandro-colomar
force-pushed
the
strnlen
branch
2 times, most recently
from
August 26, 2026 12:42
1d72861 to
6e8c56f
Compare
alejandro-colomar
force-pushed
the
strnlen
branch
from
September 6, 2026 09:20
6e8c56f to
690a133
Compare
Signed-off-by: Alejandro Colomar <alx@kernel.org>
sizeof() worked because it's an array of char, but it's brittle. Signed-off-by: Alejandro Colomar <alx@kernel.org>
ut_syslen is the length of the nonstring stored in ut_host. Let's measure it in the obvious way: strnlen(ut_host, countof(ut_host)), aka, strnlen_a(ut_host). MIN(strlen(hostname), countof(ut_host)) works because we've just copied hostname into ut_host, and the countof() field makes sure we take truncation into account. But strnlen_a(ut_host) is just simpler, and more obviously correct. Signed-off-by: Alejandro Colomar <alx@kernel.org>
alejandro-colomar
force-pushed
the
strnlen
branch
from
September 9, 2026 09:37
690a133 to
e65fe28
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cc: @uecker
Revisions:
v2
SIZEOF_ARRAY.v2b
v2c
v3
v4
v4b
v4c
v4d
v4e
v4f
v5
s/STRNLEN/strnlen_a/v5b
v5c
v5d
v5e
v5f
v5g
v6
v6b
v6c
v6d
v6e
v6f
v7
v8
v9
v10
v10b
v10c
v10d