svn commit: trunk/busybox: coreutils util-linux
vda at busybox.net
vda at busybox.net
Tue Nov 13 09:51:45 PST 2007
Author: vda
Date: 2007-11-13 09:51:40 -0800 (Tue, 13 Nov 2007)
New Revision: 20418
Log:
tr: properly detect read errors (Fernando Silveira <fsilveira at gmail.com>)
readprofile: use xwrite
function old new delta
tr_main 679 677 -2
readprofile_main 1964 1944 -20
Modified:
trunk/busybox/coreutils/tr.c
trunk/busybox/util-linux/readprofile.c
Changeset:
Modified: trunk/busybox/coreutils/tr.c
===================================================================
--- trunk/busybox/coreutils/tr.c 2007-11-13 17:36:12 UTC (rev 20417)
+++ trunk/busybox/coreutils/tr.c 2007-11-13 17:51:40 UTC (rev 20418)
@@ -173,7 +173,8 @@
int idx = 1;
int i;
smalluint flags = 0;
- size_t read_chars = 0, in_index = 0, out_index = 0, c, coded, last = -1;
+ ssize_t read_chars = 0;
+ size_t in_index = 0, out_index = 0, c, coded, last = -1;
RESERVE_CONFIG_UBUFFER(output, BUFSIZ);
RESERVE_CONFIG_BUFFER(vector, ASCII+1);
RESERVE_CONFIG_BUFFER(invec, ASCII+1);
@@ -223,8 +224,9 @@
}
read_chars = read(STDIN_FILENO, tr_buf, BUFSIZ);
if (read_chars <= 0) {
- if (write(STDOUT_FILENO, (char *)output, out_index) != out_index)
- bb_perror_msg(bb_msg_write_error);
+ xwrite(STDOUT_FILENO, (char *)output, out_index);
+ if (read_chars < 0)
+ bb_perror_msg_and_die(bb_msg_read_error);
exit(EXIT_SUCCESS);
}
in_index = 0;
Modified: trunk/busybox/util-linux/readprofile.c
===================================================================
--- trunk/busybox/util-linux/readprofile.c 2007-11-13 17:36:12 UTC (rev 20417)
+++ trunk/busybox/util-linux/readprofile.c 2007-11-13 17:51:40 UTC (rev 20418)
@@ -88,10 +88,7 @@
}
fd = xopen(defaultpro, O_WRONLY);
-
- if (full_write(fd, &multiplier, to_write) != to_write)
- bb_perror_msg_and_die("error writing %s", defaultpro);
-
+ xwrite(fd, &multiplier, to_write);
close(fd);
return EXIT_SUCCESS;
}
More information about the busybox-cvs
mailing list