diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-10-30 17:04:52 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-10-30 17:04:52 +0100 |
commit | 9ab5a8d56068261eb4117e4a743a30d05cc6c2c5 (patch) | |
tree | 6328b2315572a7318a43856fa4b77b58cfaef290 | |
parent | 3f6a978a0dabe08e9df15b3f9ee2bd3cf8e3c441 (diff) | |
download | busybox-w32-9ab5a8d56068261eb4117e4a743a30d05cc6c2c5.tar.gz busybox-w32-9ab5a8d56068261eb4117e4a743a30d05cc6c2c5.tar.bz2 busybox-w32-9ab5a8d56068261eb4117e4a743a30d05cc6c2c5.zip |
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.c | 33 |
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 @@ | |||
56 | //kbuild:lib-$(CONFIG_DD) += dd.o | 56 | //kbuild:lib-$(CONFIG_DD) += dd.o |
57 | 57 | ||
58 | //usage:#define dd_trivial_usage | 58 | //usage:#define dd_trivial_usage |
59 | //usage: "[if=FILE] [of=FILE] " IF_FEATURE_DD_IBS_OBS("[ibs=N] [obs=N] ") "[bs=N] [count=N] [skip=N]\n" | 59 | //usage: "[if=FILE] [of=FILE] [" IF_FEATURE_DD_IBS_OBS("ibs=N obs=N/") "bs=N] [count=N] [skip=N] [seek=N]\n" |
60 | //usage: " [seek=N]" IF_FEATURE_DD_IBS_OBS(" [conv=notrunc|noerror|sync|fsync] [iflag=skip_bytes|fullblock] [oflag=seek_bytes]") | 60 | //usage: IF_FEATURE_DD_IBS_OBS( |
61 | //usage: " [conv=notrunc|noerror|sync|fsync]\n" | ||
62 | //usage: " [iflag=skip_bytes|fullblock] [oflag=seek_bytes]" | ||
63 | //usage: ) | ||
61 | //usage:#define dd_full_usage "\n\n" | 64 | //usage:#define dd_full_usage "\n\n" |
62 | //usage: "Copy a file with converting and formatting\n" | 65 | //usage: "Copy a file with converting and formatting\n" |
63 | //usage: "\n if=FILE Read from FILE instead of stdin" | 66 | //usage: "\n if=FILE Read from FILE instead of stdin" |
@@ -321,13 +324,13 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
321 | #endif | 324 | #endif |
322 | /* These are all zeroed at once! */ | 325 | /* These are all zeroed at once! */ |
323 | struct { | 326 | struct { |
324 | size_t oc; | 327 | IF_FEATURE_DD_IBS_OBS(size_t ocount;) |
325 | ssize_t prev_read_size; /* for detecting swab failure */ | 328 | ssize_t prev_read_size; /* for detecting swab failure */ |
326 | off_t count; | 329 | off_t count; |
327 | off_t seek, skip; | 330 | off_t seek, skip; |
328 | const char *infile, *outfile; | 331 | const char *infile, *outfile; |
329 | } Z; | 332 | } Z; |
330 | #define oc (Z.oc ) | 333 | #define ocount (Z.ocount ) |
331 | #define prev_read_size (Z.prev_read_size) | 334 | #define prev_read_size (Z.prev_read_size) |
332 | #define count (Z.count ) | 335 | #define count (Z.count ) |
333 | #define seek (Z.seek ) | 336 | #define seek (Z.seek ) |
@@ -542,24 +545,26 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
542 | n = ibs; | 545 | n = ibs; |
543 | } | 546 | } |
544 | } | 547 | } |
548 | #if ENABLE_FEATURE_DD_IBS_OBS | ||
545 | if (G.flags & FLAG_TWOBUFS) { | 549 | if (G.flags & FLAG_TWOBUFS) { |
546 | char *tmp = ibuf; | 550 | char *tmp = ibuf; |
547 | while (n) { | 551 | while (n) { |
548 | size_t d = obs - oc; | 552 | size_t d = obs - ocount; |
549 | |||
550 | if (d > (size_t)n) | 553 | if (d > (size_t)n) |
551 | d = n; | 554 | d = n; |
552 | memcpy(obuf + oc, tmp, d); | 555 | memcpy(obuf + ocount, tmp, d); |
553 | n -= d; | 556 | n -= d; |
554 | tmp += d; | 557 | tmp += d; |
555 | oc += d; | 558 | ocount += d; |
556 | if (oc == obs) { | 559 | if (ocount == obs) { |
557 | if (write_and_stats(obuf, obs, obs, outfile)) | 560 | if (write_and_stats(obuf, obs, obs, outfile)) |
558 | goto out_status; | 561 | goto out_status; |
559 | oc = 0; | 562 | ocount = 0; |
560 | } | 563 | } |
561 | } | 564 | } |
562 | } else { | 565 | } else |
566 | #endif | ||
567 | { | ||
563 | if (write_and_stats(ibuf, n, obs, outfile)) | 568 | if (write_and_stats(ibuf, n, obs, outfile)) |
564 | goto out_status; | 569 | goto out_status; |
565 | } | 570 | } |
@@ -570,10 +575,12 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
570 | goto die_outfile; | 575 | goto die_outfile; |
571 | } | 576 | } |
572 | 577 | ||
573 | if (ENABLE_FEATURE_DD_IBS_OBS && oc) { | 578 | #if ENABLE_FEATURE_DD_IBS_OBS |
574 | if (write_and_stats(obuf, oc, obs, outfile)) | 579 | if (ocount != 0) { |
580 | if (write_and_stats(obuf, ocount, obs, outfile)) | ||
575 | goto out_status; | 581 | goto out_status; |
576 | } | 582 | } |
583 | #endif | ||
577 | if (close(ifd) < 0) { | 584 | if (close(ifd) < 0) { |
578 | die_infile: | 585 | die_infile: |
579 | bb_simple_perror_msg_and_die(infile); | 586 | bb_simple_perror_msg_and_die(infile); |