Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: src/lib/libc/stdlib



Module Name:    src
Committed By:   kre
Date:           Mon Nov 23 18:30:05 UTC 2026

Modified Files:
        src/lib/libc/stdlib: strfmon.c

Log Message:
libc/strfmon - Partly revert previous

One of the changes was to some "half done" code that I had forgotten
when the recent changes were committed -- it worked fine as it was,
but was a bit odd ... the code was calling a func for parsing a string,
which would stop at the \0 which terminates it ... but the function
wanted to be told what the max number of bytes it was allowed to consume
would be, just in case there might be no \0.   The original code
simply inserted an "easily big enough" constant - since the \0
wasn't ever going to be missing (string came from an earlier strdup()).

But, for other (related) reasons, the length of the string was being
calculated (strlen()) anyway - so rather than do that, and test it,
and then just throw away the length, the length could be captured,
and used instead of the constant.   I had written the code (like, one
variable declaration, and an assignment ... not challenging) to
do that, but hadn't gotten around to using the value saved as the
arg to the function which could use it.

lint complained about the var being set and not used.   Pointless
really, the compiler would just optimise it away.   Rather than
going back to not saving the length (the previous commit), now the
var will be used, which should keep lint happy.

The other lint related changes (change really, just one line,
deleting a "break") I am strongly tempted to simply revert.
lint should just be fixed instead.

I see nothing at all wrong - in fact, I think it should always
be done, to end a switch() case block, with a "break;" (or sometimes
continue when that is appropriate) when a fall through to the next
case label's block of code is not to happen.  That applies, even if
it should happen that the "break" is never reached because some
previous code causes the flow of control to not be able to get that far.
The "break" is just good defensive programming should a logic change
to the code block it ends mean that the break can be reached.

By all means let lint complain about real executable code that can't
be reached, but break ???  But in any case, not in this commit.

The actual change here makes no real practical difference to the execution of
strfmon().   Like all the recent changes to strfmon.c, no pullups intended.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/lib/libc/stdlib/strfmon.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




Home | Main Index | Thread Index | Old Index