diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-10-23 20:35:47 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-10-23 20:36:37 +0200 |
commit | c9e9a57fce214b24d250921654b101ff433962e7 (patch) | |
tree | a0b716043b57fbf7a21d3be10c3e76e49e1829a9 /src/shared/qrcode-util.c | |
parent | meson: sort include dirs (diff) | |
download | systemd-c9e9a57fce214b24d250921654b101ff433962e7.tar.xz systemd-c9e9a57fce214b24d250921654b101ff433962e7.zip |
shared/qrcode-util: reduce scope of iterator variables
Diffstat (limited to 'src/shared/qrcode-util.c')
-rw-r--r-- | src/shared/qrcode-util.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/shared/qrcode-util.c b/src/shared/qrcode-util.c index a545daaef3..99995eb893 100644 --- a/src/shared/qrcode-util.c +++ b/src/shared/qrcode-util.c @@ -4,13 +4,11 @@ #define ANSI_WHITE_ON_BLACK "\033[40;37;1m" static void print_border(FILE *output, unsigned width) { - unsigned x, y; - /* Four rows of border */ - for (y = 0; y < 4; y += 2) { + for (unsigned y = 0; y < 4; y += 2) { fputs(ANSI_WHITE_ON_BLACK, output); - for (x = 0; x < 4 + width + 4; x++) + for (unsigned x = 0; x < 4 + width + 4; x++) fputs("\342\226\210", output); fputs(ANSI_NORMAL "\n", output); @@ -18,8 +16,6 @@ static void print_border(FILE *output, unsigned width) { } void write_qrcode(FILE *output, QRcode *qr) { - unsigned x, y; - assert(qr); if (!output) @@ -27,17 +23,15 @@ void write_qrcode(FILE *output, QRcode *qr) { print_border(output, qr->width); - for (y = 0; y < (unsigned) qr->width; y += 2) { - const uint8_t *row1, *row2; - - row1 = qr->data + qr->width * y; - row2 = row1 + qr->width; + for (unsigned y = 0; y < (unsigned) qr->width; y += 2) { + const uint8_t *row1 = qr->data + qr->width * y; + const uint8_t *row2 = row1 + qr->width; fputs(ANSI_WHITE_ON_BLACK, output); - for (x = 0; x < 4; x++) + for (unsigned x = 0; x < 4; x++) fputs("\342\226\210", output); - for (x = 0; x < (unsigned) qr->width; x ++) { + for (unsigned x = 0; x < (unsigned) qr->width; x++) { bool a, b; a = row1[x] & 1; @@ -53,7 +47,7 @@ void write_qrcode(FILE *output, QRcode *qr) { fputs("\342\226\210", output); } - for (x = 0; x < 4; x++) + for (unsigned x = 0; x < 4; x++) fputs("\342\226\210", output); fputs(ANSI_NORMAL "\n", output); } |