commit 91afd6c8629f5a1607ce678069061cdcd07f0551
parent 1f2f60207407a4556b3fac0fabfc87ef945383c8
Author: ssnf <ssnf@ssnf.xyz>
Date: Mon, 12 Jul 2021 09:21:34 +0000
removed unnecessary variable
Diffstat:
M | dd.c | | | 24 | ++++++++++++------------ |
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/dd.c b/dd.c
@@ -23,22 +23,22 @@ main(int argc, char* argv[])
{
FILE* in, *out;
char* buf;
- uint bs, count, i, n;
+ uint bs, count, n;
in = stdin;
out = stdout;
bs = 512;
count = 0;
- for (i = 1; i < argc; ++i) {
- if (!strncmp(argv[i], "if=", 3))
- in = efopen(argv[i] + 3, "r");
- else if (!strncmp(argv[i], "of=", 3))
- out = efopen(argv[i] + 3, "w");
- else if (!strncmp(argv[i], "count=", 6))
- sscanf(argv[i] + 6, "%d", &count);
- else if (!strncmp(argv[i], "bs=", 3)) {
- sscanf(argv[i] + 3, "%d", &bs);
- switch (*(argv[i] + strlen(argv[i]) - 1)) {
+ for (n = 1; n < argc; ++n) {
+ if (!strncmp(argv[n], "if=", 3))
+ in = efopen(argv[n] + 3, "r");
+ else if (!strncmp(argv[n], "of=", 3))
+ out = efopen(argv[n] + 3, "w");
+ else if (!strncmp(argv[n], "count=", 6))
+ sscanf(argv[n] + 6, "%d", &count);
+ else if (!strncmp(argv[n], "bs=", 3)) {
+ sscanf(argv[n] + 3, "%d", &bs);
+ switch (*(argv[n] + strlen(argv[n]) - 1)) {
case 'k':
bs <<= 10;
break;
@@ -57,7 +57,7 @@ main(int argc, char* argv[])
fwrite(buf, 1, n, out);
goto exit;
count:
- for (i = 0; i < count; ++i) {
+ for (;count--;) {
n = fread(buf, 1, bs, in);
fwrite(buf, 1, n, out);
}