Subj : rmw compile warnings
To : Maurice Kinal
From : Andrew Alt
Date : Wed Mar 03 2021 11:15 am
-=> Maurice Kinal wrote to Andrew Alt <=-
MK> -={ 2021-03-01 17:54:39.246915930+00:00 }=-
MK> Hey Andrew!
MK> The above was done on my custom pure 64-bit nondistribution rootfs (aka
MK> motorshed) using gcc-10.2.0/glibc-2.33 and friends.
MK> Does this help any?
Hi, Maurice!
On Debian with gcc 8 I wasn't getting any warnings. So.. that reminds me I might have
to make some changes to get rid of those warnings. :) I'm not really sure of the best
way to fix those though. I have mixed feelings about using snprintf(). I have redundant checks in place to check string lengths before concatenating, and I don't
want strings to just get truncated. rmw is designed to exit (without a segfault) with
a message if a buffer overflow is attempted. I think I should just change all my
snprintf() statements to sprintf()... Which probably won't fix the warnings you
mentioned, lol ;)
I can get even more if I use CFLAGS="-Wformat -Wstringop-truncation
-Wformat-overflow=2 -pedantic -Wextra -Wformat-truncation=2" :)
Any suggestions? Probably if don't set fixed lengths in the structures and instead
use calloc() at the time when I concatenate and write the final string, that would
get rid of some of these annoying messages I get when I use the flags mentioned
above. Seems like that would require a lot of extra manual memory management though.
Things are working fine right now so I'm reluctant to change the code until I really
understand well how best to fix those warnings.