[Nut-upsdev] common/common.c snprintf warning
Greg Troxel
gdt at lexort.com
Mon Mar 31 15:24:18 BST 2025
Jim Klimov <jimklimov+nut at gmail.com> writes:
> The problem is, as far as NUT code is concerned, we are using tolower(),
> isalpha() etc. which may well be real functions in some libraries and
> macros with bit-shift magic or arrays on others...
> This is hard to catch without actually running builds on dozens of
> platforms :)
Yes, but the spec for them says that they take an int, and may only be
called with values that fit in unsigned char or EOF. So there's code
review, and there's test test builds.
NetBSD makes a point of throwing warnings; I suspect but am not sure
that if a NetBSD build is warning free that ctype(3) usage is legit.
In NetBSD current I think we are getting check/assert for being out of
range. We'll see how that goes.
An attempt to assert on invalid pthread usage earlier did show that many
many programs do wrong things (re-initializing an initialized mutex,
using one not initialized, unlocking an unlocked mutex, etc.). But this
was not that useful in the end as upstreams did not care and their
programs did not run. I think now it can be optionally turned on to
debug pthread usage.
More information about the Nut-upsdev
mailing list