treewide: cleanup, const-correctness, and -Werror - #781
Conversation
|
Hi @intelfx ! I owe you an apology. I ended up merging a commit with g_strlcpy before realizing you had already opened a PR with partially the same idea. Since your PR wasn't passing CI, I hadn't looked at it yet, so I didn't notice this one. I planned for a long time to fix the utterly wrong approach of truncating the filepath and when I have done it yesterday I knew more about GLib than a year ago when I knew only libc and the rants about strlcpy (which is available for a long time under FreeBSD but glibc added it only in 2.38) and strscpy from the Linux kernel which is not available to us. Even though my commit unfortunately overlapped with your work, I took a different approach in the end (size_t) but still made a mistake forgetting to change back the format specifier. I've mentionned your commit in a7d87ad (and AFAIK GH keep forever commits in PR branches even if they are from a deleted branch in the contributor own fork). I haven't looked why the CI did not pass, but I think the CI need a rework, there might be false negatives. In 28ffb62 some distributions have been removed, that may help with newer compiler options. |
cb2f962 to
18fac2d
Compare
|
Yep, your fix is better anyway (I merely "fixed" the truncation, while you made it a fatal error as it should be, and you did the const-correctness thing too). I'm going to push the |
utils: make string search functions const-correct
Usage of string search functions (
str*{chr,str}()) in rmlint implicitly relies on const-laundering of its arguments. This is not the case anymore when building with glibc 2.41+ and C23 (which is the default on newer GCC), which surfaces a lot of annoying warnings.Constify all relevant places to avoid relying on implicit const-laundering.
pathtricia: use strlcpy(), get rid of -Wstringop-truncation warning
Complete the refactoring started in 5a0ad6c and switch strncpy() to strlcpy() for better ergonomics and to squelch a
-Wstringop-truncationwarning.-Werror, more warnings, and warning fixes
This is a patch lifted from @cebtenzzre's tree (hopefully he won't object) with the rest of cleanups and
-Werror.