Page MenuHomeFreeBSD

auxv: partial revert of r366207, cast buflen to unsigned int where needed
ClosedPublic

Authored by kevans on Oct 1 2020, 5:25 PM.
Tags
None
Referenced Files
Unknown Object (File)
May 3 2024, 4:30 PM
Unknown Object (File)
Dec 22 2023, 11:58 PM
Unknown Object (File)
Dec 10 2023, 1:36 PM
Unknown Object (File)
Sep 16 2023, 5:18 PM
Unknown Object (File)
Aug 22 2023, 3:27 AM
Unknown Object (File)
Jul 13 2023, 6:25 AM
Unknown Object (File)
Jul 9 2023, 7:56 PM
Unknown Object (File)
Apr 18 2023, 10:09 PM
Subscribers

Details

Summary

The warning generated pre-rS366207 is actually a sign comparison warning:

error: comparison of integers of different signs: 'unsigned long' and 'int' [-Werror,-Wsign-compare]
                        if (strlcpy(buf, execpath, buflen) >= buflen)

Revert parts that affected other lines and just cast this to unsigned int.

The buflen < 0 -> EINVAL has been kept despite no longer serving any purposes w.r.t. sign-extension because I do believe it's the right thing to do: "The provided buffer was not the right size for the requested item."

The original warning is confirmed to still be gone with an env WARNS=6 make WITHOUT_TESTS=yes.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kevans requested review of this revision.Oct 1 2020, 5:25 PM

Quick wrapping fix... casting to unsigned int pushed it past 80.

Why does Clang treat the final argument of memcpy differently than the final argument of strlcpy?

Why does Clang treat the final argument of memcpy differently than the final argument of strlcpy?

In what context? In this case, it's not a problem with the final argument but rather with the comparison of the result of strlcpy and signed int.

This revision is now accepted and ready to land.Oct 1 2020, 5:46 PM

Oh, I see. Still, it seems like Clang ought to be complaining about the sign-extension when we pass an int to a function expecting a size_t. Maybe that warning is globally disabled.

Ah, right, sorry- I 100% agree... I checked it with a small trivial test-case, and neither gcc9 nor in-base llvm seem to have any warning about possible unintended sign extension with -Wall -Wextra at least.