[MINC-development] clearing compile warnings
Steve M. Robbins
steve at sumost.ca
Fri Jan 11 03:01:25 EST 2008
Hi,
Since I hear that 2.0.15 is imminent, I thought I'd see if I can
remove some of the warnings emitted by gcc -Wall in hopes of having it
build on sparc and arm.
I committed changes to remove unused variables.
There are also a number of unhandled cases in switch
statements. Attached is a patch that clears some of them,
for your consideration. Is logging an error message
in MI_TO_DOUBLE / MI_FROM_DOUBLE kosher? In the
minc_convenience patch?
Regards
-Steve
Index: libsrc/minc_basic.h
===================================================================
RCS file: /private-cvsroot/minc/libsrc/minc_basic.h,v
retrieving revision 6.4
diff -u -b -B -r6.4 minc_basic.h
--- libsrc/minc_basic.h 9 Aug 2007 17:05:25 -0000 6.4
+++ libsrc/minc_basic.h 11 Jan 2008 07:52:31 -0000
@@ -66,6 +66,8 @@
@RCSID : $Header: /private-cvsroot/minc/libsrc/minc_basic.h,v 6.4 2007/08/09 17:05:25 rotor Exp $ MINC (MNI)
---------------------------------------------------------------------------- */
+#include <minc.h>
+
/* --------- MINC specific constants ------------- */
/* Maximum buffer size for conversions. Should not be a power of 2 - this
@@ -129,6 +131,7 @@
#define MI_TO_DOUBLE(dvalue, type, sign, ptr) \
switch (type) { \
case NC_BYTE : \
+ case NC_CHAR : \
switch (sign) { \
case MI_PRIV_UNSIGNED : \
dvalue = (double) *((unsigned char *) ptr); break; \
@@ -158,11 +161,17 @@
case NC_DOUBLE : \
dvalue = (double) *((double *) ptr); \
break; \
+ case NC_NAT : \
+ MI_LOG_PKG_ERROR2(MI_ERR_NONNUMERIC, \
+ "Attempt to convert NC_NAT value to double"); \
+ dvalue = 0; \
+ break; \
}
#define MI_FROM_DOUBLE(dvalue, type, sign, ptr) \
switch (type) { \
case NC_BYTE : \
+ case NC_CHAR : \
switch (sign) { \
case MI_PRIV_UNSIGNED : \
dvalue = MAX(0, dvalue); \
@@ -211,6 +220,11 @@
case NC_DOUBLE : \
*((double *) ptr) = dvalue; \
break; \
+ case NC_NAT : \
+ MI_LOG_PKG_ERROR2(MI_ERR_NONNUMERIC, \
+ "Attempt to convert to NC_NAT value from double"); \
+ dvalue = 0; \
+ break; \
}
/**/
Index: libsrc/minc_convenience.c
===================================================================
RCS file: /private-cvsroot/minc/libsrc/minc_convenience.c,v
retrieving revision 6.19
diff -u -b -B -r6.19 minc_convenience.c
--- libsrc/minc_convenience.c 3 Dec 2007 14:19:35 -0000 6.19
+++ libsrc/minc_convenience.c 11 Jan 2008 07:59:42 -0000
@@ -315,6 +315,12 @@
if (miget_datatype(cdfid, imgid, &datatype, &is_signed) == MI_ERROR)
MI_RETURN(MI_ERROR);
+ if ( datatype == NC_NAT ) {
+ MI_LOG_PKG_ERROR2(MI_ERR_NONNUMERIC,
+ "Attempt to get valid range from NC_NAT variable");
+ MI_RETURN(MI_ERROR);
+ }
+
/* Save the ncopts value */
old_ncopts = ncopts;
ncopts = 0;
@@ -364,6 +370,7 @@
case NC_INT:
case NC_SHORT:
case NC_BYTE:
+ case NC_CHAR:
if (is_signed) {
valid_range[0] = (int) valid_range[0];
valid_range[1] = (int) valid_range[1];
@@ -377,6 +384,12 @@
valid_range[0] = (float) valid_range[0];
valid_range[1] = (float) valid_range[1];
break;
+ /* NC_DOUBLE is no-op, but include case to let compiler know we thought about it. */
+ case NC_DOUBLE:
+ break;
+ /* NC_NAT should have been handled at start of this routine. */
+ case NC_NAT:
+ MI_RETURN(MI_ERROR);
}
MI_RETURN(MI_NOERROR);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.bic.mni.mcgill.ca/pipermail/minc-development/attachments/20080111/79f387fa/attachment.bin
More information about the MINC-development
mailing list