Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 77980 - Bad source code
Summary: Bad source code
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: transfig
Version: 8.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Ngo Than
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-11-16 13:07 UTC by d.binderman
Modified: 2008-05-01 15:38 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2002-11-16 13:10:39 UTC


Attachments (Terms of Use)

Description d.binderman 2002-11-16 13:07:50 UTC
Description of Problem:
Hello there,

I just tried to compile package transfig-3.2.3d-7 from Redhat 8.0.

Here are some of the compiler messages.

colors.c:34: warning: `n' might be used uninitialized in this function
trans_spline.c:178: warning: `p0' might be used uninitialized in this function
genlatex.c:415: warning: `put_line' might be used uninitialized in this function
genmap.c:324: warning: `last_x' might be used uninitialized in this function
genmap.c:324: warning: `last_y' might be used uninitialized in this function
genlatex.c:942: warning: `opt' might be used uninitialized in this function
genlatex.c:943: warning: `px' might be used uninitialized in this function
genlatex.c:943: warning: `py' might be used uninitialized in this function
bound.c:616: warning: `q' might be used uninitialized in this function
gentk.c:112: warning: `wid' might be used uninitialized in this function
gentk.c:112: warning: `ht' might be used uninitialized in this function
genge.c:408: warning: conversion lacks type at end of format
genge.c:387: warning: `style' might be used uninitialized in this function
psencode.c:247: warning: `previous' might be used uninitialized in this function
readpics.c:36: warning: `fstream' might be used uninitialized in this function
readeps.c:82: warning: int format, pointer arg (arg 3)
readeps.c:82: warning: int format, pointer arg (arg 4)
genmp.c:452: warning: operation on `j' may be undefined
genmp.c:456: warning: operation on `j' may be undefined
genps.c:1277: warning: `b' might be used uninitialized in this function
sys.c:32: warning: suggest parentheses around comparison in operand of &
mkfile.c:41: warning: `needeps' might be used uninitialized in this function



Version-Release number of selected component (if applicable):


How Reproducible:


Steps to Reproduce:
1. 
2. 
3. 

Actual Results:


Expected Results:


Additional Information:

Comment 1 d.binderman 2002-11-16 13:10:32 UTC
Here is a bunch of patches which fix the messages.

*** ./fig2dev/bound.c.old	2002-11-05 11:43:36.000000000 +0000
--- ./fig2dev/bound.c	2002-11-05 11:43:49.000000000 +0000
***************
*** 613,619 ****
  {
      int		    fxmin, fymin, fxmax, fymax;
      int		    bxmin, bymin, bxmax, bymax;
!     F_point	   *p, *q;
      F_arc	   *a;
      int		    p1x, p1y, p2x, p2y;
      int		    dum;
--- 613,619 ----
  {
      int		    fxmin, fymin, fxmax, fymax;
      int		    bxmin, bymin, bxmax, bymax;
!     F_point	   *p, *q = 0;
      F_arc	   *a;
      int		    p1x, p1y, p2x, p2y;
      int		    dum;
*** ./fig2dev/colors.c.old	2002-11-05 11:38:57.000000000 +0000
--- ./fig2dev/colors.c	2002-11-05 11:39:17.000000000 +0000
***************
*** 31,37 ****
    char *name;
    RGB  *rgb;
  {
!     int		i, n;
      int		r, g, b;
      struct color_db *col;
  
--- 31,37 ----
    char *name;
    RGB  *rgb;
  {
!     int		i, n = 0;
      int		r, g, b;
      struct color_db *col;
  
*** ./fig2dev/dev/genge.c.old	2002-11-05 11:44:53.000000000 +0000
--- ./fig2dev/dev/genge.c	2002-11-05 11:48:01.000000000 +0000
***************
*** 384,390 ****
  genge_text(t)
  F_text	*t;
  {
! 	int x, y, style;
  
  	/* print any comments prefixed with "#" */
  	print_comments("# ",t->comments, "");
--- 384,390 ----
  genge_text(t)
  F_text	*t;
  {
! 	int x, y, style = 1;
  
  	/* print any comments prefixed with "#" */
  	print_comments("# ",t->comments, "");
***************
*** 405,411 ****
  		    break;
  	}
  
! 	fprintf(tfp,"f%02d %z%02d y%01d ",t->font, min(MAX_FONT_SIZE,(int)t->size), style);
  
  	x = t->base_x;
  	y = t->base_y;
--- 405,411 ----
  		    break;
  	}
  
! 	fprintf( tfp, "f%02d z%02d y%01d ",t->font, min(MAX_FONT_SIZE,(int)t->size), style);
  
  	x = t->base_x;
  	y = t->base_y;
*** ./fig2dev/dev/genlatex.c.old	2002-11-05 11:41:03.000000000 +0000
--- ./fig2dev/dev/genlatex.c	2002-11-05 11:43:08.000000000 +0000
***************
*** 412,418 ****
          int     radius2= 2*radius;
  	double  swidth = (double)(urx-llx-radius2);
  	double  sheight= (double)(ury-lly-radius2);
! 	int (*put_line)();
  
  	switch (style) {
  	    case SOLID_LINE:
--- 412,418 ----
          int     radius2= 2*radius;
  	double  swidth = (double)(urx-llx-radius2);
  	double  sheight= (double)(ury-lly-radius2);
! 	int (*put_line)() = 0;
  
  	switch (style) {
  	    case SOLID_LINE:
***************
*** 939,946 ****
   *  Draw quarter oval from p1 to p2 in quadrant q
   */
  {
! 	char	*opt;
! 	int	px, py, dx, dy;
  
  	dx = 2*ABS(p1.x - p2.x);
  	dy = 2*ABS(p1.y - p2.y);
--- 939,946 ----
   *  Draw quarter oval from p1 to p2 in quadrant q
   */
  {
! 	char	*opt = 0;
! 	int	px = 0, py = 0, dx, dy;
  
  	dx = 2*ABS(p1.x - p2.x);
  	dy = 2*ABS(p1.y - p2.y);
*** ./fig2dev/dev/genmap.c.old	2002-11-05 11:42:16.000000000 +0000
--- ./fig2dev/dev/genmap.c	2000-07-11 22:50:43.000000000 +0100
***************
*** 321,327 ****
  {
    char *ref;
 int xmin, xmax, ymin, ymax;
!   int x, y, last_x, last_y;
    F_point *p;
  
    ref = is_link(l->comments);
--- 321,327 ----
  {
    char *ref;
    int xmin, xmax, ymin, ymax;
!   int x, y, last_x = 0, last_y = 0;
    F_point *p;
  
    ref = is_link(l->comments);
*** ./fig2dev/dev/genmp.c.old	2002-11-05 11:54:06.000000000 +0000
--- ./fig2dev/dev/genmp.c	2002-11-05 11:55:55.000000000 +0000
***************
*** 449,459 ****
  	         y_off(fig2bp(p->y)));
  	      p = p->next;
  	      for ( ; p->next != NULL; ) {  /* 3 or more points */
! 	         fprintf(tfp,"    p%d..controls c%d and c%d..\n",i++,j++,j++);
  	         p = p->next;
  	      }
  	      if (s->type == 1)     /* closed spline */
! 	         fprintf(tfp,"    p%d..controls c%d and c%d..cycle;\n",i++,j++,j++);
  	      else
  	         fprintf(tfp,"    p%d..(%.2lf,%.2lf);\n",i,
  	            fig2bp(p->x),y_off(fig2bp(p->y)));
--- 449,463 ----
  	         y_off(fig2bp(p->y)));
  	      p = p->next;
  	      for ( ; p->next != NULL; ) {  /* 3 or more points */
! 	         fprintf( tfp, "    p%d..controls c%d and c%d..\n", 
! 					i++, j, j + 1);
!                  j += 2;
  	         p = p->next;
  	      }
  	      if (s->type == 1)     /* closed spline */
! 	         fprintf( tfp, "    p%d..controls c%d and c%d..cycle;\n", 
! 				i++, j, j + 1);
!                  j += 2;
  	      else
  	         fprintf(tfp,"    p%d..(%.2lf,%.2lf);\n",i,
  	            fig2bp(p->x),y_off(fig2bp(p->y)));
*** ./fig2dev/dev/genps.c.old	2002-11-05 11:56:15.000000000 +0000
--- ./fig2dev/dev/genps.c	2002-11-05 11:56:30.000000000 +0000
***************
*** 1274,1280 ****
  F_spline	*s;
  {
  	F_point		*p, *q;
! 	F_control	*a, *b, *ar;
  	int		 xmin, ymin;
  
  	fprintf(tfp, "%% Interp Spline\n");
--- 1274,1280 ----
  F_spline	*s;
  {
  	F_point		*p, *q;
! 	F_control	*a, *b = 0, *ar;
  	int		 xmin, ymin;
  
  	fprintf(tfp, "%% Interp Spline\n");
*** ./fig2dev/dev/gentk.c.old	2002-11-05 11:44:11.000000000 +0000
--- ./fig2dev/dev/gentk.c	2002-11-05 11:44:30.000000000 +0000
***************
*** 109,115 ****
  gentk_start(F_compound *objects)
  {
  	char		stfp[128];
! 	float		wid, ht, swap;
  	struct paperdef	*pd;
  
  	/* adjust ppi for the difference of screen dots to points */
--- 109,115 ----
  gentk_start(F_compound *objects)
  {
  	char		stfp[128];
! 	float		wid = 0.0, ht = 0.0, swap;
  	struct paperdef	*pd;
  
  	/* adjust ppi for the difference of screen dots to points */
*** ./fig2dev/dev/psencode.c.old	2002-11-05 11:48:22.000000000 +0000
--- ./fig2dev/dev/psencode.c	2002-11-05 11:48:35.000000000 +0000
***************
*** 244,250 ****
    long    Nbyte;
    char    s[80];
    byte    *ptr, *end;
!   int     i, nc, k, current, previous, run, y;
  
    static char h[] = "0123456789abcdef";
  
--- 244,250 ----
    long    Nbyte;
    char    s[80];
    byte    *ptr, *end;
!   int     i, nc, k, current, previous = 0, run, y;
  
    static char h[] = "0123456789abcdef";
  
*** ./fig2dev/dev/readeps.c.old	2002-11-05 11:52:32.000000000 +0000
--- ./fig2dev/dev/readeps.c	2002-11-05 11:53:33.000000000 +0000
***************
*** 79,85 ****
  		if (!strncmp(buf, "/MediaBox", 8)) {	/* look for the MediaBox spec */
  		    char *c;
  		    c = strchr(buf,'[')+1;
! 		    if (c && sscanf(c,"%d %d %d %d",&llx,&lly,&urx,&ury) < 4) {
  			llx = lly = 0;
  			urx = paperdef[0].width*72;
  			ury = paperdef[0].height*72;
--- 79,85 ----
  		if (!strncmp(buf, "/MediaBox", 8)) {	/* look for the MediaBox spec */
  		    char *c;
  		    c = strchr(buf,'[')+1;
! 		    if (c && sscanf(c,"%d %d %d %d", llx, lly, &urx,&ury) < 4) {
  			llx = lly = 0;
  			urx = paperdef[0].width*72;
  			ury = paperdef[0].height*72;
*** ./fig2dev/dev/readpics.c.old	2002-11-05 11:48:56.000000000 +0000
--- ./fig2dev/dev/readpics.c	2002-11-05 11:49:10.000000000 +0000
***************
*** 33,39 ****
      char	*retname;
  {
      char	 unc[PATH_MAX+20];	/* temp buffer for gunzip command */
!     FILE	*fstream;		/* handle on file  */
      struct stat	 status;
      char	*gzoption;
  
--- 33,39 ----
      char	*retname;
  {
      char	 unc[PATH_MAX+20];	/* temp buffer for gunzip command */
!     FILE	*fstream = 0;		/* handle on file  */
      struct stat	 status;
      char	*gzoption;
  
*** ./fig2dev/trans_spline.c.old	2002-11-05 11:40:13.000000000 +0000
--- ./fig2dev/trans_spline.c	2002-11-05 11:40:42.000000000 +0000
***************
*** 175,181 ****
  {
    int       k;
    float     step;
!   F_point   *p0, *p1, *p2, *p3;
    F_control *s0, *s1, *s2, *s3;
  
    if (!init_point_array(300, 200))
--- 175,181 ----
  {
    int       k;
    float     step;
!   F_point   *p0 = 0, *p1, *p2, *p3;
    F_control *s0, *s1, *s2, *s3;
  
    if (!init_point_array(300, 200))
*** ./transfig/mkfile.c.old	2002-11-05 11:58:52.000000000 +0000
--- ./transfig/mkfile.c	2002-11-05 11:59:15.000000000 +0000
***************
*** 38,44 ****
    argument *a;
    char *i;
    enum language to;
!   int needps, needeps, needpic, needfig;
    
    fprintf(mk, "#\n# TransFig makefile\n#\n");
  
--- 38,44 ----
    argument *a;
    char *i;
    enum language to;
!   int needps, needeps = 0, needpic, needfig;
    
    fprintf(mk, "#\n# TransFig makefile\n#\n");
  
*** ./transfig/sys.c.old	2002-11-05 11:56:50.000000000 +0000
--- ./transfig/sys.c	2002-11-05 11:58:31.000000000 +0000
***************
*** 28,41 ****
  
    ls = popen("/bin/ls *.fig", "r");
    i = 0;
!   c = fgetc(ls);
!   while (c != EOF & i < MAXSYS-1)
    {
! 	sysbuf[i] = (char) c;
! 	i += 1;
! 	c = fgetc(ls);
    }
!   sysbuf[i] = '\0';
    return sysbuf;
  }
  
--- 28,39 ----
  
    ls = popen("/bin/ls *.fig", "r");
    i = 0;
!   while ((i < (MAXSYS - 1))
! 	&& ((c = fgetc( ls)) != EOF)
    {
! 	sysbuf[ i++] = (char) c;
    }
!   sysbuf[ i] = '\0';
    return sysbuf;
  }
  


Comment 2 Ngo Than 2002-11-18 14:42:19 UTC
great, the 3.2.3d-8 will include this fix. Have you sent this fix to the xfig autor?



Note You need to log in before you can comment on or make changes to this bug.