]> git.ipfire.org Git - thirdparty/util-linux.git/commit
last: Use int for string precision modifier
authorTobias Stoeckmann <tobias@stoeckmann.org>
Thu, 9 Apr 2026 19:23:05 +0000 (21:23 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Thu, 9 Apr 2026 22:31:52 +0000 (00:31 +0200)
commita401c223ab5a2affcfdae44f25ebb2a56a5f263b
treefbed3b67e25d870a75d4853595dd527a070a8cd4
parent2cc4450d8e93968cb159c24d45b5ebd0e42f1e0b
last: Use int for string precision modifier

The %.*s modifier requires an int as precision argument, not an unsigned
int. Instead of just turning the domain_len and name_len fields into
int, this refactoring makes it easier to verify that only two fixed
values are ever used and avoids many int/size_t casts:

Since fullnames_mode field already specifies which values domain_len and
name_len will take, these fields can be turned into local variables.

No special checks required when parsing 'w' argument.

Setting domain_len and name_len as close as possible to their usages as
%.*s modifier arguments shows that the relevant if-else-blocks are always
evaluated and only allow two values.

This leads to smaller binary size because less instructions are needed
(e.g. these variables do not need pointer dereferences anymore).
In total, around 160 bytes on x86_64 are saved.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
login-utils/last.c