aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coreutils/dd.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 9299f58bc..2838f6341 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -395,7 +395,8 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
395 n = 0; 395 n = 0;
396 } 396 }
397 if (flags & FLAG_SWAB) { 397 if (flags & FLAG_SWAB) {
398 uint16_t *p16, *end; 398 uint16_t *p16;
399 ssize_t n2;
399 400
400 /* Our code allows only last read to be odd-sized */ 401 /* Our code allows only last read to be odd-sized */
401 if (prev_read_size & 1) 402 if (prev_read_size & 1)
@@ -408,8 +409,8 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
408 * prints "wqe". 409 * prints "wqe".
409 */ 410 */
410 p16 = (void*) ibuf; 411 p16 = (void*) ibuf;
411 end = (void*) (ibuf + (n & ~(ssize_t)1)); 412 n2 = (n >> 1);
412 while (p16 < end) { 413 while (--n2 >= 0) {
413 *p16 = bswap_16(*p16); 414 *p16 = bswap_16(*p16);
414 p16++; 415 p16++;
415 } 416 }