[gs-commits] rev 11770 - trunk/gs/base

ken at ghostscript.com ken at ghostscript.com
Thu Oct 7 12:49:55 UTC 2010


Author: ken
Date: 2010-10-07 12:49:54 +0000 (Thu, 07 Oct 2010)
New Revision: 11770

Modified:
   trunk/gs/base/gdevpdfi.c
   trunk/gs/base/gdevpdfj.c
   trunk/gs/base/gdevpdfm.c
   trunk/gs/base/gdevpdfp.c
   trunk/gs/base/gdevpdfu.c
   trunk/gs/base/gdevpdtb.c
   trunk/gs/base/gdevpdtc.c
   trunk/gs/base/gdevpdtd.c
   trunk/gs/base/gdevpdtf.c
   trunk/gs/base/gdevpdti.c
   trunk/gs/base/gdevpdtt.c
Log:
More changes to silence static analysis warnings. Mostly removing unused variables or
assignments.


Modified: trunk/gs/base/gdevpdfi.c
===================================================================
--- trunk/gs/base/gdevpdfi.c	2010-10-07 08:35:58 UTC (rev 11769)
+++ trunk/gs/base/gdevpdfi.c	2010-10-07 12:49:54 UTC (rev 11770)
@@ -727,7 +727,7 @@
      * this piece of code.
      */
     rc_increment_cs(image[0].pixel.ColorSpace);
-    if ((code = pdf_begin_write_image(pdev, &pie->writer, gs_no_id, width,
+    if ((pdf_begin_write_image(pdev, &pie->writer, gs_no_id, width,
 		    height, pnamed, in_line)) < 0 ||
 	/*
 	 * Some regrettable PostScript code (such as LanguageLevel 1 output
@@ -738,7 +738,7 @@
 	 * filters if the transfer function(s) is/are other than the
 	 * identity.
 	 */
-	(code = (pie->writer.alt_writer_count == 1 ?
+	((pie->writer.alt_writer_count == 1 ?
 		 psdf_setup_lossless_filters((gx_device_psdf *) pdev,
 					     &pie->writer.binary[0],
 					     &image[0].pixel, in_line) :
@@ -1277,6 +1277,8 @@
 	code = gx_default_begin_typed_image
 	    ((gx_device *)&cvd->mdev, pis, pmat, pic, prect, pdcolor, NULL, mem,
 	    pinfo);
+	if (code < 0)
+	    return code;
     } else {
 	code = pdf_make_mxd(pmcdev, midev, mem);
 	if (code < 0)
@@ -1284,6 +1286,8 @@
 	code = pdf_begin_typed_image
 	    ((gx_device_pdf *)dev, pis, pmat, pic, prect, pdcolor, pcpath, mem,
 	    pinfo, PDF_IMAGE_TYPE3_DATA);
+	if (code < 0)
+	    return code;
     }
     /* Due to equal image merging, we delay the adding of the "Mask" entry into 
        a type 3 image dictionary until the mask is completed. 
@@ -1322,7 +1326,6 @@
     int code;
     pdf_image_enum *pmie;
     pdf_image_enum *pmce;
-    cos_stream_t *pmcs;
     int i;
     const gs_image3x_mask_t *pixm;
 
@@ -1350,7 +1353,6 @@
     }
     pmie = (pdf_image_enum *)pminfo[i];
     pmce = (pdf_image_enum *)(*pinfo);
-    pmcs = (cos_stream_t *)pmce->writer.pres->object;
     /*
      * Add the SMask entry to the image dictionary, and, if needed,
      * the Matte entry to the mask dictionary.

Modified: trunk/gs/base/gdevpdfj.c
===================================================================
--- trunk/gs/base/gdevpdfj.c	2010-10-07 08:35:58 UTC (rev 11769)
+++ trunk/gs/base/gdevpdfj.c	2010-10-07 12:49:54 UTC (rev 11770)
@@ -426,7 +426,7 @@
 	    for (; lines_left; lines_left--) 
 		for (i = 0; i < piw->alt_writer_count; i++) {
 		    for (l = bytes_per_line; l > 0; l -= lb)
-			if ((status = sputs(piw->binary[i].strm, buf, min(l, lb), 
+			if ((sputs(piw->binary[i].strm, buf, min(l, lb), 
 					    &ignore)) < 0)
 			    return_error(gs_error_ioerror);
 		}

Modified: trunk/gs/base/gdevpdfm.c
===================================================================
--- trunk/gs/base/gdevpdfm.c	2010-10-07 08:35:58 UTC (rev 11769)
+++ trunk/gs/base/gdevpdfm.c	2010-10-07 12:49:54 UTC (rev 11770)
@@ -1512,7 +1512,7 @@
 		    return_error(gs_error_VMerror);
 		memcpy(str, vdata, j);
 		memcpy(str + j, buf + 1, len);
-		alt_pair[1].data = vdata = str;
+		alt_pair[1].data = str;
 		alt_pair[1].size = vsize = j + len;
 		pair = alt_pair;
 	    }

Modified: trunk/gs/base/gdevpdfp.c
===================================================================
--- trunk/gs/base/gdevpdfp.c	2010-10-07 08:35:58 UTC (rev 11769)
+++ trunk/gs/base/gdevpdfp.c	2010-10-07 12:49:54 UTC (rev 11770)
@@ -282,6 +282,8 @@
      * psdf_put_params.
      */
     ecode = code = param_read_bool(plist, "LockDistillerParams", &locked);
+    if (ecode < 0)
+	param_signal_error(plist, param_name, ecode);
  
     if (!(locked && pdev->params.LockDistillerParams)) {
 	/* General parameters. */
@@ -290,6 +292,8 @@
 	    int efo = 1;
 
 	    ecode = param_put_int(plist, (param_name = ".EmbedFontObjects"), &efo, ecode);
+	    if (ecode < 0)
+		param_signal_error(plist, param_name, ecode);
 	    if (efo != 1)
 		param_signal_error(plist, param_name, ecode = gs_error_rangecheck);
 	}
@@ -297,6 +301,8 @@
 	    int cdv = CoreDistVersion;
 
 	    ecode = param_put_int(plist, (param_name = "CoreDistVersion"), &cdv, ecode);
+	    if (ecode < 0)
+		return gs_note_error(ecode);
 	    if (cdv != CoreDistVersion)
 		param_signal_error(plist, param_name, ecode = gs_error_rangecheck);
 	}
@@ -457,14 +463,14 @@
 	  strcmp(pdev->color_info.cm_name, "DeviceGray"))) {
 	emprintf(pdev->memory,
                  "ColorConversionStrategy is incompatible to ProcessColorModel.\n");
-	ecode = gs_note_error(gs_error_rangecheck);
+	gs_note_error(gs_error_rangecheck);
 	pdev->params.ColorConversionStrategy = save_ccs;
     }
     if (pdev->params.ColorConversionStrategy == ccs_UseDeviceIndependentColor) {
 	if (!pdev->UseCIEColor) {
 	    emprintf(pdev->memory,
                      "Set UseCIEColor for UseDeviceIndependentColor to work properly.\n");
-	    ecode = gs_note_error(gs_error_rangecheck);
+	    gs_note_error(gs_error_rangecheck);
 	    pdev->UseCIEColor = true;
 	}
     }
@@ -476,7 +482,7 @@
 	    if (!pdev->UseCIEColor) {
 		emprintf(pdev->memory,
                          "Set UseCIEColor for UseDeviceIndependentColor to work properly.\n");
-		ecode = gs_note_error(gs_error_rangecheck);
+		gs_note_error(gs_error_rangecheck);
 		pdev->UseCIEColor = true;
 	    }
 	}
@@ -500,19 +506,19 @@
 	    !strcmp(pdev->params.ColorImage.Filter, "JPXEncode")) {
 	emprintf(pdev->memory,
                  "JPXEncode requires CompatibilityLevel >= 1.5 .\n");
-	ecode = gs_note_error(gs_error_rangecheck);
+	gs_note_error(gs_error_rangecheck);
     }
     if (cl < 1.5 && pdev->params.GrayImage.Filter != NULL &&
 	    !strcmp(pdev->params.GrayImage.Filter, "JPXEncode")) {
 	emprintf(pdev->memory,
                  "JPXEncode requires CompatibilityLevel >= 1.5 .\n");
-	ecode = gs_note_error(gs_error_rangecheck);
+	gs_note_error(gs_error_rangecheck);
     }
     if (cl < 1.4  && pdev->params.MonoImage.Filter != NULL &&
 	    !strcmp(pdev->params.MonoImage.Filter, "JBIG2Encode")) {
 	emprintf(pdev->memory,
                  "JBIG2Encode requires CompatibilityLevel >= 1.4 .\n");
-	ecode = gs_note_error(gs_error_rangecheck);
+	gs_note_error(gs_error_rangecheck);
     }
     if (pdev->HaveTrueTypes && pdev->version == psdf_version_level2) {
 	pdev->version = psdf_version_level2_with_TT ;

Modified: trunk/gs/base/gdevpdfu.c
===================================================================
--- trunk/gs/base/gdevpdfu.c	2010-10-07 08:35:58 UTC (rev 11769)
+++ trunk/gs/base/gdevpdfu.c	2010-10-07 12:49:54 UTC (rev 11770)
@@ -726,7 +726,7 @@
 	    sclose(s);		/* Next terminate the compression filter */
 	    gs_free_object(pdev->pdf_memory, s->cbuf, "zlib buffer");
 	    gs_free_object(pdev->pdf_memory, s, "zlib stream");
-	    pdev->strm = s = fs;
+	    pdev->strm = fs;
 	}
 	pdf_end_encrypt(pdev);
     	s = pdev->strm;
@@ -1299,6 +1299,10 @@
 	uint copy = min(left, sbuf_size);
 
 	r = fread(buf, 1, copy, file);
+	if (r < 1) {
+	    gs_note_error(gs_error_ioerror);
+	    return;
+	}
 	if (ss)
 	    s_arcfour_process_buffer(ss, buf, copy);
 	stream_write(s, buf, copy);
@@ -1321,6 +1325,10 @@
 
 	fseek(file, position + count - left, SEEK_SET);
 	r = fread(buf, 1, copy, file);
+	if (r < 1) {
+	    gs_note_error(gs_error_ioerror);
+	    return;
+	}
 	fseek(file, end_pos, SEEK_SET);
 	stream_write(s, buf, copy);
 	sflush(s);

Modified: trunk/gs/base/gdevpdtb.c
===================================================================
--- trunk/gs/base/gdevpdtb.c	2010-10-07 08:35:58 UTC (rev 11769)
+++ trunk/gs/base/gdevpdtb.c	2010-10-07 12:49:54 UTC (rev 11770)
@@ -223,7 +223,7 @@
     if (pbfont->do_subset != DO_SUBSET_YES && reserve_glyphs == -1) {
 	/* The only possibly non-subsetted fonts are Type 1/2 and Type 42. */
 	if (is_standard)
-	    complete = copied, code = 0;
+	    complete = copied;
 	else {
 	    code = gs_copy_font((gs_font *)font, &font->FontMatrix, mem, &complete, -1);
 	    if (code < 0)

Modified: trunk/gs/base/gdevpdtc.c
===================================================================
--- trunk/gs/base/gdevpdtc.c	2010-10-07 08:35:58 UTC (rev 11769)
+++ trunk/gs/base/gdevpdtc.c	2010-10-07 12:49:54 UTC (rev 11770)
@@ -488,7 +488,6 @@
 		    return_error(gs_error_unregistered); /* Must not happen */
 		if (pdsubf->FontType == ft_user_defined  || pdsubf->FontType == ft_encrypted || 
 				pdsubf->FontType == ft_encrypted2) {
-		    code += 0; /* A good place for a breakpoint. */
 		} else {
 		    pdf_font_resource_t *pdfont;
 		    bool notdef_subst = false;
@@ -702,7 +701,6 @@
 		    type1_glyphs[0] = type1_glyphs[num_type1_glyphs];
 		    num_type1_glyphs = 1;
 		    subfont = saved_subfont;
-		    font_change = 0;
 		} else {
 		    num_type1_glyphs = 0;
 		}

Modified: trunk/gs/base/gdevpdtd.c
===================================================================
--- trunk/gs/base/gdevpdtd.c	2010-10-07 08:35:58 UTC (rev 11769)
+++ trunk/gs/base/gdevpdtd.c	2010-10-07 12:49:54 UTC (rev 11770)
@@ -403,7 +403,7 @@
      */
     notdef = GS_NO_GLYPH;
     for (index = 0;
-	 (code = bfont->procs.enumerate_glyph((gs_font *)bfont, &index, 
+	 (bfont->procs.enumerate_glyph((gs_font *)bfont, &index, 
 		(is_cid ? GLYPH_SPACE_INDEX : GLYPH_SPACE_NAME), &glyph)) >= 0 &&
 	     index != 0;
 	 ) {

Modified: trunk/gs/base/gdevpdtf.c
===================================================================
--- trunk/gs/base/gdevpdtf.c	2010-10-07 08:35:58 UTC (rev 11769)
+++ trunk/gs/base/gdevpdtf.c	2010-10-07 12:49:54 UTC (rev 11770)
@@ -209,7 +209,6 @@
 	return -1;
     }
 
-    mask |= FONT_SAME_OUTLINES;
     for (i = 0; i < PDF_NUM_STANDARD_FONTS; ++psf, ++i) {
 	gs_font_base *cfont;
 	int code;
@@ -636,7 +635,7 @@
     const int sl = strlen(gx_extendeg_glyph_name_separator);
 
     psf_enumerate_glyphs_begin(&genum, (gs_font *)pfont, NULL, 0, GLYPH_SPACE_NAME);
-    for (glyph = gs_no_glyph; (code = psf_enumerate_glyphs_next(&genum, &glyph)) != 1; ) {
+    for (glyph = gs_no_glyph; (psf_enumerate_glyphs_next(&genum, &glyph)) != 1; ) {
 	code = pfont->procs.glyph_name(pfont, glyph, &str);
 	if (code < 0)
 	    return code;
@@ -895,6 +894,8 @@
 					   pdf_font_descriptor_FontType(pfd),
 					   pdf_write_contents_simple);
 
+    if (code < 0)
+	return(gs_note_error(code));
     pdfont->FontDescriptor = pfd;
     set_is_MM_instance(pdfont, pdf_font_descriptor_font(pfd, false));
     *ppfres = pdfont;

Modified: trunk/gs/base/gdevpdti.c
===================================================================
--- trunk/gs/base/gdevpdti.c	2010-10-07 08:35:58 UTC (rev 11769)
+++ trunk/gs/base/gdevpdti.c	2010-10-07 12:49:54 UTC (rev 11770)
@@ -194,7 +194,6 @@
     code = pdf_finish_write_contents_type3(pdev, pdfont);
     if (code < 0)
 	return code;
-    s = pdev->strm; /* pdf_finish_write_contents_type3 changes pdev->strm . */
     if (!pdfont->u.simple.s.type3.bitmap_font && diff_id > 0) {
 	code = pdf_write_encoding(pdev, pdfont, diff_id, 0);
 	if (code < 0)

Modified: trunk/gs/base/gdevpdtt.c
===================================================================
--- trunk/gs/base/gdevpdtt.c	2010-10-07 08:35:58 UTC (rev 11769)
+++ trunk/gs/base/gdevpdtt.c	2010-10-07 12:49:54 UTC (rev 11770)
@@ -1289,7 +1289,6 @@
 	(code = font_alloc(pdev, &pdfont, base_font->id, pfd)) < 0
 	)
 	return code;
-    code = 1;
 
     if (!pdf_is_CID_font(font)) {
 	pdfont->u.simple.BaseEncoding = BaseEncoding;
@@ -1317,6 +1316,8 @@
 	    widths.Width.w = 0;
 	    code = pdf_glyph_widths(pdfont, font->WMode, notdef_glyph,
 		 font, &widths, cdevproc_result);
+	    if (code < 0)
+		return code;
 	    w[0] = widths.Width.w;
 	    pdfont->used[0] |= 0x80;
 	}
@@ -2154,10 +2155,14 @@
 
 	/* Sort out any pending glyphs */
 	code = pdf_set_PaintType0_params(pdev, pis, size, scaled_width, &ppts->values);
+	if (code < 0)
+	    return code;
 
 	pis->line_params.half_width = scaled_width / 2;
 	code = pdf_set_text_process_state(pdev, (const gs_text_enum_t *)penum,
 				      ppts);
+	if (code < 0)
+	    return code;
 
 	pis->line_params.half_width = saved_width;
     } else {
@@ -2189,6 +2194,9 @@
 	int code;
 
 	code = pdf_open_contents(pdev, PDF_IN_STRING);
+	if (code < 0)
+	    return code;
+
 	code = pdf_prepare_stroke(pdev, pis);
 	if (code >= 0) 
 	    code = gdev_vector_prepare_stroke((gx_device_vector *)pdev,
@@ -2453,7 +2461,7 @@
 	p = (byte *)gs_alloc_string(pdev->pdf_memory, gnstr->size, "pdf_text_set_cache");
 	if (p == NULL)
 	    return_error(gs_error_VMerror);
-	sprintf(buf, "g%04x", glyph & 0xFFFF);
+	sprintf(buf, "g%04x", (unsigned int)(glyph & 0xFFFF));
 	memcpy(p, buf, 5);
 	gnstr->data = p;
     } else {



More information about the gs-commits mailing list