diff options
author | John Hawthorn <john.hawthorn@gmail.com> | 2015-04-11 18:16:40 -0700 |
---|---|---|
committer | John Hawthorn <john.hawthorn@gmail.com> | 2015-04-11 18:16:40 -0700 |
commit | 4ab1c75f97cb70543db388b3ed99bcfb7e94c758 (patch) | |
tree | 8482a14390de63083a69bd70f6a2685fa9c306e1 /src | |
parent | 1c0b8ffa1778e0274b660d657a6112676c421f66 (diff) | |
parent | 5c1fde906c6c28c020b518d461467e4178675060 (diff) | |
download | mirror-meh-4ab1c75f97cb70543db388b3ed99bcfb7e94c758.tar.gz mirror-meh-4ab1c75f97cb70543db388b3ed99bcfb7e94c758.tar.bz2 mirror-meh-4ab1c75f97cb70543db388b3ed99bcfb7e94c758.zip |
Fix unused result warnings
Diffstat (limited to 'src')
-rw-r--r-- | src/imagemagick.c | 11 | ||||
-rw-r--r-- | src/netpbm.c | 14 |
2 files changed, 16 insertions, 9 deletions
diff --git a/src/imagemagick.c b/src/imagemagick.c index ada2f6e..a168e80 100644 --- a/src/imagemagick.c +++ b/src/imagemagick.c @@ -30,14 +30,17 @@ struct image *imagemagick_open(FILE *f){ argv[0] = "convert"; argv[1] = "-depth"; argv[2] = "255"; - asprintf(&argv[3], "fd:%i", origfd); - asprintf(&argv[4], "ppm:fd:%i", tmpfd[1]); + if((asprintf(&argv[3], "fd:%i", origfd) < 0) || (asprintf(&argv[4], "ppm:fd:%i", tmpfd[1]) < 0)){ + fprintf(stderr, "Out of memory"); + exit(EXIT_FAILURE); + } argv[5] = NULL; #ifdef NDEBUG /* STFU OMFG */ - freopen("/dev/null", "w", stdout); - freopen("/dev/null", "w", stderr); + FILE *unused __attribute__((unused)); + unused = freopen("/dev/null", "w", stdout); + unused = freopen("/dev/null", "w", stderr); #endif execvp(argv[0], argv); diff --git a/src/netpbm.c b/src/netpbm.c index f30dbbc..0f5eac2 100644 --- a/src/netpbm.c +++ b/src/netpbm.c @@ -41,14 +41,14 @@ struct image *netpbm_open(FILE *f){ b->format = format; skipspace(f); - fscanf(f, "%u", &b->img.bufwidth); + if(fscanf(f, "%u", &b->img.bufwidth) != 1) goto err; skipspace(f); - fscanf(f, "%u", &b->img.bufheight); + if(fscanf(f, "%u", &b->img.bufheight) != 1) goto err; if(format == '1' || format == '4'){ b->maxval = 1; }else{ skipspace(f); - fscanf(f, "%u", &b->maxval); + if(fscanf(f, "%u", &b->maxval) != 1) goto err; } /* whitespace character */ @@ -58,12 +58,16 @@ struct image *netpbm_open(FILE *f){ b->img.fmt = &netpbm; return (struct image *)b; + +err: + free(b); + return NULL; } static unsigned char readvali(struct netpbm_t *b){ skipspace(b->f); int val; - fscanf(b->f, "%i", &val); + int unused = fscanf(b->f, "%i", &val); return val * 255 / b->maxval; } @@ -129,7 +133,7 @@ int netpbm_read(struct image *img){ } }else if(b->format == '6'){ if(b->maxval == 255){ - fread(img->buf, 1, left * 3, f); + int unused = fread(img->buf, 1, left * 3, f); }else{ while(left--){ img->buf[a++] = readvalb(b); |