[BusyBox] [PATCH] size optimisation for fdformat.c

Tito farmatito at tiscali.it
Tue Jan 20 23:26:12 UTC 2004


On Tuesday 20 January 2004 13:32, Glenn McGrath wrote:
> On Mon, 19 Jan 2004 14:47:59 +0000
>
> Tito <farmatito at tiscali.it> wrote:
> > Hi to all,
> >
> > I tested it several times with fd0 and fd0u1722 and it worked well.
>
> Applied.
>
> > BTW I would like to ask the Gurus if it is possible to move the
> > following two functions to libbb ( as they are or improved/cleaned
> > up):
>
> It probably is a good idea, on a related note....
>
> There are times when it would be convenient to use one of the xfunctions
> in libbb but the exit status, or message logging isnt suitable.
>
> I think it would be good if we could modify the exit and
> logging behaviour of the various xfuncs.
>
> It could eliminate the need for seperate functions such as this proposed
> bb_xioctl() and bb_ioctl(), xfopen() and wfopen() and bb_xgetularg could
> be more generally usefull if it didnt call bb_show_usage on error.
>
> Also, many of these xfuncts are problematic in inetd as they need to
> send error messages to syslog instead of stderr.
>
> Most of these xfunctions are really small, they do not justify adding
> extra code to handle different error handling or exit status, that is
> why there is multiple versions of them with slightly different
> behaviour.
>
> A different approach would be to add extra functionality to
> bb_error_msg, perhaps adding a global variable that offers different
> error logging and exit behaviour.
>
> We could use a bitfield seperated to two groups, e.g.
>
> ERROR_MSG_STDERR
> ERROR_MSG_SYSLOG
> ERROR_MSG_SILENT
>
> ERROR_DIE
> ERROR_RETURN
> ERROR_SHOW_USAGE
>
> (there may be others)
>
> bb_error_msg is one of the most common functions we have so adding extra
> functionality would add little overhead and would probably lead to a
> reduction in the number of libbb functions and make the remaining ones
> more usfull.
>
> Opinions ?
>

file:/root/Desktop/err_msg/error_msg_and_die.c
file:/root/Desktop/err_msg/error_msg.c
file:/root/Desktop/err_msg/herror_msg_and_die.c
file:/root/Desktop/err_msg/herror_msg.c
file:/root/Desktop/err_msg/perror_msg_and_die.c
file:/root/Desktop/err_msg/perror_msg.c
file:/root/Desktop/err_msg/perror_nomsg_and_die.c
file:/root/Desktop/err_msg/perror_nomsg.c
file:/root/Desktop/err_msg/syslog_msg_with_name.c
file:/root/Desktop/err_msg/verror_msg.c
file:/root/Desktop/err_msg/vherror_msg.c
file:/root/Desktop/err_msg/vperror_msg.c

Would it not be nice to unify these all in one new bb_err_msg() function?
It seems to me these functions are performing  the same task 

print the error/or print it not --- and to die/or not die (shakespeare?)

four times (error, herror, perror,verror),

just syslog_msg_with_name lacks syslog_msg_with_name_and_die,  syslog_nomsg_with_name
and syslog_nomsg_with_name_and_die(this one is silly? isn't it?...I know ;-P) but we can add'em ;-)........

I would try to do this just for fun .....if you give me a good example about the bitfield you told  :
       
Something like this ?
       S_IFMT     0170000   bitmask for the file type bitfields
       S_IFSOCK   0140000   socket
       S_IFLNK    0120000   symbolic link
       S_IFREG    0100000   regular file
       S_IFBLK    0060000   block device
       S_IFDIR    0040000   directory

Wouldn't an int flag do it also?
int die    (yes/no)	
int msg  (yes/no)
int action  (error, perror, herror, (verror maybe is not needed) ,syslog).

Tito.

>
> Glenn




More information about the busybox mailing list