[PATCH] minor size optimization for dd.c

Bernhard Fischer rep.nop at aon.at
Sat Mar 18 23:20:05 UTC 2006


On Wed, Mar 15, 2006 at 09:21:51AM +0200, Denis Vlasenko wrote:
>On Tuesday 14 March 2006 15:41, Tito wrote:
>> Hi,
>> this patch reduces size of dd.c.
>> Size reduction is:
>> 
>>    text    data     bss     dec     hex filename
>>   1346       0       0    1346     542 coreutils/dd.o.orig
>>   1302       0       0    1302     516 coreutils/dd.o
>> 
>> Changes are trivial.
>> 
>> Please apply.
>
>                if ((ofd = open(outfile, oflag, 0666)) < 0) {
>-                       bb_perror_msg_and_die("%s", outfile);
>+                       goto OUTFILE_ERROR;
>                }
>
>I think it is better to use bb_xopen(), which will be doing
>the bb_perror_msg_and_die thing to you. Pity current bb_xopen()
>has only two arguments, but it's trivial to have three-argument one.
>See at http://195.66.192.167/linux/bbox/bb_xopen3.patch

landley disliked this the bb_xopen3 idea, iirc.

Rob, care to elaborate on why you don't want it, please?

Tito, I'd propose we revisit this after rob has branched a
busybox_1_1_stable branch, so we have clear sight for 1.2 assuming that
1.1 will go into bug-fix only mode, ok?

Thank you,
>
>diff -urpN busybox.org/libbb/xfuncs.c busybox.unlzma2/libbb/xfuncs.c
>--- busybox.org/libbb/xfuncs.c	Tue Mar  7 07:58:22 2006
>+++ busybox.unlzma2/libbb/xfuncs.c	Mon Mar 13 09:59:22 2006
>@@ -108,6 +108,19 @@ int bb_xopen(const char *pathname, int f
> }
> #endif
> 
>+#ifdef L_xopen3
>+int bb_xopen3(const char *pathname, int flags, int mode)
>+{
>+	int ret;
>+
>+	ret = open(pathname, flags, mode);
>+	if (ret == -1) {
>+		bb_perror_msg_and_die("%s", pathname);
>+	}
>+	return ret;
>+}
>+#endif
>
>Or else you may change bb_xopen() definition so that
>it can take 3 params. FYI: libc defines open() as 
>int open(const char *file, int oflag, ...);
>
>Unfortunately, it's not trivial to do the same to lseek etc:
>
>	bb_xlseek(ifd, skip * bs, SEEK_CUR);
>
>does not have any way to report _filename_ on error :(
>Maybe
>
>	bb_xlseek(ifd, skip * bs, SEEK_CUR, infile);
>
>where "infile" is a filename to use in bb_perror_msg_and_die
>if lseek will fail.
>--
>vda
>_______________________________________________
>busybox mailing list
>busybox at busybox.net
>http://busybox.net/cgi-bin/mailman/listinfo/busybox
>



More information about the busybox mailing list