[hackers] [farbfeld] Convert depth-check to switch and remove unused variables || FRIGN

From: <git_AT_suckless.org>
Date: Mon, 4 Jan 2016 18:34:05 +0100 (CET)

commit 06c4b47d0102d2e2205c983c2158b4121c7293ab
Author: FRIGN <dev_AT_frign.de>
AuthorDate: Mon Jan 4 18:33:42 2016 +0100
Commit: FRIGN <dev_AT_frign.de>
CommitDate: Mon Jan 4 18:33:42 2016 +0100

    Convert depth-check to switch and remove unused variables

diff --git a/png2ff.c b/png2ff.c
index 5b75dfa..101036d 100644
--- a/png2ff.c
+++ b/png2ff.c
_AT_@ -13,7 +13,7 @@ main(int argc, char *argv[])
         png_structp png_struct_p;
         png_infop png_info_p;
         png_bytepp png_row_p;
- int depth, color, interlace;
+ int depth;
         uint32_t width, height, png_row_len, tmp32, r, i;
         uint16_t tmp16;
 
_AT_@ -43,7 +43,7 @@ main(int argc, char *argv[])
         png_read_png(png_struct_p, png_info_p, PNG_TRANSFORM_PACKING |
                      PNG_TRANSFORM_EXPAND, NULL);
         png_get_IHDR(png_struct_p, png_info_p, &width, &height, &depth,
- &color, &interlace, NULL, NULL);
+ NULL, NULL, NULL, NULL);
         png_row_len = png_get_rowbytes(png_struct_p, png_info_p);
         png_row_p = png_get_rows(png_struct_p, png_info_p);
 
_AT_@ -55,7 +55,8 @@ main(int argc, char *argv[])
         fwrite(&tmp32, sizeof(uint32_t), 1, stdout);
 
         /* write data */
- if (depth == 8) {
+ switch(depth) {
+ case 8:
                 for (r = 0; r < height; ++r) {
                         for (i = 0; i < png_row_len; i++) {
                                 /* ((2^16-1) / 255) == 257 */
_AT_@ -63,7 +64,8 @@ main(int argc, char *argv[])
                                 fwrite(&tmp16, sizeof(uint16_t), 1, stdout);
                         }
                 }
- } else if (depth == 16) {
+ break;
+ case 16:
                 for (r = 0; r < height; ++r) {
                         for (i = 0; i < png_row_len / 2; i++) {
                                 tmp16 = *((uint16_t *)
_AT_@ -71,7 +73,8 @@ main(int argc, char *argv[])
                                 fwrite(&tmp16, sizeof(uint16_t), 1, stdout);
                         }
                 }
- } else {
+ break;
+ default:
                 fprintf(stderr, "format error\n");
                 return 1;
         }
Received on Mon Jan 04 2016 - 18:34:05 CET

This archive was generated by hypermail 2.3.0 : Mon Jan 04 2016 - 18:36:18 CET