Removing compiler warnings. I think most of the effected code is not even used in Racket

This commit is contained in:
Jay McCarthy 2010-11-10 16:09:35 -07:00
parent aabd1652c1
commit 022d289059
11 changed files with 97 additions and 71 deletions

View File

@ -66,6 +66,8 @@
#include "matrix.h" #include "matrix.h"
#include "fit.h" #include "fit.h"
#include <math.h> #include <math.h>
#include <stdlib.h>
#include <string.h>
/* #define STANDARD stderr */ /* #define STANDARD stderr */
@ -100,24 +102,24 @@ typedef enum marq_res marq_res_t;
/* HBB 971023: new, allow for dynamic adjustment of these: */ /* HBB 971023: new, allow for dynamic adjustment of these: */
static int max_data; static UNUSED int max_data;
static int max_params; static UNUSED int max_params;
static double epsilon = 1e-5; /* convergence limit */ static double epsilon = 1e-5; /* convergence limit */
static int maxiter = 0; /* HBB 970304: maxiter patch */ static int maxiter = 0; /* HBB 970304: maxiter patch */
static char *FIXED = "# FIXED"; static UNUSED char *FIXED = "# FIXED";
static char *GNUFITLOG = "FIT_LOG"; static UNUSED char *GNUFITLOG = "FIT_LOG";
static char *FITLIMIT = "FIT_LIMIT"; static UNUSED char *FITLIMIT = "FIT_LIMIT";
static char *FITSTARTLAMBDA = "FIT_START_LAMBDA"; static UNUSED char *FITSTARTLAMBDA = "FIT_START_LAMBDA";
static char *FITLAMBDAFACTOR = "FIT_LAMBDA_FACTOR"; static UNUSED char *FITLAMBDAFACTOR = "FIT_LAMBDA_FACTOR";
static char *FITMAXITER = "FIT_MAXITER"; /* HBB 970304: maxiter patch */ static UNUSED char *FITMAXITER = "FIT_MAXITER"; /* HBB 970304: maxiter patch */
static char *FITSCRIPT = "FIT_SCRIPT"; static UNUSED char *FITSCRIPT = "FIT_SCRIPT";
static char *DEFAULT_CMD = "replot"; /* if no fitscript spec. */ static UNUSED char *DEFAULT_CMD = "replot"; /* if no fitscript spec. */
static int num_data, num_params; static int num_data, num_params;
static int columns; static UNUSED int columns;
static double *fit_x; static double *fit_x;
static double *fit_y; static double *fit_y;
static double *fit_z ; 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 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, static marq_res_t marquardt (double a[], double **alpha, double *chisq,
double *lambda); double *lambda);
static TBOOLEAN analyze (double a[], double **alpha, double beta[], 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.) 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; double **C;
int m, n; int m, n;
{ {
@ -199,7 +201,7 @@ int m, n;
/************************************************************************** /**************************************************************************
Yet another debugging aid: print matrix, with diff. and residue vector 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 **C;
double *d, *r; double *d, *r;
int m, n; int m, n;

View File

@ -32,6 +32,12 @@
#include "../dllexport.h" #include "../dllexport.h"
#ifdef __GNUC__
# define UNUSED __attribute__((unused))
#else
# define UNUSED
#endif
MZ_DLLEXPORT MZ_DLLEXPORT
double * do_fit(void * function, double * do_fit(void * function,
int n_values, int n_values,

View File

@ -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 /* NOTICE: Change of Copyright Status
* *
* The author of this module, Carsten Grammes, has expressed in * 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 "fit.h"
#include "matrix.h" #include "matrix.h"
#include <math.h> #include <math.h>
#include <stdlib.h>
// create a simple gc malloc... // create a simple gc malloc...
typedef struct Node { typedef struct Node {

View File

@ -343,8 +343,8 @@ rdbuf_line(PLStream *pls)
dbug_enter("rdbuf_line"); dbug_enter("rdbuf_line");
fread(xpl, sizeof(short), npts, pls->plbufFile); if (npts != fread(xpl, sizeof(short), npts, pls->plbufFile)) return;
fread(ypl, sizeof(short), npts, pls->plbufFile); if (npts != fread(ypl, sizeof(short), npts, pls->plbufFile)) return;
plP_line(xpl, ypl); plP_line(xpl, ypl);
} }
@ -363,9 +363,9 @@ rdbuf_polyline(PLStream *pls)
dbug_enter("rdbuf_polyline"); dbug_enter("rdbuf_polyline");
fread(&npts, sizeof(PLINT), 1, pls->plbufFile); if (1 != fread(&npts, sizeof(PLINT), 1, pls->plbufFile)) return;
fread(xpl, sizeof(short), npts, pls->plbufFile); if (npts != fread(xpl, sizeof(short), npts, pls->plbufFile)) return;
fread(ypl, sizeof(short), npts, pls->plbufFile); if (npts != fread(ypl, sizeof(short), npts, pls->plbufFile)) return;
plP_polyline(xpl, ypl, npts); plP_polyline(xpl, ypl, npts);
} }
@ -409,14 +409,14 @@ rdbuf_state(PLStream *pls)
dbug_enter("rdbuf_state"); 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) { switch (op) {
case PLSTATE_WIDTH:{ case PLSTATE_WIDTH:{
U_CHAR 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; pls->width = width;
plP_state(PLSTATE_WIDTH); plP_state(PLSTATE_WIDTH);
@ -426,11 +426,11 @@ rdbuf_state(PLStream *pls)
case PLSTATE_COLOR0:{ case PLSTATE_COLOR0:{
U_CHAR icol0, r, g, b; 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) { if (icol0 == PL_RGB_COLOR) {
fread(&r, sizeof(U_CHAR), 1, pls->plbufFile); if (1 != fread(&r, sizeof(U_CHAR), 1, pls->plbufFile)) return;
fread(&g, sizeof(U_CHAR), 1, pls->plbufFile); if (1 != fread(&g, sizeof(U_CHAR), 1, pls->plbufFile)) return;
fread(&b, sizeof(U_CHAR), 1, pls->plbufFile); if (1 != fread(&b, sizeof(U_CHAR), 1, pls->plbufFile)) return;
} }
else { else {
if ((int) icol0 > 15) { if ((int) icol0 > 15) {
@ -453,7 +453,7 @@ rdbuf_state(PLStream *pls)
case PLSTATE_COLOR1: { case PLSTATE_COLOR1: {
U_CHAR icol1; 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->icol1 = icol1;
pls->curcolor.r = pls->cmap1[icol1].r; pls->curcolor.r = pls->cmap1[icol1].r;
@ -467,7 +467,7 @@ rdbuf_state(PLStream *pls)
case PLSTATE_FILL: { case PLSTATE_FILL: {
signed char patt; 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; pls->patt = patt;
plP_state(PLSTATE_FILL); plP_state(PLSTATE_FILL);
@ -503,7 +503,7 @@ rdbuf_esc(PLStream *pls)
dbug_enter("rdbuf_esc"); 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) { switch (op) {
case PLESC_FILL: case PLESC_FILL:
@ -532,9 +532,9 @@ rdbuf_fill(PLStream *pls)
dbug_enter("rdbuf_fill"); dbug_enter("rdbuf_fill");
fread(&npts, sizeof(PLINT), 1, pls->plbufFile); if (1 != fread(&npts, sizeof(PLINT), 1, pls->plbufFile)) return;
fread(xpl, sizeof(short), npts, pls->plbufFile); if (npts != fread(xpl, sizeof(short), npts, pls->plbufFile)) return;
fread(ypl, sizeof(short), npts, pls->plbufFile); if (npts != fread(ypl, sizeof(short), npts, pls->plbufFile)) return;
plP_fill(xpl, ypl, npts); plP_fill(xpl, ypl, npts);
} }
@ -555,31 +555,37 @@ rdbuf_image(PLStream *pls)
dbug_enter("rdbuf_image"); dbug_enter("rdbuf_image");
fread(&nptsX, sizeof(PLINT), 1, pls->plbufFile); if (1 != fread(&nptsX, sizeof(PLINT), 1, pls->plbufFile)) return;
fread(&nptsY, sizeof(PLINT), 1, pls->plbufFile); if (1 != fread(&nptsY, sizeof(PLINT), 1, pls->plbufFile)) return;
npts = nptsX*nptsY; npts = nptsX*nptsY;
fread(&xmin, sizeof(PLFLT), 1, pls->plbufFile); if (1 != fread(&xmin, sizeof(PLFLT), 1, pls->plbufFile)) return;
fread(&ymin, sizeof(PLFLT), 1, pls->plbufFile); if (1 != fread(&ymin, sizeof(PLFLT), 1, pls->plbufFile)) return;
fread(&dx, sizeof(PLFLT), 1, pls->plbufFile); if (1 != fread(&dx, sizeof(PLFLT), 1, pls->plbufFile)) return;
fread(&dy, sizeof(PLFLT), 1, pls->plbufFile); if (1 != fread(&dy, sizeof(PLFLT), 1, pls->plbufFile)) return;
fread(&dev_zmin, sizeof(short), 1, pls->plbufFile); if (1 != fread(&dev_zmin, sizeof(short), 1, pls->plbufFile)) return;
fread(&dev_zmax, sizeof(short), 1, pls->plbufFile); if (1 != fread(&dev_zmax, sizeof(short), 1, pls->plbufFile)) return;
dev_ix=(short *)malloc(npts*sizeof(short)); dev_ix=(short *)malloc(npts*sizeof(short));
if (!dev_ix) return;
dev_iy=(short *)malloc(npts*sizeof(short)); 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)); 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); if (npts != fread(dev_ix, sizeof(short), npts, pls->plbufFile)) goto end;
fread(dev_iy, sizeof(short), npts, pls->plbufFile); if (npts != fread(dev_iy, sizeof(short), npts, pls->plbufFile)) goto end;
fread(dev_z, sizeof(unsigned short), (nptsX-1)*(nptsY-1), pls->plbufFile); 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); plP_image(dev_ix, dev_iy, dev_z, nptsX, nptsY, xmin, ymin, dx, dy, dev_zmin, dev_zmax);
free(dev_ix); end:
free(dev_iy);
free(dev_z); free(dev_z);
end_z:
free(dev_iy);
end_y:
free(dev_ix);
} }
/*--------------------------------------------------------------------------*\ /*--------------------------------------------------------------------------*\
@ -593,15 +599,15 @@ rdbuf_swin(PLStream *pls)
{ {
PLWindow plwin; PLWindow plwin;
fread(&plwin.dxmi, sizeof(PLFLT), 1, pls->plbufFile); if (1 != fread(&plwin.dxmi, sizeof(PLFLT), 1, pls->plbufFile)) return;
fread(&plwin.dxma, sizeof(PLFLT), 1, pls->plbufFile); if (1 != fread(&plwin.dxma, sizeof(PLFLT), 1, pls->plbufFile)) return;
fread(&plwin.dymi, sizeof(PLFLT), 1, pls->plbufFile); if (1 != fread(&plwin.dymi, sizeof(PLFLT), 1, pls->plbufFile)) return;
fread(&plwin.dyma, sizeof(PLFLT), 1, pls->plbufFile); if (1 != fread(&plwin.dyma, sizeof(PLFLT), 1, pls->plbufFile)) return;
fread(&plwin.wxmi, sizeof(PLFLT), 1, pls->plbufFile); if (1 != fread(&plwin.wxmi, sizeof(PLFLT), 1, pls->plbufFile)) return;
fread(&plwin.wxma, sizeof(PLFLT), 1, pls->plbufFile); if (1 != fread(&plwin.wxma, sizeof(PLFLT), 1, pls->plbufFile)) return;
fread(&plwin.wymi, sizeof(PLFLT), 1, pls->plbufFile); if (1 != fread(&plwin.wymi, sizeof(PLFLT), 1, pls->plbufFile)) return;
fread(&plwin.wyma, sizeof(PLFLT), 1, pls->plbufFile); if (1 != fread(&plwin.wyma, sizeof(PLFLT), 1, pls->plbufFile)) return;
plP_swin(&plwin); plP_swin(&plwin);
} }

View File

@ -1859,7 +1859,9 @@ plSelectDev()
fprintf(stdout, "\nEnter device number or keyword (stream %d): ", fprintf(stdout, "\nEnter device number or keyword (stream %d): ",
(int) ipls); (int) ipls);
fgets(response, sizeof(response), stdin); if (! (fgets(response, sizeof(response), stdin))) {
return;
}
/* First check to see if device keyword was entered. */ /* First check to see if device keyword was entered. */
/* Final "\n" in response messes things up, so ignore it. */ /* Final "\n" in response messes things up, so ignore it. */

View File

@ -19,8 +19,6 @@ typedef lt_ptr (*PLDispatchInit)( PLDispatchTable *pdt );
typedef void (*PLDispatchInit)( PLDispatchTable *pdt ); typedef void (*PLDispatchInit)( PLDispatchTable *pdt );
#endif #endif
/* Static function prototypes */ /* Static function prototypes */
static void grline (short *, short *, PLINT); static void grline (short *, short *, PLINT);
@ -250,6 +248,6 @@ static PLLoadableDevice *loadable_device_list;
static PLLoadableDriver *loadable_driver_list; static PLLoadableDriver *loadable_driver_list;
#endif #endif
static int nloadabledrivers = 0; static UNUSED int nloadabledrivers = 0;
#endif /* __PLCORE_H__ */ #endif /* __PLCORE_H__ */

View File

@ -1445,7 +1445,9 @@ plOpenFile(PLStream *pls)
if (pls->FileName == NULL) { if (pls->FileName == NULL) {
do { do {
fprintf(stdout, "Enter graphics output file name: "); fprintf(stdout, "Enter graphics output file name: ");
fgets(line, sizeof(line), stdin); if (!fgets(line, sizeof(line), stdin)) {
return;
}
len = strlen(line); len = strlen(line);
if (len) if (len)
len--; len--;
@ -1671,8 +1673,10 @@ plGetInt(char *s)
char line[256]; char line[256];
while (i++ < 10) { while (i++ < 10) {
fprintf(stdout, s); fprintf(stdout, "%s", s);
fgets(line, sizeof(line), stdin); if (! (fgets(line, sizeof(line), stdin))) {
return 0;
}
#ifdef MSDOS #ifdef MSDOS
m = atoi(line); m = atoi(line);
return (m); return (m);
@ -1701,8 +1705,10 @@ plGetFlt(char *s)
char line[256]; char line[256];
while (i++ < 10) { while (i++ < 10) {
fprintf(stdout, s); fprintf(stdout, "%s", s);
fgets(line, sizeof(line), stdin); if (! (fgets(line, sizeof(line), stdin))) {
return (0.);
}
#ifdef MSDOS #ifdef MSDOS
m = atof(line); m = atof(line);
return (m); return (m);

View File

@ -57,8 +57,14 @@ if (plsc->debug) \
* The label is typically the calling function name. * The label is typically the calling function name.
\*--------------------------------------------------------------------------*/ \*--------------------------------------------------------------------------*/
#ifdef __GNUC__
# define UNUSED __attribute__((unused))
#else
# define UNUSED
#endif
#ifdef NEED_PLDEBUG #ifdef NEED_PLDEBUG
static void UNUSED static void
pldebug( const char *label, ... ) pldebug( const char *label, ... )
{ {
#ifdef DEBUG #ifdef DEBUG

View File

@ -11,7 +11,7 @@
#include <qhull/qhull_a.h> #include <qhull/qhull_a.h>
#endif #endif
#if !defined(HAVE_ISNAN) #if !defined(HAVE_ISNAN) && !defined(isnan)
#define isnan(x) ((x) != (x)) #define isnan(x) ((x) != (x))
#endif #endif

View File

@ -186,7 +186,7 @@ shade_triangle(PLFLT x0, PLFLT y0, PLFLT z0,
int i; int i;
/* arrays for interface to core functions */ /* arrays for interface to core functions */
short u[6], v[6]; short u[6], v[6];
PLFLT x[6], y[6], z[6], c; PLFLT x[6], y[6], z[6];
int n; int n;
PLFLT xmin, xmax, ymin, ymax, zmin, zmax, zscale; PLFLT xmin, xmax, ymin, ymax, zmin, zmax, zscale;
PLFLT *V[3]; PLFLT *V[3];
@ -768,7 +768,7 @@ c_plot3dc(PLFLT *x, PLFLT *y, PLFLT **z,
ny = _ny; 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 * Don't use the data z value to scale the color, use the z axis
* values set by plw3d() * values set by plw3d()

View File

@ -1054,8 +1054,11 @@ plfntld(PLINT fnt)
#if PLPLOT_USE_TCL_CHANNELS #if PLPLOT_USE_TCL_CHANNELS
pdf_rdx(fntbffr, sizeof(signed char)*(2 * bffrleng), pdfs); pdf_rdx(fntbffr, sizeof(signed char)*(2 * bffrleng), pdfs);
#else #else
fread((void *) fntbffr, (size_t) sizeof(signed char), if ( (2 * bffrleng) !=
(size_t) (2 * bffrleng), pdfs->file); fread((void *) fntbffr, (size_t) sizeof(signed char),
(size_t) (2 * bffrleng), pdfs->file) ) {
plexit("plfntld: Failed to read into font buffer.");
}
#endif #endif
/* Done */ /* Done */