RFC: cleaning up naming mess
Denis Vlasenko
vda.linux at googlemail.com
Mon Oct 2 21:52:43 UTC 2006
General guidelines:
bb_xfunc is sort of stupid. Either bb_ or x, not both.
xfunc() should closely match libc func() (in params and return value).
Otherwise use name like func_or_die()
Mark functions which can die - we will need it when we will
try to add nofork functionality.
Use bb_ prefix if otherwise name might look like some libc thing.
What we currently have and RFC for renaming:
bb_applet_long_options
bb_applet_name
Remove bb_ - names are clearly bbox-related.
bb_default_error_retval
There is nothing "default" about it.
Rename to xfunc_error_retval.
bb_error_msg
bb_error_msg_and_die
bb_herror_msg
bb_herror_msg_and_die
bb_perror_msg
bb_perror_msg_and_die
bb_perror_nomsg
bb_perror_nomsg_and_die
bb_vherror_msg
bb_vperror_msg
bb_info_msg
bb_vinfo_msg
bb_verror_msg
Excellent greppability on "error_msg" -> remove bb_, not needed.
bb_xgetlarg (should be bb_xgetlarg_bnd)
bb_xgetlarg10_sfx
bb_xgetlarg_bnd_sfx
bb_xgetularg_bnd
bb_xparse_number (should be bb_xgetularg10_sfx)
bb_xgetularg_bnd_sfx
bb_xgetularg10
bb_xgetularg10_bnd
Bad. What do they have to do with _args_? They parse _strings_!
Also we have tons of unchecked atoi().
Renaming:
atoi -> xatoi / xatou (str)
bb_xgetlarg (bb_xgetlarg_bnd) -> xstrtol_range (str, base, lo, hi)
bb_xgetlarg10_sfx -> xatol_sfx (str, sfxbtl[])
bb_xgetlarg_bnd_sfx -> xstrtol_range_sfx(str, base, lo, hi, sfxbtl[])
bb_xgetularg_bnd -> xstrtol_range (str, base, lo, hi)
bb_xparse_number (bb_xgetularg10_sfx) -> xatoul_sfx (str, sfxbtl[])
bb_xgetularg_bnd_sfx -> xstrtoul_range (str, base, lo, hi, sfxbtl[])
bb_xgetularg10 -> xatoul (str)
bb_xgetularg10_bnd -> xatoul_range (str, lo, hi)
bb_getopt_ulflags
Rename to getopt32. Because abi _has to_ have exact number of bits.
Just think about applet with 33 different options.
C code will be _different_ for 32-bit longs and 64-bit longs!
(If you disagree, show me the code how to handle it).
bb_opt_complementally
Rename to opt_complementary.
Also maybe introduce global uint32_t option_mask which is set by getopt32.
Several applets duplicate this already.
bb_fprintf
bb_printf
bb_vfprintf
bb_vprintf
Analyze & remove. At first glance these are useless.
bb_fflush_stdout_and_exit
Remove bb_
bb_xgetgrnam
bb_xgetpwnam
Rename to gid_from_name_or_die, uid_from_name_or_die?
bb_getgrgid
bb_getpwuid
bb_getug
bb_getxxnam
Bad names. What do they do?
Rest is not reviewed:
bb_ask_confirmation
bb_common_bufsiz1
bb_do_delay
bb_dump_add
bb_dump_blocksize
bb_dump_dump
bb_dump_fshead
bb_dump_length
bb_dump_size
bb_dump_skip
bb_dump_vflag
bb_echo
bb_fclose_nonstdin
bb_get_chomped_line_from_file
bb_get_chunk_from_file
bb_get_last_path_component
bb_get_line_from_file
bb_lookup_host
bb_lookup_port
bb_make_directory
bb_mode_string
bb_parse_mode
bb_process_escape_sequence
bb_setpgrp
bb_show_usage
bb_simplify_path
bb_test
bb_uuenc_tbl_base64
bb_uuenc_tbl_std
bb_uuencode
bb_warn_ignoring_args
bb_wfopen
bb_wfopen_input
--
vda
More information about the busybox
mailing list