https://github.com/networkupstools/nut/blob/master/drivers/al175.c#L400
snprintf(data+2, 6+1, "%2X%2X%2X", pr1, pr2, pr3);
http://buildbot.networkupstools.org/public/nut/builders/Ubuntu-artful-x64/builds/240/steps/compile/logs/warnings%20%284%29 and http://buildbot.networkupstools.org/public/nut/builders/Ubuntu-bionic-x64/builds/185/steps/compile/logs/warnings%20%281%29 :
../../../drivers/al175.c:400:28: warning: '%2X' directive output may be truncated writing between 2 and 4 bytes into a region of size between 3 and 5 [-Wformat-truncation=]
I am in favor of finding a way to silence this one warning, unless someone comes up with reasoning why it makes sense. For now, PR #858 would add a comment here that the warning exists in a rare test case, but seems bogus.
Probably bumping the target buffer size might avoid this like in other such cases, but I really wonder if there is a way for explicit %2X of an explicitly 16-bit variable to print more than two data bytes?.. Do some distros/compilers account for wide chars for example? Then we'd have a lot more such warnings on that platform, I suppose...
https://github.com/networkupstools/nut/blob/master/drivers/al175.c#L400
http://buildbot.networkupstools.org/public/nut/builders/Ubuntu-artful-x64/builds/240/steps/compile/logs/warnings%20%284%29 and http://buildbot.networkupstools.org/public/nut/builders/Ubuntu-bionic-x64/builds/185/steps/compile/logs/warnings%20%281%29 :
I am in favor of finding a way to silence this one warning, unless someone comes up with reasoning why it makes sense. For now, PR #858 would add a comment here that the warning exists in a rare test case, but seems bogus.
Probably bumping the target buffer size might avoid this like in other such cases, but I really wonder if there is a way for explicit
%2Xof an explicitly 16-bit variable to print more than two data bytes?.. Do some distros/compilers account for wide chars for example? Then we'd have a lot more such warnings on that platform, I suppose...