From 022d28905991bda39bdd11d43cda8416d04d148e Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Wed, 10 Nov 2010 16:09:35 -0700 Subject: [PATCH] Removing compiler warnings. I think most of the effected code is not even used in Racket --- src/plot/fit/fit.c | 30 +++++++------- src/plot/fit/fit.h | 6 +++ src/plot/fit/matrix.c | 5 +-- src/plot/plplot/plbuf.c | 82 +++++++++++++++++++++------------------ src/plot/plplot/plcore.c | 4 +- src/plot/plplot/plcore.h | 4 +- src/plot/plplot/plctrl.c | 16 +++++--- src/plot/plplot/pldebug.h | 8 +++- src/plot/plplot/plgridd.c | 2 +- src/plot/plplot/plot3d.c | 4 +- src/plot/plplot/plsym.c | 7 +++- 11 files changed, 97 insertions(+), 71 deletions(-) diff --git a/src/plot/fit/fit.c b/src/plot/fit/fit.c index 2967bec6c9..b6f819190d 100644 --- a/src/plot/fit/fit.c +++ b/src/plot/fit/fit.c @@ -66,6 +66,8 @@ #include "matrix.h" #include "fit.h" #include +#include +#include /* #define STANDARD stderr */ @@ -100,24 +102,24 @@ typedef enum marq_res marq_res_t; /* HBB 971023: new, allow for dynamic adjustment of these: */ -static int max_data; -static int max_params; +static UNUSED int max_data; +static UNUSED int max_params; static double epsilon = 1e-5; /* convergence limit */ static int maxiter = 0; /* HBB 970304: maxiter patch */ -static char *FIXED = "# FIXED"; -static char *GNUFITLOG = "FIT_LOG"; -static char *FITLIMIT = "FIT_LIMIT"; -static char *FITSTARTLAMBDA = "FIT_START_LAMBDA"; -static char *FITLAMBDAFACTOR = "FIT_LAMBDA_FACTOR"; -static char *FITMAXITER = "FIT_MAXITER"; /* HBB 970304: maxiter patch */ -static char *FITSCRIPT = "FIT_SCRIPT"; -static char *DEFAULT_CMD = "replot"; /* if no fitscript spec. */ +static UNUSED char *FIXED = "# FIXED"; +static UNUSED char *GNUFITLOG = "FIT_LOG"; +static UNUSED char *FITLIMIT = "FIT_LIMIT"; +static UNUSED char *FITSTARTLAMBDA = "FIT_START_LAMBDA"; +static UNUSED char *FITLAMBDAFACTOR = "FIT_LAMBDA_FACTOR"; +static UNUSED char *FITMAXITER = "FIT_MAXITER"; /* HBB 970304: maxiter patch */ +static UNUSED char *FITSCRIPT = "FIT_SCRIPT"; +static UNUSED char *DEFAULT_CMD = "replot"; /* if no fitscript spec. */ static int num_data, num_params; -static int columns; +static UNUSED int columns; static double *fit_x; static double *fit_y; static double *fit_z ; @@ -166,7 +168,7 @@ double * get_asym_error_percent() *****************************************************************/ /*static void printmatrix __PROTO((double **C, int m, int n)); */ -static void print_matrix_and_vectors (double **C, double *d, double *r, int m, int n); +static UNUSED void print_matrix_and_vectors (double **C, double *d, double *r, int m, int n); static marq_res_t marquardt (double a[], double **alpha, double *chisq, double *lambda); static TBOOLEAN analyze (double a[], double **alpha, double beta[], @@ -182,7 +184,7 @@ static TBOOLEAN regress (double a[]); /***************************************************************** New utility routine: print a matrix (for debugging the alg.) *****************************************************************/ -static void printmatrix(C, m, n) +static UNUSED void printmatrix(C, m, n) double **C; int m, n; { @@ -199,7 +201,7 @@ int m, n; /************************************************************************** Yet another debugging aid: print matrix, with diff. and residue vector **************************************************************************/ -static void print_matrix_and_vectors(C, d, r, m, n) +static UNUSED void print_matrix_and_vectors(C, d, r, m, n) double **C; double *d, *r; int m, n; diff --git a/src/plot/fit/fit.h b/src/plot/fit/fit.h index 871bfff387..83fa7a9f33 100644 --- a/src/plot/fit/fit.h +++ b/src/plot/fit/fit.h @@ -32,6 +32,12 @@ #include "../dllexport.h" +#ifdef __GNUC__ +# define UNUSED __attribute__((unused)) +#else +# define UNUSED +#endif + MZ_DLLEXPORT double * do_fit(void * function, int n_values, diff --git a/src/plot/fit/matrix.c b/src/plot/fit/matrix.c index 9d4c63b26c..76015775db 100644 --- a/src/plot/fit/matrix.c +++ b/src/plot/fit/matrix.c @@ -1,7 +1,3 @@ -#ifndef lint -static char *RCSid = "$Id: matrix.c,v 1.4 2005/03/15 23:21:26 eli Exp $"; -#endif - /* NOTICE: Change of Copyright Status * * The author of this module, Carsten Grammes, has expressed in @@ -41,6 +37,7 @@ static char *RCSid = "$Id: matrix.c,v 1.4 2005/03/15 23:21:26 eli Exp $"; #include "fit.h" #include "matrix.h" #include +#include // create a simple gc malloc... typedef struct Node { diff --git a/src/plot/plplot/plbuf.c b/src/plot/plplot/plbuf.c index 8badfd21fa..ffe50adebd 100644 --- a/src/plot/plplot/plbuf.c +++ b/src/plot/plplot/plbuf.c @@ -343,8 +343,8 @@ rdbuf_line(PLStream *pls) dbug_enter("rdbuf_line"); - fread(xpl, sizeof(short), npts, pls->plbufFile); - fread(ypl, sizeof(short), npts, pls->plbufFile); + if (npts != fread(xpl, sizeof(short), npts, pls->plbufFile)) return; + if (npts != fread(ypl, sizeof(short), npts, pls->plbufFile)) return; plP_line(xpl, ypl); } @@ -363,9 +363,9 @@ rdbuf_polyline(PLStream *pls) dbug_enter("rdbuf_polyline"); - fread(&npts, sizeof(PLINT), 1, pls->plbufFile); - fread(xpl, sizeof(short), npts, pls->plbufFile); - fread(ypl, sizeof(short), npts, pls->plbufFile); + if (1 != fread(&npts, sizeof(PLINT), 1, pls->plbufFile)) return; + if (npts != fread(xpl, sizeof(short), npts, pls->plbufFile)) return; + if (npts != fread(ypl, sizeof(short), npts, pls->plbufFile)) return; plP_polyline(xpl, ypl, npts); } @@ -409,14 +409,14 @@ rdbuf_state(PLStream *pls) dbug_enter("rdbuf_state"); - fread(&op, sizeof(U_CHAR), 1, pls->plbufFile); + if (1 != fread(&op, sizeof(U_CHAR), 1, pls->plbufFile)) return; switch (op) { case PLSTATE_WIDTH:{ U_CHAR width; - fread(&width, sizeof(U_CHAR), 1, pls->plbufFile); + if (1 != fread(&width, sizeof(U_CHAR), 1, pls->plbufFile)) return; pls->width = width; plP_state(PLSTATE_WIDTH); @@ -426,11 +426,11 @@ rdbuf_state(PLStream *pls) case PLSTATE_COLOR0:{ U_CHAR icol0, r, g, b; - fread(&icol0, sizeof(U_CHAR), 1, pls->plbufFile); + if (1 != fread(&icol0, sizeof(U_CHAR), 1, pls->plbufFile)) return; if (icol0 == PL_RGB_COLOR) { - fread(&r, sizeof(U_CHAR), 1, pls->plbufFile); - fread(&g, sizeof(U_CHAR), 1, pls->plbufFile); - fread(&b, sizeof(U_CHAR), 1, pls->plbufFile); + if (1 != fread(&r, sizeof(U_CHAR), 1, pls->plbufFile)) return; + if (1 != fread(&g, sizeof(U_CHAR), 1, pls->plbufFile)) return; + if (1 != fread(&b, sizeof(U_CHAR), 1, pls->plbufFile)) return; } else { if ((int) icol0 > 15) { @@ -453,7 +453,7 @@ rdbuf_state(PLStream *pls) case PLSTATE_COLOR1: { U_CHAR icol1; - fread(&icol1, sizeof(U_CHAR), 1, pls->plbufFile); + if (1 != fread(&icol1, sizeof(U_CHAR), 1, pls->plbufFile)) return; pls->icol1 = icol1; pls->curcolor.r = pls->cmap1[icol1].r; @@ -467,7 +467,7 @@ rdbuf_state(PLStream *pls) case PLSTATE_FILL: { signed char patt; - fread(&patt, sizeof(signed char), 1, pls->plbufFile); + if (1 != fread(&patt, sizeof(signed char), 1, pls->plbufFile)) return; pls->patt = patt; plP_state(PLSTATE_FILL); @@ -503,7 +503,7 @@ rdbuf_esc(PLStream *pls) dbug_enter("rdbuf_esc"); - fread(&op, sizeof(U_CHAR), 1, pls->plbufFile); + if (1 != fread(&op, sizeof(U_CHAR), 1, pls->plbufFile)) return; switch (op) { case PLESC_FILL: @@ -532,9 +532,9 @@ rdbuf_fill(PLStream *pls) dbug_enter("rdbuf_fill"); - fread(&npts, sizeof(PLINT), 1, pls->plbufFile); - fread(xpl, sizeof(short), npts, pls->plbufFile); - fread(ypl, sizeof(short), npts, pls->plbufFile); + if (1 != fread(&npts, sizeof(PLINT), 1, pls->plbufFile)) return; + if (npts != fread(xpl, sizeof(short), npts, pls->plbufFile)) return; + if (npts != fread(ypl, sizeof(short), npts, pls->plbufFile)) return; plP_fill(xpl, ypl, npts); } @@ -555,31 +555,37 @@ rdbuf_image(PLStream *pls) dbug_enter("rdbuf_image"); - fread(&nptsX, sizeof(PLINT), 1, pls->plbufFile); - fread(&nptsY, sizeof(PLINT), 1, pls->plbufFile); + if (1 != fread(&nptsX, sizeof(PLINT), 1, pls->plbufFile)) return; + if (1 != fread(&nptsY, sizeof(PLINT), 1, pls->plbufFile)) return; npts = nptsX*nptsY; - fread(&xmin, sizeof(PLFLT), 1, pls->plbufFile); - fread(&ymin, sizeof(PLFLT), 1, pls->plbufFile); - fread(&dx, sizeof(PLFLT), 1, pls->plbufFile); - fread(&dy, sizeof(PLFLT), 1, pls->plbufFile); + if (1 != fread(&xmin, sizeof(PLFLT), 1, pls->plbufFile)) return; + if (1 != fread(&ymin, sizeof(PLFLT), 1, pls->plbufFile)) return; + if (1 != fread(&dx, sizeof(PLFLT), 1, pls->plbufFile)) return; + if (1 != fread(&dy, sizeof(PLFLT), 1, pls->plbufFile)) return; - fread(&dev_zmin, sizeof(short), 1, pls->plbufFile); - fread(&dev_zmax, sizeof(short), 1, pls->plbufFile); + if (1 != fread(&dev_zmin, sizeof(short), 1, pls->plbufFile)) return; + if (1 != fread(&dev_zmax, sizeof(short), 1, pls->plbufFile)) return; dev_ix=(short *)malloc(npts*sizeof(short)); + if (!dev_ix) return; dev_iy=(short *)malloc(npts*sizeof(short)); + if (!dev_iy) goto end_y; dev_z=(unsigned short *)malloc((nptsX-1)*(nptsY-1)*sizeof(unsigned short)); + if (!dev_z) goto end_z; - fread(dev_ix, sizeof(short), npts, pls->plbufFile); - fread(dev_iy, sizeof(short), npts, pls->plbufFile); - fread(dev_z, sizeof(unsigned short), (nptsX-1)*(nptsY-1), pls->plbufFile); + if (npts != fread(dev_ix, sizeof(short), npts, pls->plbufFile)) goto end; + if (npts != fread(dev_iy, sizeof(short), npts, pls->plbufFile)) goto end; + if ((nptsX-1)*(nptsY-1) != fread(dev_z, sizeof(unsigned short), (nptsX-1)*(nptsY-1), pls->plbufFile)) goto end; plP_image(dev_ix, dev_iy, dev_z, nptsX, nptsY, xmin, ymin, dx, dy, dev_zmin, dev_zmax); - free(dev_ix); - free(dev_iy); +end: free(dev_z); +end_z: + free(dev_iy); +end_y: + free(dev_ix); } /*--------------------------------------------------------------------------*\ @@ -593,15 +599,15 @@ rdbuf_swin(PLStream *pls) { PLWindow plwin; - fread(&plwin.dxmi, sizeof(PLFLT), 1, pls->plbufFile); - fread(&plwin.dxma, sizeof(PLFLT), 1, pls->plbufFile); - fread(&plwin.dymi, sizeof(PLFLT), 1, pls->plbufFile); - fread(&plwin.dyma, sizeof(PLFLT), 1, pls->plbufFile); + if (1 != fread(&plwin.dxmi, sizeof(PLFLT), 1, pls->plbufFile)) return; + if (1 != fread(&plwin.dxma, sizeof(PLFLT), 1, pls->plbufFile)) return; + if (1 != fread(&plwin.dymi, sizeof(PLFLT), 1, pls->plbufFile)) return; + if (1 != fread(&plwin.dyma, sizeof(PLFLT), 1, pls->plbufFile)) return; - fread(&plwin.wxmi, sizeof(PLFLT), 1, pls->plbufFile); - fread(&plwin.wxma, sizeof(PLFLT), 1, pls->plbufFile); - fread(&plwin.wymi, sizeof(PLFLT), 1, pls->plbufFile); - fread(&plwin.wyma, sizeof(PLFLT), 1, pls->plbufFile); + if (1 != fread(&plwin.wxmi, sizeof(PLFLT), 1, pls->plbufFile)) return; + if (1 != fread(&plwin.wxma, sizeof(PLFLT), 1, pls->plbufFile)) return; + if (1 != fread(&plwin.wymi, sizeof(PLFLT), 1, pls->plbufFile)) return; + if (1 != fread(&plwin.wyma, sizeof(PLFLT), 1, pls->plbufFile)) return; plP_swin(&plwin); } diff --git a/src/plot/plplot/plcore.c b/src/plot/plplot/plcore.c index 206b66d29a..b42e9d7bed 100644 --- a/src/plot/plplot/plcore.c +++ b/src/plot/plplot/plcore.c @@ -1859,7 +1859,9 @@ plSelectDev() fprintf(stdout, "\nEnter device number or keyword (stream %d): ", (int) ipls); - fgets(response, sizeof(response), stdin); + if (! (fgets(response, sizeof(response), stdin))) { + return; + } /* First check to see if device keyword was entered. */ /* Final "\n" in response messes things up, so ignore it. */ diff --git a/src/plot/plplot/plcore.h b/src/plot/plplot/plcore.h index 1a3927ffa6..00af09accf 100644 --- a/src/plot/plplot/plcore.h +++ b/src/plot/plplot/plcore.h @@ -18,8 +18,6 @@ typedef lt_ptr (*PLDispatchInit)( PLDispatchTable *pdt ); #else typedef void (*PLDispatchInit)( PLDispatchTable *pdt ); #endif - - /* Static function prototypes */ @@ -250,6 +248,6 @@ static PLLoadableDevice *loadable_device_list; static PLLoadableDriver *loadable_driver_list; #endif -static int nloadabledrivers = 0; +static UNUSED int nloadabledrivers = 0; #endif /* __PLCORE_H__ */ diff --git a/src/plot/plplot/plctrl.c b/src/plot/plplot/plctrl.c index b83ef0ed77..b5ed250667 100644 --- a/src/plot/plplot/plctrl.c +++ b/src/plot/plplot/plctrl.c @@ -1445,7 +1445,9 @@ plOpenFile(PLStream *pls) if (pls->FileName == NULL) { do { fprintf(stdout, "Enter graphics output file name: "); - fgets(line, sizeof(line), stdin); + if (!fgets(line, sizeof(line), stdin)) { + return; + } len = strlen(line); if (len) len--; @@ -1671,8 +1673,10 @@ plGetInt(char *s) char line[256]; while (i++ < 10) { - fprintf(stdout, s); - fgets(line, sizeof(line), stdin); + fprintf(stdout, "%s", s); + if (! (fgets(line, sizeof(line), stdin))) { + return 0; + } #ifdef MSDOS m = atoi(line); return (m); @@ -1701,8 +1705,10 @@ plGetFlt(char *s) char line[256]; while (i++ < 10) { - fprintf(stdout, s); - fgets(line, sizeof(line), stdin); + fprintf(stdout, "%s", s); + if (! (fgets(line, sizeof(line), stdin))) { + return (0.); + } #ifdef MSDOS m = atof(line); return (m); diff --git a/src/plot/plplot/pldebug.h b/src/plot/plplot/pldebug.h index fb358efb8d..f95b29d727 100644 --- a/src/plot/plplot/pldebug.h +++ b/src/plot/plplot/pldebug.h @@ -57,8 +57,14 @@ if (plsc->debug) \ * The label is typically the calling function name. \*--------------------------------------------------------------------------*/ +#ifdef __GNUC__ +# define UNUSED __attribute__((unused)) +#else +# define UNUSED +#endif + #ifdef NEED_PLDEBUG -static void +UNUSED static void pldebug( const char *label, ... ) { #ifdef DEBUG diff --git a/src/plot/plplot/plgridd.c b/src/plot/plplot/plgridd.c index 030a4bcc0b..70ad348bd4 100644 --- a/src/plot/plplot/plgridd.c +++ b/src/plot/plplot/plgridd.c @@ -11,7 +11,7 @@ #include #endif -#if !defined(HAVE_ISNAN) +#if !defined(HAVE_ISNAN) && !defined(isnan) #define isnan(x) ((x) != (x)) #endif diff --git a/src/plot/plplot/plot3d.c b/src/plot/plplot/plot3d.c index 2c64cf218b..b07d52d470 100644 --- a/src/plot/plplot/plot3d.c +++ b/src/plot/plplot/plot3d.c @@ -186,7 +186,7 @@ shade_triangle(PLFLT x0, PLFLT y0, PLFLT z0, int i; /* arrays for interface to core functions */ short u[6], v[6]; - PLFLT x[6], y[6], z[6], c; + PLFLT x[6], y[6], z[6]; int n; PLFLT xmin, xmax, ymin, ymax, zmin, zmax, zscale; PLFLT *V[3]; @@ -768,7 +768,7 @@ c_plot3dc(PLFLT *x, PLFLT *y, PLFLT **z, ny = _ny; } - if (opt & BASE_CONT || opt & TOP_CONT || opt && MAG_COLOR ) { + if ((opt & BASE_CONT) || (opt & TOP_CONT) || (opt && MAG_COLOR) ) { /* * Don't use the data z value to scale the color, use the z axis * values set by plw3d() diff --git a/src/plot/plplot/plsym.c b/src/plot/plplot/plsym.c index 4cc195e785..2d0dba4bb0 100644 --- a/src/plot/plplot/plsym.c +++ b/src/plot/plplot/plsym.c @@ -1054,8 +1054,11 @@ plfntld(PLINT fnt) #if PLPLOT_USE_TCL_CHANNELS pdf_rdx(fntbffr, sizeof(signed char)*(2 * bffrleng), pdfs); #else - fread((void *) fntbffr, (size_t) sizeof(signed char), - (size_t) (2 * bffrleng), pdfs->file); + if ( (2 * bffrleng) != + fread((void *) fntbffr, (size_t) sizeof(signed char), + (size_t) (2 * bffrleng), pdfs->file) ) { + plexit("plfntld: Failed to read into font buffer."); + } #endif /* Done */