aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2013-08-19 09:00:08 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2013-08-19 09:00:08 +0200
commit4b1896cd2ccdb3e09070035f86a48d42b678d8ff (patch)
tree9298db8a54e017e187b57b053cd1b9291ff82478
parentec2bef11a7ea6381b21e77a3a83cc7730b7e9aef (diff)
downloadbusybox-w32-4b1896cd2ccdb3e09070035f86a48d42b678d8ff.tar.gz
busybox-w32-4b1896cd2ccdb3e09070035f86a48d42b678d8ff.tar.bz2
busybox-w32-4b1896cd2ccdb3e09070035f86a48d42b678d8ff.zip
dd: do not reuse local variables for unrelated values.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/dd.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 96602ebdd..9cb96bb06 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -201,7 +201,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
201 }; 201 };
202 int exitcode = EXIT_FAILURE; 202 int exitcode = EXIT_FAILURE;
203 size_t ibs = 512, obs = 512; 203 size_t ibs = 512, obs = 512;
204 ssize_t n, w; 204 int i;
205 char *ibuf, *obuf; 205 char *ibuf, *obuf;
206 /* And these are all zeroed at once! */ 206 /* And these are all zeroed at once! */
207 struct { 207 struct {
@@ -223,10 +223,10 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
223 INIT_G(); 223 INIT_G();
224 //fflush_all(); - is this needed because of NOEXEC? 224 //fflush_all(); - is this needed because of NOEXEC?
225 225
226 for (n = 1; argv[n]; n++) { 226 for (i = 1; argv[i]; i++) {
227 int what; 227 int what;
228 char *val; 228 char *val;
229 char *arg = argv[n]; 229 char *arg = argv[i];
230 230
231#if ENABLE_DESKTOP 231#if ENABLE_DESKTOP
232 /* "dd --". NB: coreutils 6.9 will complain if they see 232 /* "dd --". NB: coreutils 6.9 will complain if they see
@@ -300,7 +300,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
300 outfile = val; 300 outfile = val;
301 /*continue;*/ 301 /*continue;*/
302 } 302 }
303 } /* end of "for (argv[n])" */ 303 } /* end of "for (argv[i])" */
304 304
305//XXX:FIXME for huge ibs or obs, malloc'ing them isn't the brightest idea ever 305//XXX:FIXME for huge ibs or obs, malloc'ing them isn't the brightest idea ever
306 ibuf = obuf = xmalloc(ibs); 306 ibuf = obuf = xmalloc(ibs);
@@ -347,7 +347,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
347 if (skip) { 347 if (skip) {
348 if (lseek(ifd, skip * ibs, SEEK_CUR) < 0) { 348 if (lseek(ifd, skip * ibs, SEEK_CUR) < 0) {
349 while (skip-- > 0) { 349 while (skip-- > 0) {
350 n = safe_read(ifd, ibuf, ibs); 350 ssize_t n = safe_read(ifd, ibuf, ibs);
351 if (n < 0) 351 if (n < 0)
352 goto die_infile; 352 goto die_infile;
353 if (n == 0) 353 if (n == 0)
@@ -361,6 +361,8 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
361 } 361 }
362 362
363 while (!(flags & FLAG_COUNT) || (G.in_full + G.in_part != count)) { 363 while (!(flags & FLAG_COUNT) || (G.in_full + G.in_part != count)) {
364 ssize_t n;
365
364 n = safe_read(ifd, ibuf, ibs); 366 n = safe_read(ifd, ibuf, ibs);
365 if (n == 0) 367 if (n == 0)
366 break; 368 break;
@@ -411,7 +413,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
411 } 413 }
412 414
413 if (ENABLE_FEATURE_DD_IBS_OBS && oc) { 415 if (ENABLE_FEATURE_DD_IBS_OBS && oc) {
414 w = full_write_or_warn(obuf, oc, outfile); 416 ssize_t w = full_write_or_warn(obuf, oc, outfile);
415 if (w < 0) goto out_status; 417 if (w < 0) goto out_status;
416 if (w > 0) G.out_part++; 418 if (w > 0) G.out_part++;
417 } 419 }