diff options
author | Maxim Sobolev <sobomax@FreeBSD.org> | 2018-11-29 19:28:01 +0000 |
---|---|---|
committer | Maxim Sobolev <sobomax@FreeBSD.org> | 2018-11-29 19:28:01 +0000 |
commit | dead7b5e47d14f6560c5be40e673664ba20c670f (patch) | |
tree | d35261be8adc5986baf73412030722df77b9435a | |
parent | 7d2b0bd7d78a05f57adb96cc73a605d05938a037 (diff) |
Notes
-rw-r--r-- | bin/dd/dd.c | 10 | ||||
-rw-r--r-- | bin/dd/dd.h | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/bin/dd/dd.c b/bin/dd/dd.c index ef186a8186c3..46175fa4c8f2 100644 --- a/bin/dd/dd.c +++ b/bin/dd/dd.c @@ -511,7 +511,7 @@ void dd_out(int force) { u_char *outp; - size_t cnt, i, n; + size_t cnt, n; ssize_t nw; static int warned; int sparse; @@ -544,12 +544,8 @@ dd_out(int force) do { sparse = 0; if (ddflags & C_SPARSE) { - sparse = 1; /* Is buffer sparse? */ - for (i = 0; i < cnt; i++) - if (outp[i] != 0) { - sparse = 0; - break; - } + /* Is buffer sparse? */ + sparse = BISZERO(outp, cnt); } if (sparse && !force) { pending += cnt; diff --git a/bin/dd/dd.h b/bin/dd/dd.h index 0f7c680a6ee0..8090252923fd 100644 --- a/bin/dd/dd.h +++ b/bin/dd/dd.h @@ -103,3 +103,7 @@ typedef struct { #define C_PROGRESS 0x40000000 #define C_PARITY (C_PAREVEN | C_PARODD | C_PARNONE | C_PARSET) + +#define BISZERO(p, s) ((s) > 0 && *((const char *)p) == 0 && !memcmp( \ + (const void *)(p), (const void *) \ + ((const char *)p + 1), (s) - 1)) |