[BusyBox] [PATCH] size optimisation for fdformat.c
Tito
farmatito at tiscali.it
Tue Jan 20 21:16:46 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_STDOUT ?
ERROR_MSG_PERROR
> ERROR_MSG_SYSLOG
ERROR_MSG_SYSLOG_STDERR ?
> ERROR_MSG_SILENT
>
> ERROR_DIE
> ERROR_RETURN
> ERROR_SHOW_USAGE
Yes, I'm thinking long time about it, as the xfuncs are very usefull,
but always die............... :-(
I struggled with this problem in devfsd.c and found a not
too elegant solution:
static void msg_logger(int die, int pri, const char * fmt, ... )
{
va_list ap;
va_start(ap, fmt);
if (access ("/dev/log", F_OK) == 0)
{
openlog(bb_applet_name, 0, LOG_DAEMON);
vsyslog( pri , fmt , ap);
closelog();
}
#ifndef CONFIG_DEBUG
else
#endif
bb_verror_msg(fmt, ap);
va_end(ap);
if(die==DIE)
exit(EXIT_FAILURE);
}
Your idea is good , we should do this.
But it will be a lot of work to modify all the code.........
Ciao,
Tito
> (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 ?
>
>
>
> Glenn
More information about the busybox
mailing list