diff options
author | Markus Teich <markus.teich@stusta.mhn.de> | 2015-12-09 00:50:05 +0100 |
---|---|---|
committer | Markus Teich <markus.teich@stusta.mhn.de> | 2015-12-09 00:50:05 +0100 |
commit | 008ff1b88b3e9cdd13e82d0ec4fb573c977f6a3d (patch) | |
tree | c3965820d4435f4f35448e00cc2fbacb0d93f933 /sent.c | |
parent | edb46305647d909199a860b6b0812595742f6fe4 (diff) |
fix 2 uninitialized variables and bin == NULL check
Diffstat (limited to 'sent.c')
-rw-r--r-- | sent.c | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -162,23 +162,25 @@ filter(int fd, const char *cmd) Image *ffopen(char *filename) { unsigned char hdr[16]; - char *bin; + char *bin = NULL; regex_t regex; Image *img; size_t i; int tmpfd, fd; - for (bin = NULL, i = 0; i < LEN(filters); i++) { + for (i = 0; i < LEN(filters); i++) { if (regcomp(®ex, filters[i].regex, REG_NOSUB | REG_EXTENDED | REG_ICASE)) continue; if (!regexec(®ex, filename, 0, NULL, 0)) { - if (!(bin = filters[i].bin)) - return NULL; + bin = filters[i].bin break; } } + if (!bin) + return NULL; + if ((fd = open(filename, O_RDONLY)) < 0) { eprintf("Unable to open file %s:", filename); return NULL; @@ -355,7 +357,7 @@ void ffdraw(Image *img) void getfontsize(Slide *s, unsigned int *width, unsigned int *height) { int i, j; - unsigned int curw, imax; + unsigned int curw, new_max; float lfac = linespacing * (s->linecount - 1) + 1; /* fit height */ @@ -369,13 +371,12 @@ void getfontsize(Slide *s, unsigned int *width, unsigned int *height) *width = 0; for (i = 0; i < s->linecount; i++) { curw = drw_fontset_getwidth(d, s->lines[i]); - if (curw >= *width) - imax = i; + newmax = (curw >= *width); while (j > 0 && curw > xw.uw) { drw_setfontset(d, fonts[--j]); curw = drw_fontset_getwidth(d, s->lines[i]); } - if (imax == i) + if (newmax) *width = curw; } *height = fonts[j]->h * lfac; |