[Toybox] [Patches] - Some more static analysis fixes

Rob Landley rob at landley.net
Mon Oct 13 22:38:27 PDT 2014


On 10/07/14 00:50, Ashwini Sharma wrote:
> Hi Rob, List,
> 
> Attached are few more static analysis fixes. This includes issues like
> resource leaks, logical dead codes etc...

The reason I didn't do this bit in lib.c:

-    if (!pidstr) xputs(signames[i].name);
+    if (!pidstr) xprintf("%02d) %s\n", signames[i].num, signames[i].name);

Is that posix kill.html says for -l "Write all values of signal_name supported
by the implementation, if no operand is given." (And then for -s it says
signal_name is a symbolic name.)

The "number) name" syntax provides more information to humans, but A) is less
scriptable (can't do "for i in $(kill -l)" from the shell), B) not what posix
requires.

Note that if you go "POSIXLY_CORRECT=1 kill -l" the gnu/dammit version will
spit out just the names, not the numbers.

*shrug* I can do it the other way if that's what people really prefer, just
pointing out I had reasons for _not_ doing that. (And I'm not interested in
reading a POSIXLY_CORRECT variable. Either we're compliant with the standard
or we aren't, pick one.

Being more scriptable pushed me over to standards compliance because you can
do a trivial one liner:

for i in $(./toybox kill -l); do echo $(./toybox kill -l $i)") "$i; done | sort -n

So implementing the standard doesn't actually make it hard to get this information...

Rob

 1413265107.0


More information about the Toybox mailing list