Skip to content

Misc tiny fixes to issues spotted by Clang#4111

Open
pmatilai wants to merge 6 commits intorpm-software-management:masterfrom
pmatilai:clang-misc
Open

Misc tiny fixes to issues spotted by Clang#4111
pmatilai wants to merge 6 commits intorpm-software-management:masterfrom
pmatilai:clang-misc

Conversation

@pmatilai
Copy link
Member

@pmatilai pmatilai commented Feb 9, 2026

These are mostly on the cosmetic department...

Clang is clever enough to spot this: the cases in the switch are
of rpmTagClass enum, whereas RPM_NULL_TYPE is rpmTagType. The value
is 0 for both so this is of academic interest in this case, but in
some other situation could be a real bug. Kudos to clang.

Having the NULL type/class explicitly listed here adds no value whatsoever
because it falls through to the default case anyhow.

Related: rpm-software-management#4105
Clang complains we're not using the rc value in removeSBITS() anything,
which is entirely correct - we don't know what the heck to do with it.
Returning the rc makes the complaint go away, despite callers not
actually checking for it. So this is just kicking the issue further
down the road, not an actual fix.

Related: rpm-software-management#4105
This is a bit silly: 32*BUFSIZ is a compile time calculation, but when
when assigned to a non-const variable and used as an array size, Clang
thinks it's a variable length array. Which it isn't, unless you're a
language lawyer. Add a const in front to shoo the lawyers away.

Related: rpm-software-management#4105
Clang was clever enough to spot this ancient typo/thinko and complain.

Related: rpm-software-management#4105
@pmatilai pmatilai requested a review from a team as a code owner February 9, 2026 15:14
@pmatilai pmatilai requested review from dmnks and removed request for a team February 9, 2026 15:14
The cpio modulo has been hardcoded to value of 4 for 25+ years already.
It's not going to change now, so drop the silly parameter from
rpmcpioWritePad() and make it a const to make it clear to the compiler
this is not a VLA.

The rpmcpioReadPad() counterpart never had a modulo argument, but
instead it duplicates the size. Make modulo const there too, and use
it for the buffer size.

Related: rpm-software-management#4105
We cap the maximum file name length to 4096 in the line above, might
as well use that limit for the buffer size too. Add and use
CPIO_NAMESIZE_MAX define for it to avoid duplicating the value.

Related: rpm-software-management#4105
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.

2 participants

Comments