Remove common patterns -- second try

Loïc Grenié loic.grenie at gmail.com
Sun Sep 30 18:53:05 UTC 2007


2007/9/30, Denys Vlasenko <vda.linux at googlemail.com>:
> On Sunday 30 September 2007 15:30, Loïc Grenié wrote:
> >     I've tried to remove "common patterns" in the code.
> >  Second try: I've changed bb_\(p?\)error_msg\(_and_die\)("%s", \(.*\))
> >  in bb_simple_\1error_msg\2(\3).
> >
> >    Patch attached.
> >
> >         Loïc
> -#ifdef VERSION_WITH_WRITEV
> -.....
> -#endif
>
>
> Why did you remove it?

    I had moved it in bb_simple_error_msg.c -- I've moved it back to where
  it belonged.

> May I suggest a simpler approach?
>
> Make bb_simple_[p]error_msg_XXX(str) call bb_[p]error_msg_XXX("%s", str),
> not the other way around.

    Of course, you're right.

    While I'm at it: bb_verror_msg is written in such a way that msg can have
  an embedded NUL char. Is it important ? Otherwise the function can be
  simplified (using strcat or vasprintf instead of moving pointers around).

      Loïc

PS: with my local gcc, whenever bb_simple_perror_msg is declared in
networking/libiproute/iproute.c, the function do_iproute takes 40 bytes
more. I've removed from the patch the kludge that I've used here but
I don't know whether this is a general problem.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: simple_error.diff
Type: text/x-patch
Size: 24378 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20070930/8e1992ed/attachment-0002.bin 


More information about the busybox mailing list