svn commit: trunk/busybox/libbb
vda at busybox.net
vda at busybox.net
Thu Oct 12 15:44:13 PDT 2006
Author: vda
Date: 2006-10-12 15:44:13 -0700 (Thu, 12 Oct 2006)
New Revision: 16376
Log:
xread/write can use full_read/write (smaller code)
Modified:
trunk/busybox/libbb/full_read.c
trunk/busybox/libbb/full_write.c
trunk/busybox/libbb/xfuncs.c
Changeset:
Modified: trunk/busybox/libbb/full_read.c
===================================================================
--- trunk/busybox/libbb/full_read.c 2006-10-12 22:43:20 UTC (rev 16375)
+++ trunk/busybox/libbb/full_read.c 2006-10-12 22:44:13 UTC (rev 16376)
@@ -24,7 +24,7 @@
total = 0;
- while (len > 0) {
+ while (len) {
cc = safe_read(fd, buf, len);
if (cc < 0)
Modified: trunk/busybox/libbb/full_write.c
===================================================================
--- trunk/busybox/libbb/full_write.c 2006-10-12 22:43:20 UTC (rev 16375)
+++ trunk/busybox/libbb/full_write.c 2006-10-12 22:44:13 UTC (rev 16376)
@@ -23,7 +23,7 @@
total = 0;
- while (len > 0) {
+ while (len) {
cc = safe_write(fd, buf, len);
if (cc < 0)
Modified: trunk/busybox/libbb/xfuncs.c
===================================================================
--- trunk/busybox/libbb/xfuncs.c 2006-10-12 22:43:20 UTC (rev 16375)
+++ trunk/busybox/libbb/xfuncs.c 2006-10-12 22:44:13 UTC (rev 16376)
@@ -113,24 +113,20 @@
// Die with an error message if we can't read the entire buffer.
void xread(int fd, void *buf, size_t count)
{
- while (count) {
- ssize_t size = safe_read(fd, buf, count);
- if (size < 1)
+ if (count) {
+ ssize_t size = full_read(fd, buf, count);
+ if (size != count)
bb_error_msg_and_die("short read");
- count -= size;
- buf = ((char *) buf) + size;
}
}
// Die with an error message if we can't write the entire buffer.
void xwrite(int fd, void *buf, size_t count)
{
- while (count) {
- ssize_t size = safe_write(fd, buf, count);
- if (size < 1)
+ if (count) {
+ ssize_t size = full_write(fd, buf, count);
+ if (size != count)
bb_error_msg_and_die("short write");
- count -= size;
- buf = ((char *) buf) + size;
}
}
More information about the busybox-cvs
mailing list