From a049d8736c94e13529650a63fe690c73652ecfd7 Mon Sep 17 00:00:00 2001 From: Packit Service Date: Dec 09 2020 23:29:38 +0000 Subject: Apply patch netpbm-covscan.patch patch_name: netpbm-covscan.patch present_in_specfile: true location_in_specfile: 21 --- diff --git a/converter/other/fiasco/lib/error.c b/converter/other/fiasco/lib/error.c index 08291ce..b56eb50 100644 --- a/converter/other/fiasco/lib/error.c +++ b/converter/other/fiasco/lib/error.c @@ -89,8 +89,10 @@ set_error(const char *format, ...) { } else if (*str == 'c') { (void)va_arg(args, int); len += 1; - } else + } else { + va_end(args); return; + } ++str; } va_end(args); @@ -204,8 +206,10 @@ warning (const char *format, ...) VA_START (args, format); - if (verboselevel == FIASCO_NO_VERBOSITY) + if (verboselevel == FIASCO_NO_VERBOSITY) { + va_end (args); return; + } fprintf (stderr, "Warning: "); vfprintf (stderr, format, args); @@ -224,8 +228,10 @@ message (const char *format, ...) VA_START (args, format); - if (verboselevel == FIASCO_NO_VERBOSITY) + if (verboselevel == FIASCO_NO_VERBOSITY) { + va_end(args); return; + } vfprintf (stderr, format, args); fputc ('\n', stderr); @@ -242,8 +248,10 @@ debug_message (const char *format, ...) VA_START (args, format); - if (verboselevel < FIASCO_ULTIMATE_VERBOSITY) + if (verboselevel < FIASCO_ULTIMATE_VERBOSITY) { + va_end (args); return; + } fprintf (stderr, "*** "); vfprintf (stderr, format, args); @@ -261,8 +269,10 @@ info (const char *format, ...) VA_START (args, format); - if (verboselevel == FIASCO_NO_VERBOSITY) + if (verboselevel == FIASCO_NO_VERBOSITY) { + va_end (args); return; + } vfprintf (stderr, format, args); fflush (stderr); diff --git a/converter/other/gemtopnm.c b/converter/other/gemtopnm.c index 5f1a51a..fc96882 100644 --- a/converter/other/gemtopnm.c +++ b/converter/other/gemtopnm.c @@ -101,10 +101,11 @@ main(argc, argv) if (planes == 1) type = PBM_TYPE; - else + else type = PPM_TYPE; - pnm_writepnminit( stdout, cols, rows, MAXVAL, type, 0 ); + pnm_writepnminit( stdout, cols, rows, MAXVAL, type, 0 ); + overflow_add(cols, padright); { diff --git a/converter/other/jbig/jbigtopnm.c b/converter/other/jbig/jbigtopnm.c index 733ba22..8fa076e 100644 --- a/converter/other/jbig/jbigtopnm.c +++ b/converter/other/jbig/jbigtopnm.c @@ -279,6 +279,7 @@ int main (int argc, char **argv) } pm_close(fout); + pm_close(fin); jbg_dec_free(&s); diff --git a/converter/other/jbig/libjbig/jbig.c b/converter/other/jbig/libjbig/jbig.c index 0d29f77..ba9c645 100644 --- a/converter/other/jbig/libjbig/jbig.c +++ b/converter/other/jbig/libjbig/jbig.c @@ -887,7 +887,7 @@ void jbg_enc_options(struct jbg_enc_state *s, int order, int options, if (order >= 0 && order <= 0x0f) s->order = order; if (options >= 0) s->options = options; if (l0 > 0) s->l0 = l0; - if (mx >= 0 && my < 128) s->mx = mx; + if (mx >= 0 && mx < 128) s->mx = mx; if (my >= 0 && my < 256) s->my = my; return; diff --git a/converter/other/jpeg2000/jpeg2ktopam.c b/converter/other/jpeg2000/jpeg2ktopam.c index b727624..0a94f80 100644 --- a/converter/other/jpeg2000/jpeg2ktopam.c +++ b/converter/other/jpeg2000/jpeg2ktopam.c @@ -135,11 +135,11 @@ readJ2k(const char * const inputFilename, jasperP = jas_image_decode(instreamP, jas_image_getfmt(instreamP), (char*)options); - if (jasperP == NULL) + if (jasperP == NULL) { pm_error("Unable to interpret JPEG-2000 input. " "The Jasper library jas_image_decode() subroutine failed."); - - jas_stream_close(instreamP); + } + jas_stream_close(instreamP); *jasperPP = jasperP; } diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_util.c b/converter/other/jpeg2000/libjasper/jpc/jpc_util.c index 82f4b28..08ac238 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_util.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_util.c @@ -151,7 +151,7 @@ int jpc_atoaf(const char *s, int *numvalues, double **values) if ((cp = strtok(buf, delim))) { ++n; while ((cp = strtok(0, delim))) { - if (cp != '\0') { + if (*cp != '\0') { ++n; } } @@ -169,7 +169,7 @@ int jpc_atoaf(const char *s, int *numvalues, double **values) vs[n] = atof(cp); ++n; while ((cp = strtok(0, delim))) { - if (cp != '\0') { + if (*cp != '\0') { vs[n] = atof(cp); ++n; } diff --git a/converter/other/jpeg2000/pamtojpeg2k.c b/converter/other/jpeg2000/pamtojpeg2k.c index 4a6b250..066cc7d 100644 --- a/converter/other/jpeg2000/pamtojpeg2k.c +++ b/converter/other/jpeg2000/pamtojpeg2k.c @@ -355,7 +355,7 @@ convertToJasperImage(struct pam * const inpamP, JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_RGB_B)); } } else { - if (strncmp(inpamP->tuple_type, "GRAYSCALE", 9 == 0) || + if (strncmp(inpamP->tuple_type, "GRAYSCALE", 9) == 0 || strncmp(inpamP->tuple_type, "BLACKANDWHITE", 13) == 0) { jas_image_setclrspc(jasperP, JAS_CLRSPC_GENGRAY); jas_image_setcmpttype(jasperP, 0, diff --git a/converter/pbm/pbmtoln03.c b/converter/pbm/pbmtoln03.c index f7cf53c..1b4c56b 100644 --- a/converter/pbm/pbmtoln03.c +++ b/converter/pbm/pbmtoln03.c @@ -80,22 +80,25 @@ output_sixel_record (unsigned char * record, int width) { /* Do an encoding */ record[j++] = '!' ; sprintf (repeated_str, "%d", i - start_repeat) ; - for (p = repeated_str ; *p ; p++) + for (p = repeated_str ; *p ; p++) { record[j++] = *p ; - record[j++] = last_char ; } + } + record[j++] = last_char ; - else { + } else { for (k = 0 ; k < repeated ; k++) - record[j++] = last_char ; } + record[j++] = last_char ; + } start_repeat = i ; - last_char = record[i] ; } + last_char = record[i] ; } + } fwrite ((char *) record, j, 1, stdout) ; putchar ('-') ; /* DECGNL (graphics new-line) */ putchar ('\n') ; - } +} static void diff --git a/converter/pbm/pbmtomacp.c b/converter/pbm/pbmtomacp.c index df5cbb0..64f918b 100644 --- a/converter/pbm/pbmtomacp.c +++ b/converter/pbm/pbmtomacp.c @@ -177,7 +177,7 @@ calculateCropPad(struct CmdlineInfo const cmdline, pm_message("Specified -bottom value %u is beyond edge of " "input image", cmdline.bottom); - bottom = MIN3(cmdline.bottom, rows - 1, top + MACP_ROWS - 1); + bottom = MIN3(cmdline.bottom, rows - 1, top + MACP_ROWS - 1); } else bottom = MIN(rows - 1, top + MACP_ROWS - 1); diff --git a/converter/pbm/pbmtoppa/pbm.c b/converter/pbm/pbmtoppa/pbm.c index 1c8d236..32802d4 100644 --- a/converter/pbm/pbmtoppa/pbm.c +++ b/converter/pbm/pbmtoppa/pbm.c @@ -12,6 +12,7 @@ #include #include +#include "ppm.h" #include "ppapbm.h" int make_pbm_stat(pbm_stat* pbm,FILE* fptr) diff --git a/converter/ppm/pjtoppm.c b/converter/ppm/pjtoppm.c index 62ce77e..abec4db 100644 --- a/converter/ppm/pjtoppm.c +++ b/converter/ppm/pjtoppm.c @@ -11,6 +11,7 @@ */ #include "ppm.h" +#include "pm.h" #include "mallocvar.h" static char usage[] = "[paintjetfile]"; diff --git a/converter/ppm/ppmtomitsu.c b/converter/ppm/ppmtomitsu.c index 1d2be20..4be1c1c 100644 --- a/converter/ppm/ppmtomitsu.c +++ b/converter/ppm/ppmtomitsu.c @@ -651,9 +651,10 @@ main(int argc, char * argv[]) { dpi300 = TRUE; else if (pm_keymatch(argv[argn], "-tiny", 2)) tiny = TRUE; - else + else pm_usage(usage); - ++argn; + + ++argn; } if (argn < argc) { diff --git a/converter/ppm/tgatoppm.c b/converter/ppm/tgatoppm.c index 3660e64..0601402 100644 --- a/converter/ppm/tgatoppm.c +++ b/converter/ppm/tgatoppm.c @@ -168,8 +168,8 @@ get_pixel(FILE * const ifP, pixel * dest, int Size, gray *alpha_p) { Red = getbyte( ifP ); if ( Size == 32 ) Alpha = getbyte( ifP ); - else - Alpha = 0; + else + Alpha = 0; l = 0; break; diff --git a/converter/ppm/xpmtoppm.c b/converter/ppm/xpmtoppm.c index 9471ec7..52eaca1 100644 --- a/converter/ppm/xpmtoppm.c +++ b/converter/ppm/xpmtoppm.c @@ -941,8 +941,8 @@ convertRaster(FILE * const ifP, if (imageOutFileP) ppm_writeppmrow(imageOutFileP, pixrow, cols, PPM_MAXMAXVAL, 0); - if (alphaOutFileP) - pbm_writepbmrow(alphaOutFileP, alpharow, cols, 0); + if (alphaOutFileP) + pbm_writepbmrow(alphaOutFileP, alpharow, cols, 0); } pbm_freerow(alpharow); diff --git a/editor/pnmconvol.c b/editor/pnmconvol.c index 98ec3a6..b1d8e02 100644 --- a/editor/pnmconvol.c +++ b/editor/pnmconvol.c @@ -733,7 +733,7 @@ parsePlaneFileLine(const char * const line, "-matrix value is not a valid floating point " "number", colCt, line); - ++colCt; + ++colCt; } pm_strfree(token); } diff --git a/generator/pbmtext.c b/generator/pbmtext.c index 0fe8ad6..b2579d1 100644 --- a/generator/pbmtext.c +++ b/generator/pbmtext.c @@ -404,7 +404,7 @@ fixControlChars(const PM_WCHAR * const input, output[outCursor++] = L' '; } else if (currentChar > fontP->maxglyph || !fontP->glyph[currentChar]) { - if (currentChar > PM_FONT2_MAXGLYPH) + if (currentChar > PM_FONT2_MAXGLYPH){ pm_message("code point %X is beyond what this program " "can handle. Max=%X", (unsigned int)currentChar, PM_FONT2_MAXGLYPH); @@ -420,15 +420,15 @@ fixControlChars(const PM_WCHAR * const input, (unsigned int) currentChar ); output[outCursor++] = ' '; } + } } else output[outCursor++] = input[inCursor]; - + assert(outCursor <= outputSize); } output[outCursor++] = L'\0'; assert(outCursor <= outputSize); - *outputP = output; } diff --git a/lib/libpm.c b/lib/libpm.c index 36c49c7..14d5e38 100644 --- a/lib/libpm.c +++ b/lib/libpm.c @@ -437,9 +437,10 @@ pm_maxvaltobits(int const maxval) { return 15; else if ( (long) maxval <= 65535L ) return 16; - else + else { pm_error( "maxval of %d is too large!", maxval ); return -1; /* Should never come here */ + } } int diff --git a/other/pamfix.c b/other/pamfix.c index 8db67e0..4225ba1 100644 --- a/other/pamfix.c +++ b/other/pamfix.c @@ -184,7 +184,7 @@ clipPamRow(const struct pam * const pamP, "image maxval of %lu", row, col, plane, tuplerow[col][plane], pamP->maxval); - tuplerow[col][plane] = pamP->maxval; + tuplerow[col][plane] = pamP->maxval; } } } diff --git a/other/pnmcolormap.c b/other/pnmcolormap.c index 7195295..d1cbca7 100644 --- a/other/pnmcolormap.c +++ b/other/pnmcolormap.c @@ -838,9 +838,10 @@ colormapToSquare(struct pam * const pamP, unsigned int const intsqrt = (int)sqrt((float)colormap.size); if (intsqrt * intsqrt == colormap.size) pamP->width = intsqrt; - else + else { pamP->width = intsqrt + 1; overflow_add(intsqrt, 1); + } } { unsigned int const intQuotient = colormap.size / pamP->width;