aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Denys Vlasenko <vda.linux@googlemail.com>2018-10-30 17:04:52 +0100
committerGravatar Denys Vlasenko <vda.linux@googlemail.com>2018-10-30 17:04:52 +0100
commit9ab5a8d56068261eb4117e4a743a30d05cc6c2c5 (patch)
tree6328b2315572a7318a43856fa4b77b58cfaef290
parent3f6a978a0dabe08e9df15b3f9ee2bd3cf8e3c441 (diff)
downloadbusybox-9ab5a8d56068261eb4117e4a743a30d05cc6c2c5.tar.gz
busybox-9ab5a8d56068261eb4117e4a743a30d05cc6c2c5.tar.bz2
dd: do not have 'ocount' variable if ibs/obs support is not enabled
function old new delta packed_usage 32964 32961 -3 dd_main 1033 1021 -12 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-15) Total: -15 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/dd.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 129637e24..39ce5019f 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -56,8 +56,11 @@
//kbuild:lib-$(CONFIG_DD) += dd.o
//usage:#define dd_trivial_usage
-//usage: "[if=FILE] [of=FILE] " IF_FEATURE_DD_IBS_OBS("[ibs=N] [obs=N] ") "[bs=N] [count=N] [skip=N]\n"
-//usage: " [seek=N]" IF_FEATURE_DD_IBS_OBS(" [conv=notrunc|noerror|sync|fsync] [iflag=skip_bytes|fullblock] [oflag=seek_bytes]")
+//usage: "[if=FILE] [of=FILE] [" IF_FEATURE_DD_IBS_OBS("ibs=N obs=N/") "bs=N] [count=N] [skip=N] [seek=N]\n"
+//usage: IF_FEATURE_DD_IBS_OBS(
+//usage: " [conv=notrunc|noerror|sync|fsync]\n"
+//usage: " [iflag=skip_bytes|fullblock] [oflag=seek_bytes]"
+//usage: )
//usage:#define dd_full_usage "\n\n"
//usage: "Copy a file with converting and formatting\n"
//usage: "\n if=FILE Read from FILE instead of stdin"
@@ -321,13 +324,13 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
#endif
/* These are all zeroed at once! */
struct {
- size_t oc;
+ IF_FEATURE_DD_IBS_OBS(size_t ocount;)
ssize_t prev_read_size; /* for detecting swab failure */
off_t count;
off_t seek, skip;
const char *infile, *outfile;
} Z;
-#define oc (Z.oc )
+#define ocount (Z.ocount )
#define prev_read_size (Z.prev_read_size)
#define count (Z.count )
#define seek (Z.seek )
@@ -542,24 +545,26 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
n = ibs;
}
}
+#if ENABLE_FEATURE_DD_IBS_OBS
if (G.flags & FLAG_TWOBUFS) {
char *tmp = ibuf;
while (n) {
- size_t d = obs - oc;
-
+ size_t d = obs - ocount;
if (d > (size_t)n)
d = n;
- memcpy(obuf + oc, tmp, d);
+ memcpy(obuf + ocount, tmp, d);
n -= d;
tmp += d;
- oc += d;
- if (oc == obs) {
+ ocount += d;
+ if (ocount == obs) {
if (write_and_stats(obuf, obs, obs, outfile))
goto out_status;
- oc = 0;
+ ocount = 0;
}
}
- } else {
+ } else
+#endif
+ {
if (write_and_stats(ibuf, n, obs, outfile))
goto out_status;
}
@@ -570,10 +575,12 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
goto die_outfile;
}
- if (ENABLE_FEATURE_DD_IBS_OBS && oc) {
- if (write_and_stats(obuf, oc, obs, outfile))
+#if ENABLE_FEATURE_DD_IBS_OBS
+ if (ocount != 0) {
+ if (write_and_stats(obuf, ocount, obs, outfile))
goto out_status;
}
+#endif
if (close(ifd) < 0) {
die_infile:
bb_simple_perror_msg_and_die(infile);