[Toybox] Vconfig cleanup.

Rob Landley rob at landley.net
Sat Nov 2 11:57:44 PDT 2013


When I rsync my repository up this should be  
http://landley.net/hg/toybox/rev/1103

There are still a few commands that got merged before I had "pending",  
and one of them is vconfig. First pass at cleaning that up:

1) strtol_range()

Design concern:The argument parsing logic already does this. Sharing  
infrastructure might be good. Should this go into lib, and if so should  
lib/args.c use it? (Not sure yet, but it's clearly duplicate code.)

Rename function strtorange(), for two reasons. 1) having strtol in the  
name implies strtoi and strtou variants are coming, which seems  
unlikely. But more importantly, a prefix with an underscore is  
generally used for grouping functions. It's a common prefix between  
related functions, like llist_ or dirtree_, or showing that perror_msg  
and perror_exit are related. Functions implementing a command are  
prefixed with the command's name, and the slightly oddball do_ prefix  
means it's called from loopfiles(). (That last one's not a particularly  
_good_ naming convention, but it's fairly consistent.) So I'd prefer  
not to have multipart_name() without strong reason.

Local variables: rename "endptr" to "end" because including the  
variable type in the variable name is hungarian notation (which we  
don't do), and being more verbose about it doesn't help. Similary,  
"ret_value" is just "val".

The general principle here is that the smaller the scope of the  
variable, the smaller the name can be. You don't want to grep over 1000  
lines for a variable called "e" but for a 5 line function we don't need  
to say loopIteratorVariable either. Not a big deal, but this bit of  
signaling helps me quickly get back up to speed when I haven't looked  
at an area of code in a while.

Collapse together multiple error message and reduce vocabulary: still  
trying to be easier for non-english speakers.

Remove BSD-style unnecessary braces: more of this to come.

Remove comments that provide no information. Saying vconfig_main() is  
the "vconfig main function" is not worth three lines.

That's probably enough for one pass.

Rob
 1383418664.0


More information about the Toybox mailing list