From: <kin...@us...> - 2012-09-26 02:32:39
|
Revision: 5661 http://teem.svn.sourceforge.net/teem/?rev=5661&view=rev Author: kindlmann Date: 2012-09-26 02:32:32 +0000 (Wed, 26 Sep 2012) Log Message: ----------- variable and parameter renamings to avoid shadowing things like index, read, round, y0, y1, log2 (as revealed by gcc -Wshadow) Modified Paths: -------------- teem/trunk/src/CODING.txt teem/trunk/src/bin/talkweb.c teem/trunk/src/coil/coreCoil.c teem/trunk/src/echo/color.c teem/trunk/src/echo/matter.c teem/trunk/src/echo/set.c teem/trunk/src/gage/shape.c teem/trunk/src/make/darwin.mk teem/trunk/src/mite/txf.c teem/trunk/src/nrrd/encodingGzip.c teem/trunk/src/nrrd/filt.c teem/trunk/src/nrrd/gzio.c teem/trunk/src/nrrd/nrrd.h teem/trunk/src/nrrd/resampleContext.c teem/trunk/src/nrrd/resampleNrrd.c teem/trunk/src/pull/parmPull.c teem/trunk/src/ten/tendFiber.c teem/trunk/src/unrrdu/i2w.c teem/trunk/src/unrrdu/w2i.c Modified: teem/trunk/src/CODING.txt =================================================================== --- teem/trunk/src/CODING.txt 2012-09-26 02:29:53 UTC (rev 5660) +++ teem/trunk/src/CODING.txt 2012-09-26 02:32:32 UTC (rev 5661) @@ -256,20 +256,51 @@ * The tests in teem/Testing are slowly accumulating. Much of the effort in ongoing Teem development will be in creating and strengthening tests. -* For the most part, Teem is written in ANSI C89. The known ways in -which the code diverges from this standard are: - - using the "long long" type qualifier to generate 64-bit ints - - various strings created at compile time, often with the benefit of the +* Teem is 99.9% ANSI C89. The known ways in which it isn't conformant are: + - using the "long long" type qualifier to generate 64-bit ints (on *nix, + and __int64 on Windows). + - various strings created at compile time, often via the automatic "foo" "bar" --> "foobar" string concatenation, exceed the length 509 guaranteed to be supported by the standard - - using snprintf() and fileno(), which are usually part of stdio.h -The relevant gcc invocation might include something like: -"-W -Wall -Wextra -C89 -pedantic -Wno-long-long -Wno-overlength-string" + - using snprintf() and fileno(), which are not necessarily part of stdio.h Note that automatic conversion from a non-void* to a void*, in the specific case of supplying the value for a %p argument to a printf-like function, is -not actually supported: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26542 -The AIR_VOIDP(x) macro can be used to cast x to void*. +not actually in C89: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26542 +The AIR_VOIDP(x) and AIR_CVOIDP(x) macros are used to cast x to void* +or const void * in this context. +* Compiling with various warnings can help reveal bugs and potential problems. +The advice here is relevant for Teem: +http://www.gnu.org/software/gsl/manual/html_node/GCC-warning-options-for-numerical-programs.html + +However, -Wmissing-prototypes complains about a missing prototype even for +local (static) functions that aren't used outside a given file, which is very +common in Teem, and adding protoypes would be onerous (and for similar +reasons -Wmissing-declarations is not helpful). So what has proven useful +for development is: + + gcc -O2 -std=c89 -pedantic \ + -W -Wall -Wextra -Wno-long-long -Wno-overlength-strings \ + -fstrict-aliasing -Wstrict-aliasing=2 -fstrict-overflow -Wstrict-overflow=5 \ + -ftrapv -fshort-enums -fno-common \ + -Wpointer-arith -Wcast-qual -Wcast-align \ + -Wstrict-prototypes -Wshadow -Wwrite-strings -Wnested-externs \ + -Wunreachable-code -Wmissing-field-initializers + +* Avoid symbol names that shadow others means there is a set of names that +should be avoided (as revealed by -Wshadow). Here are some that have been +removed from Teem, starting with the most suprising: +index: looks to be same as strchr, but in strings.h instead of string.h +round: round double to integer +y0, y1: along with j0, j1, jn, yn, these are for Bessel functions +signal: basic unix process communication +read: read from file descriptors; a system call +exp, log2: math functions, oops + +The relevant gcc invocation might include something like: +"-W -Wall -Wextra -C89 -pedantic -Wno-long-long -Wno-overlength-string" + + * Any externally visible changes in Teem must be accompanied by regenerating its python ctypes wrappers teem/python/ctypes/teem.py. The current tools for doing this are not very slick, including the drawback that the information from @@ -291,10 +322,10 @@ followed by "svn commit" if needed. * Make casts grep-able. This usually means using AIR_CAST, but can also mean -using macros AIR_VOIDP, AIR_UINT, AIR_INT, and the ell macros ending in "_TT". -The only exception is casting things to airMopper to pass to airMopAdd(). -(why: casts are inherently tricky, and sources of bugs, so their use should -be grep-able) +using macros AIR_VOIDP, AIR_CVOIDP, AIR_UINT, AIR_INT, and the ell macros +ending in "_TT". The only exception is casting things to airMopper to pass +to airMopAdd(). (why: casts are inherently tricky, and sources of bugs, so +their use should be grep-able) * Use AIR_CALLOC (preferably) or AIR_MALLOC to allocate things (why: both explicitly indicate the number of elements, and the size of each, and both Modified: teem/trunk/src/bin/talkweb.c =================================================================== --- teem/trunk/src/bin/talkweb.c 2012-09-26 02:29:53 UTC (rev 5660) +++ teem/trunk/src/bin/talkweb.c 2012-09-26 02:32:32 UTC (rev 5661) @@ -304,9 +304,9 @@ } int -tkwbWriteIndex(char *_index, tkwbSlide **slide, char *tag[TKWB_TAG_MAX+1]) { +tkwbWriteIndex(char *_indx, tkwbSlide **slide, char *tag[TKWB_TAG_MAX+1]) { static const char me[]="tkwbWriteIndex"; - char *repl, *index, tmp[AIR_STRLEN_MED]; + char *repl, *indx, tmp[AIR_STRLEN_MED]; int replLen, si; airArray *mop; @@ -333,10 +333,10 @@ } strcat(repl, "</ol>"); - index = airStrdup(_index); - tkwbStringSubst(&index, tag[TKWB_TAG_TOC], repl); - airMopAdd(mop, index, airFree, airMopAlways); - if (tkwbWriteStringToFile("index.html", index)) { + indx = airStrdup(_indx); + tkwbStringSubst(&indx, tag[TKWB_TAG_TOC], repl); + airMopAdd(mop, indx, airFree, airMopAlways); + if (tkwbWriteStringToFile("index.html", indx)) { biffAddf(TKWB, "%s: couldn't write \"index.html\"", me); airMopError(mop); return 1; } @@ -385,20 +385,20 @@ } int -tkwbDoit(char *indexS, char *tmplS, char *scriptS, +tkwbDoit(char *indxS, char *tmplS, char *scriptS, char *tag[TKWB_TAG_MAX+1], char *link[4]) { static const char me[]="tkwbDoit"; - char *index, *tmpl; + char *indx, *tmpl; tkwbSlide **slide; airArray *mop; int numSlides; mop = airMopNew(); - if (tkwbReadTemplate(&index, indexS)) { + if (tkwbReadTemplate(&indx, indxS)) { biffAddf(TKWB, "%s: trouble reading in index template file", me); airMopError(mop); return 1; } - airMopAdd(mop, index, airFree, airMopAlways); + airMopAdd(mop, indx, airFree, airMopAlways); if (tkwbReadTemplate(&tmpl, tmplS)) { biffAddf(TKWB, "%s: trouble reading in slide template file", me); @@ -417,7 +417,7 @@ airMopError(mop); return 1; } - if (tkwbWriteIndex(index, slide, tag)) { + if (tkwbWriteIndex(indx, slide, tag)) { biffAddf(TKWB, "%s: trouble writing index.html", me); airMopError(mop); return 1; } @@ -435,7 +435,7 @@ int main(int argc, const char *argv[]) { const char *me; - char *err, *indexS, *tmplS, *scriptS, *pretag[TKWB_TAG_MAX+1], + char *err, *indxS, *tmplS, *scriptS, *pretag[TKWB_TAG_MAX+1], *tag[AIR_STRLEN_MED], *frstLink, *prevLink, *nextLink, *lastLink, *link[4]; hestOpt *hopt = NULL; @@ -443,7 +443,7 @@ int ti; me = argv[0]; - hestOptAdd(&hopt, "i", "index", airTypeString, 1, 1, &indexS, NULL, + hestOptAdd(&hopt, "i", "index", airTypeString, 1, 1, &indxS, NULL, "*index* template HTML filename. This will be turned into " "the \"index.html\" index file, after the links to all the " "slides have been substituted in."); @@ -500,7 +500,7 @@ airMopAdd(mop, tag[ti], airFree, airMopAlways); sprintf(tag[ti], "<!--%s-->", pretag[ti]); } - if (tkwbDoit(indexS, tmplS, scriptS, tag, link)) { + if (tkwbDoit(indxS, tmplS, scriptS, tag, link)) { airMopAdd(mop, err = biffGetDone(TKWB), airFree, airMopAlways); fprintf(stderr, "%s: error:\n%s", me, err); airMopError(mop); return 1; Modified: teem/trunk/src/coil/coreCoil.c =================================================================== --- teem/trunk/src/coil/coreCoil.c 2012-09-26 02:29:53 UTC (rev 5660) +++ teem/trunk/src/coil/coreCoil.c 2012-09-26 02:32:32 UTC (rev 5661) @@ -24,7 +24,7 @@ #include "coil.h" #define _COIL_IV3_FILL(radius, diam, valLen) \ - if (0 && x0) { \ + if (0 && xx0) { \ /* cycle through slices */ \ tmp = iv3[0]; \ for (xni=0; xni<diam-1; xni++) { \ @@ -33,11 +33,11 @@ iv3[diam-1] = tmp; \ /* refill only newest one */ \ xni = diam-1; \ - xvi = AIR_CLAMP(0, xni-(int)radius+x0, sizeX-1) - x0; \ + xvi = AIR_CLAMP(0, xni-(int)radius+xx0, sizeX-1) - xx0; \ for (zni=0; zni<diam; zni++) { \ - zvi = AIR_CLAMP(0, zni-(int)radius+z0, sizeZ-1) - z0; \ + zvi = AIR_CLAMP(0, zni-(int)radius+zz0, sizeZ-1) - zz0; \ for (yni=0; yni<diam; yni++) { \ - yvi = AIR_CLAMP(0, yni-(int)radius+y0, sizeY-1) - y0; \ + yvi = AIR_CLAMP(0, yni-(int)radius+yy0, sizeY-1) - yy0; \ for (vi=0; vi<valLen; vi++) { \ iv3[xni][vi + valLen*(yni + diam*zni)] = \ here[vi + valLen*(0 + 2*(xvi + sizeX*(yvi + sizeY*zvi)))]; \ @@ -47,11 +47,11 @@ } else { \ /* have to re-fill entire thing */ \ for (zni=0; zni<diam; zni++) { \ - zvi = AIR_CLAMP(0, zni-(int)radius+z0, sizeZ-1) - z0; \ + zvi = AIR_CLAMP(0, zni-(int)radius+zz0, sizeZ-1) - zz0; \ for (yni=0; yni<diam; yni++) { \ - yvi = AIR_CLAMP(0, yni-(int)radius+y0, sizeY-1) - y0; \ + yvi = AIR_CLAMP(0, yni-(int)radius+yy0, sizeY-1) - yy0; \ for (xni=0; xni<diam; xni++) { \ - xvi = AIR_CLAMP(0, xni-(int)radius+x0, sizeX-1) - x0; \ + xvi = AIR_CLAMP(0, xni-(int)radius+xx0, sizeX-1) - xx0; \ for (vi=0; vi<valLen; vi++) { \ iv3[xni][vi + valLen*(yni + diam*zni)] = \ here[vi + valLen*(0 + 2*(xvi + sizeX*(yvi + sizeY*zvi)))]; \ @@ -69,7 +69,7 @@ */ void _coilIv3Fill_R_L(coil_t **iv3, coil_t *here, unsigned int radius, int valLen, - int x0, int y0, int z0, int sizeX, int sizeY, int sizeZ) { + int xx0, int yy0, int zz0, int sizeX, int sizeY, int sizeZ) { int diam, vi, /* value index */ xni, yni, zni, /* neighborhood (iv3) indices */ xvi, yvi, zvi; /* volume indices */ @@ -82,7 +82,7 @@ void _coilIv3Fill_1_1(coil_t **iv3, coil_t *here, unsigned int radius, int valLen, - int x0, int y0, int z0, int sizeX, int sizeY, int sizeZ) { + int xx0, int yy0, int zz0, int sizeX, int sizeY, int sizeZ) { int vi, /* value index */ xni, yni, zni, /* neighborhood (iv3) indices */ xvi, yvi, zvi; /* volume indices */ @@ -97,7 +97,7 @@ void _coilIv3Fill_1_7(coil_t **iv3, coil_t *here, unsigned int radius, int valLen, - int x0, int y0, int z0, int sizeX, int sizeY, int sizeZ) { + int xx0, int yy0, int zz0, int sizeX, int sizeY, int sizeZ) { int vi, /* value index */ xni, yni, zni, /* neighborhood (iv3) indices */ xvi, yvi, zvi; /* volume indices */ Modified: teem/trunk/src/echo/color.c =================================================================== --- teem/trunk/src/echo/color.c 2012-09-26 02:29:53 UTC (rev 5660) +++ teem/trunk/src/echo/color.c 2012-09-26 02:32:32 UTC (rev 5661) @@ -258,17 +258,17 @@ */ int _echoRefract(echoPos_t T[3], echoPos_t V[3], - echoPos_t N[3], echoCol_t index, echoThreadState *tstate) { + echoPos_t N[3], echoCol_t indexr, echoThreadState *tstate) { echoPos_t cosTh, cosPh, sinPhSq, cosPhSq, tmp1, tmp2; cosTh = ELL_3V_DOT(V, N); - sinPhSq = (1 - cosTh*cosTh)/(index*index); + sinPhSq = (1 - cosTh*cosTh)/(indexr*indexr); cosPhSq = 1 - sinPhSq; if (cosPhSq < 0) { if (tstate->verbose) { fprintf(stderr, "%s%s: cosTh = %g --%g--> TIR!!\n", _echoDot(tstate->depth), "_echoRefract", - cosTh, index); + cosTh, indexr); } return AIR_FALSE; } @@ -277,9 +277,9 @@ if (tstate->verbose) { fprintf(stderr, "%s%s: cosTh = %g --%g--> cosPh = %g\n", _echoDot(tstate->depth), "_echoRefract", - cosTh, index, cosPh); + cosTh, indexr, cosPh); } - tmp1 = -1.0/index; tmp2 = cosTh/index - cosPh; + tmp1 = -1.0/indexr; tmp2 = cosTh/indexr - cosPh; ELL_3V_SCALE_ADD2(T, tmp1, V, tmp2, N); ELL_3V_NORM(T, T, tmp1); return AIR_TRUE; @@ -291,7 +291,7 @@ echoCol_t ambi[3], diff[3], ka, kd, RP, RS, RT, R0, - index, /* (index of material we're going into) / + indexr, /* (index of material we're going into) / (index of material we're leaving) */ k[3], /* attenuation of color due to travel through medium */ matlCol[4], /* inherent color */ @@ -312,7 +312,7 @@ tranRay.shadow = reflRay.shadow = AIR_FALSE; ELL_3V_COPY(reflRay.dir, intx->refl); /* tranRay.dir set below */ - index = intx->obj->mat[echoMatterGlassIndex]; + indexr = intx->obj->mat[echoMatterGlassIndex]; RS = 0.0; /* this is a flag meaning: "AFAIK, there's no total int refl" */ tmp = ELL_3V_DOT(intx->norm, intx->view); @@ -320,12 +320,12 @@ /* "d.n < 0": we're coming from outside the glass, and we assume this means that we're going into a HIGHER index material, which means there is NO total internal reflection */ - _echoRefract(tranRay.dir, intx->view, intx->norm, index, tstate); + _echoRefract(tranRay.dir, intx->view, intx->norm, indexr, tstate); if (tstate->verbose) { fprintf(stderr, "%s%s: V=(%g,%g,%g),N=(%g,%g,%g),n=%g -> T=(%g,%g,%g)\n", _echoDot(tstate->depth), me, intx->view[0], intx->view[1], intx->view[2], - intx->norm[0], intx->norm[1], intx->norm[2], index, + intx->norm[0], intx->norm[1], intx->norm[2], indexr, tranRay.dir[0], tranRay.dir[1], tranRay.dir[2]); } c = tmp; @@ -344,7 +344,7 @@ _echoDot(tstate->depth), me, intx->t, k[0], k[1], k[2]); } ELL_3V_SCALE(negnorm, -1, intx->norm); - if (_echoRefract(tranRay.dir, intx->view, negnorm, 1/index, tstate)) { + if (_echoRefract(tranRay.dir, intx->view, negnorm, 1/indexr, tstate)) { c = -ELL_3V_DOT(tranRay.dir, negnorm); } else { /* its total internal reflection time! */ @@ -357,7 +357,7 @@ /* total internal reflection */ RT = 0; } else { - R0 = (index - 1)/(index + 1); + R0 = (indexr - 1)/(indexr + 1); R0 *= R0; c = 1 - c; c = c*c*c*c*c; @@ -435,7 +435,7 @@ */ void echoIntxFuzzify(echoIntx *intx, echoCol_t fuzz, echoThreadState *tstate) { - echoPos_t tmp, *jitt, oldNorm[3], perp0[3], perp1[3], j0, j1; + echoPos_t tmp, *jitt, oldNorm[3], perp0[3], perp1[3], jj0, jj1; int side; /* at some point I thought this was important to avoid bias when @@ -446,18 +446,18 @@ } else { jitt = tstate->jitt + 2*echoJittableNormalB; } - j0 = fuzz*jitt[0]; - j1 = fuzz*jitt[1]; + jj0 = fuzz*jitt[0]; + jj1 = fuzz*jitt[1]; ELL_3V_COPY(oldNorm, intx->norm); side = ELL_3V_DOT(intx->refl, oldNorm) > 0; ell_3v_PERP(perp0, oldNorm); ELL_3V_NORM(perp0, perp0, tmp); ELL_3V_CROSS(perp1, perp0, oldNorm); - ELL_3V_SCALE_ADD3(intx->norm, 1, oldNorm, j0, perp0, j1, perp1); + ELL_3V_SCALE_ADD3(intx->norm, 1, oldNorm, jj0, perp0, jj1, perp1); ELL_3V_NORM(intx->norm, intx->norm, tmp); _ECHO_REFLECT(intx->refl, intx->norm, intx->view, tmp); if (side != (ELL_3V_DOT(intx->refl, oldNorm) > 0)) { - ELL_3V_SCALE_ADD3(intx->norm, 1, oldNorm, -j0, perp0, -j1, perp1); + ELL_3V_SCALE_ADD3(intx->norm, 1, oldNorm, -jj0, perp0, -jj1, perp1); ELL_3V_NORM(intx->norm, intx->norm, tmp); _ECHO_REFLECT(intx->refl, intx->norm, intx->view, tmp); } Modified: teem/trunk/src/echo/matter.c =================================================================== --- teem/trunk/src/echo/matter.c 2012-09-26 02:29:53 UTC (rev 5660) +++ teem/trunk/src/echo/matter.c 2012-09-26 02:32:32 UTC (rev 5661) @@ -64,12 +64,12 @@ void echoMatterGlassSet(echoScene *scene, echoObject *obj, - echoCol_t index, echoCol_t ka, + echoCol_t indexr, echoCol_t ka, echoCol_t kd, echoCol_t fuzzy) { if (scene && obj && echoObjectHasMatter[obj->type]) { obj->matter = echoMatterGlass; - obj->mat[echoMatterGlassIndex] = index; + obj->mat[echoMatterGlassIndex] = indexr; obj->mat[echoMatterGlassKa] = ka; obj->mat[echoMatterGlassKd] = kd; obj->mat[echoMatterGlassFuzzy] = fuzzy; Modified: teem/trunk/src/echo/set.c =================================================================== --- teem/trunk/src/echo/set.c 2012-09-26 02:29:53 UTC (rev 5660) +++ teem/trunk/src/echo/set.c 2012-09-26 02:32:32 UTC (rev 5661) @@ -73,14 +73,14 @@ void echoTriangleSet(echoObject *tri, - echoPos_t x0, echoPos_t y0, echoPos_t z0, - echoPos_t x1, echoPos_t y1, echoPos_t z1, - echoPos_t x2, echoPos_t y2, echoPos_t z2) { + echoPos_t xx0, echoPos_t yy0, echoPos_t zz0, + echoPos_t xx1, echoPos_t yy1, echoPos_t zz1, + echoPos_t xx2, echoPos_t yy2, echoPos_t zz2) { if (tri && echoTypeTriangle == tri->type) { - ELL_3V_SET(TRIANGLE(tri)->vert[0], x0, y0, z0); - ELL_3V_SET(TRIANGLE(tri)->vert[1], x1, y1, z1); - ELL_3V_SET(TRIANGLE(tri)->vert[2], x2, y2, z2); + ELL_3V_SET(TRIANGLE(tri)->vert[0], xx0, yy0, zz0); + ELL_3V_SET(TRIANGLE(tri)->vert[1], xx1, yy1, zz1); + ELL_3V_SET(TRIANGLE(tri)->vert[2], xx2, yy2, zz2); } return; } Modified: teem/trunk/src/gage/shape.c =================================================================== --- teem/trunk/src/gage/shape.c 2012-09-26 02:29:53 UTC (rev 5660) +++ teem/trunk/src/gage/shape.c 2012-09-26 02:32:32 UTC (rev 5661) @@ -86,18 +86,18 @@ static void shapeUnitItoW(const gageShape *shape, double world[3], - const double index[3], const double volHalfLen[3]) { + const double indx[3], const double volHalfLen[3]) { unsigned int i; if (nrrdCenterNode == shape->center) { for (i=0; i<=2; i++) { world[i] = NRRD_NODE_POS(-volHalfLen[i], volHalfLen[i], - shape->size[i], index[i]); + shape->size[i], indx[i]); } } else { for (i=0; i<=2; i++) { world[i] = NRRD_CELL_POS(-volHalfLen[i], volHalfLen[i], - shape->size[i], index[i]); + shape->size[i], indx[i]); } } } @@ -413,17 +413,17 @@ /* ** this wasn't being used at all void -gageShapeUnitWtoI(gageShape *shape, double index[3], double world[3]) { +gageShapeUnitWtoI(gageShape *shape, double indx[3], double world[3]) { int i; if (nrrdCenterNode == shape->center) { for (i=0; i<=2; i++) { - index[i] = NRRD_NODE_IDX(-shape->volHalfLen[i], shape->volHalfLen[i], + indx[i] = NRRD_NODE_IDX(-shape->volHalfLen[i], shape->volHalfLen[i], shape->size[i], world[i]); } } else { for (i=0; i<=2; i++) { - index[i] = NRRD_CELL_IDX(-shape->volHalfLen[i], shape->volHalfLen[i], + indx[i] = NRRD_CELL_IDX(-shape->volHalfLen[i], shape->volHalfLen[i], shape->size[i], world[i]); } } @@ -432,28 +432,28 @@ void gageShapeWtoI(const gageShape *shape, - double _index[3], const double _world[3]) { + double _indx[3], const double _world[3]) { /* static const char me[]="gageShapeWtoI"; */ - double index[4], world[4]; + double indx[4], world[4]; /* fprintf(stderr, "!%s: hello %p %p %p; %p\n", me, - shape, _index, _world, shape->WtoI); + shape, _indx, _world, shape->WtoI); */ ELL_3V_COPY(world, _world); world[3] = 1.0; - ELL_4MV_MUL(index, shape->WtoI, world); - ELL_3V_SCALE(_index, 1.0/index[3], index); + ELL_4MV_MUL(indx, shape->WtoI, world); + ELL_3V_SCALE(_indx, 1.0/indx[3], indx); } void gageShapeItoW(const gageShape *shape, - double _world[3], const double _index[3]) { - double world[4], index[4]; + double _world[3], const double _indx[3]) { + double world[4], indx[4]; - ELL_3V_COPY(index, _index); - index[3] = 1.0; - ELL_4MV_MUL(world, shape->ItoW, index); + ELL_3V_COPY(indx, _indx); + indx[3] = 1.0; + ELL_4MV_MUL(world, shape->ItoW, indx); ELL_3V_SCALE(_world, 1.0/world[3], world); } Modified: teem/trunk/src/make/darwin.mk =================================================================== --- teem/trunk/src/make/darwin.mk 2012-09-26 02:29:53 UTC (rev 5660) +++ teem/trunk/src/make/darwin.mk 2012-09-26 02:32:32 UTC (rev 5661) @@ -25,19 +25,43 @@ ARFLAGS = -static -o RANLIB = ranlib -LD = gcc +#LD = clang +#CC = clang +#OPT_CFLAG ?= -O2 -fstrict-aliasing -fcatch-undefined-behavior -OPT_CFLAG ?= -O3 +#LD = clang +#CC = clang +#LD = gcc +#CC = gcc +LD = colorgcc +CC = colorgcc +# OPT_CFLAG ?= -O3 -fast +# see http://www.gnu.org/software/gsl/manual/html_node/GCC-warning-options-for-numerical-programs.html +# +# PUT BACK: +# -Wconversion +# +# Not useful given the structure of Teem: +# -Wmissing-prototypes, -Wmissing-declarations wants prototypes even for local static functions +# -Wbad-function-cast doesn't like cast the result of a function (not the function pointer) +# -Wmissing-format-attribute could be interesting, but moot once a printf replacement is in place +OPT_CFLAG ?= -O2 -ansi -pedantic \ + -W -Wall -Wextra -Wno-long-long -Wno-overlength-strings \ + -fstrict-aliasing -Wstrict-aliasing=9 -fstrict-overflow -Wstrict-overflow=9 \ + -Wpointer-arith -Wcast-qual -Wcast-align -ftrapv \ + -Wstrict-prototypes -Wshadow -Wwrite-strings -fshort-enums -fno-common -Wnested-externs \ + -Wmissing-field-initializers -Wunreachable-code STATIC_CFLAG = -Wl,-prebind -SHARED_CFLAG = +SHARED_CFLAG = -fPIC SHARED_LDFLAG = -dynamic -dynamiclib -fno-common SHARED_INSTALL_NAME = -install_name -ARCH_CFLAG = -W -Wall +ARCH_CFLAG = -W -Wall -Wextra ARCH_LDFLAG = ifeq ($(SUBARCH),64) - ARCH_CFLAG = -W -Wall -arch x86_64 +# -Wconversion + ARCH_CFLAG = -arch x86_64 else ifeq ($(SUBARCH),32) ARCH_CFLAG = -W -Wall -arch i386 Modified: teem/trunk/src/mite/txf.c =================================================================== --- teem/trunk/src/mite/txf.c 2012-09-26 02:29:53 UTC (rev 5660) +++ teem/trunk/src/mite/txf.c 2012-09-26 02:32:32 UTC (rev 5661) @@ -226,8 +226,8 @@ static const char me[]="miteNtxfCheck"; char *rangeStr, *domStr; gageItemSpec isp; - int log2; unsigned int rii, axi; + int ilog2; if (nrrdCheck(ntxf)) { biffMovef(MITE, NRRD, "%s: basic nrrd validity check failed", me); @@ -294,16 +294,16 @@ } if (3 == isp.kind->table[isp.item].answerLength) { /* has to be right length for one of the quantization schemes */ - log2 = airLog2(ntxf->axis[axi].size); - if (-1 == log2) { + ilog2 = airLog2(ntxf->axis[axi].size); + if (-1 == ilog2) { char stmp[AIR_STRLEN_SMALL]; biffAddf(MITE, "%s: txf axis size for %s must be power of 2 (not %s)", me, domStr, airSprintSize_t(stmp, ntxf->axis[axi].size)); return 1; } else { - if (!( AIR_IN_CL(8, log2, 16) )) { + if (!( AIR_IN_CL(8, ilog2, 16) )) { biffAddf(MITE, "%s: log_2 of txf axis size for %s should be in " - "range [8,16] (not %d)", me, domStr, log2); + "range [8,16] (not %d)", me, domStr, ilog2); return 1; } } @@ -543,7 +543,7 @@ _miteStageSet(miteThread *mtt, miteRender *mrr) { static const char me[]="_miteStageSet"; char *value; - int ni, di, stageIdx, rii, stageNum, log2; + int ni, di, stageIdx, rii, stageNum, ilog2; Nrrd *ntxf; miteStage *stage; gageItemSpec isp; @@ -591,8 +591,8 @@ stage->qn = NULL; } else if (3 == isp.kind->table[isp.item].answerLength) { char stmp[AIR_STRLEN_SMALL]; - log2 = airLog2(ntxf->axis[di].size); - switch(log2) { + ilog2 = airLog2(ntxf->axis[di].size); + switch(ilog2) { case 8: stage->qn = limnVtoQN_d[ limnQN8octa]; break; case 9: stage->qn = limnVtoQN_d[ limnQN9octa]; break; case 10: stage->qn = limnVtoQN_d[limnQN10octa]; break; Modified: teem/trunk/src/nrrd/encodingGzip.c =================================================================== --- teem/trunk/src/nrrd/encodingGzip.c 2012-09-26 02:29:53 UTC (rev 5660) +++ teem/trunk/src/nrrd/encodingGzip.c 2012-09-26 02:32:32 UTC (rev 5661) @@ -45,7 +45,7 @@ size_t sizeData, sizeRed, sizeChunk; int error; long int bi; - unsigned int read; + unsigned int didread; char *data; gzFile gzfin; airPtrPtrUnion appu; @@ -93,10 +93,10 @@ required data. Cast on third arg ok because of AIR_MIN use above */ while (!(error = _nrrdGzRead(gzfin, buff + sizeRed, AIR_CAST(unsigned int, sizeChunk), - &read)) - && read > 0) { - sizeRed += read; - if (read >= sizeChunk) { + &didread)) + && didread > 0) { + sizeRed += didread; + if (didread >= sizeChunk) { /* we were able to read as much data as we requested, maybe there is more, so we need to make our temp buffer bigger */ airArrayLenIncr(buffArr, sizeChunk); @@ -127,7 +127,7 @@ for (bi=0; bi<nio->byteSkip; bi++) { unsigned char b; /* Check to see if a single byte was able to be read. */ - if (_nrrdGzRead(gzfin, &b, 1, &read) != 0 || read != 1) { + if (_nrrdGzRead(gzfin, &b, 1, &didread) != 0 || didread != 1) { biffAddf(NRRD, "%s: hit an error skipping byte %ld of %ld", me, bi, nio->byteSkip); return 1; @@ -136,11 +136,11 @@ } /* Pointer to chunks as we read them. */ data = AIR_CAST(char *, _data); - while (!(error = _nrrdGzRead(gzfin, data, sizeChunk, &read)) - && read > 0) { + while (!(error = _nrrdGzRead(gzfin, data, sizeChunk, &didread)) + && didread > 0) { /* Increment the data pointer to the next available chunk. */ - data += read; - sizeRed += read; + data += didread; + sizeRed += didread; /* We only want to read as much data as we need, so we need to check to make sure that we don't request data that might be there but that we don't want. This will reduce sizeChunk when we get to the last Modified: teem/trunk/src/nrrd/filt.c =================================================================== --- teem/trunk/src/nrrd/filt.c 2012-09-26 02:29:53 UTC (rev 5660) +++ teem/trunk/src/nrrd/filt.c 2012-09-26 02:32:32 UTC (rev 5661) @@ -428,11 +428,11 @@ ** returns intersection of parabolas c(x) = spc^2 (x - xi)^2 + yi */ static double -intx(double x0, double y0, double x1, double y1, double spc) { +intx(double xx0, double yy0, double xx1, double yy1, double spc) { double ss; ss = spc*spc; - return (y1/ss + x1*x1 - (y0/ss + x0*x0))/(2*(x1 - x0)); + return (yy1/ss + xx1*xx1 - (yy0/ss + xx0*xx0))/(2*(xx1 - xx0)); } /* Modified: teem/trunk/src/nrrd/gzio.c =================================================================== --- teem/trunk/src/nrrd/gzio.c 2012-09-26 02:29:53 UTC (rev 5660) +++ teem/trunk/src/nrrd/gzio.c 2012-09-26 02:32:32 UTC (rev 5661) @@ -298,7 +298,7 @@ ** Returns the number of bytes actually read (0 for end of file). */ int -_nrrdGzRead(gzFile file, void* buf, unsigned int len, unsigned int* read) { +_nrrdGzRead(gzFile file, void* buf, unsigned int len, unsigned int* didread) { static const char me[]="_nrrdGzRead"; _NrrdGzStream *s = (_NrrdGzStream*)file; Bytef *start = (Bytef*)buf; /* starting point for crc computation */ @@ -306,18 +306,18 @@ if (s == NULL || s->mode != 'r') { biffAddf(NRRD, "%s: invalid stream or file mode", me); - *read = 0; + *didread = 0; return 1; } if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) { biffAddf(NRRD, "%s: data read error", me); - *read = 0; + *didread = 0; return 1; } if (s->z_err == Z_STREAM_END) { - *read = 0; + *didread = 0; return 0; /* EOF */ } @@ -347,7 +347,7 @@ s->stream.total_in += len; s->stream.total_out += len; if (len == 0) s->z_eof = 1; - *read = len; + *didread = len; return 0; } if (s->stream.avail_in == 0 && !s->z_eof) { @@ -394,7 +394,7 @@ } s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); - *read = len - s->stream.avail_out; + *didread = len - s->stream.avail_out; return 0; } Modified: teem/trunk/src/nrrd/nrrd.h =================================================================== --- teem/trunk/src/nrrd/nrrd.h 2012-09-26 02:29:53 UTC (rev 5660) +++ teem/trunk/src/nrrd/nrrd.h 2012-09-26 02:32:32 UTC (rev 5661) @@ -584,13 +584,14 @@ integral, should we renormalize the weights to match the kernel integral so as to remove annoying ripple */ - round, /* when copying from the last intermediate + roundlast, /* when copying from the last intermediate (floating point) result to the output nrrd, for integer outputs, do we round to the nearest integer first, before clamping and assigning. Enabling this fixed the mystery of downsampling large constant regions of 255 (uchar), and - ending up with 254 */ + ending up with 254 + (renamed from "round" to avoid shadowing) */ clamp, /* when copying from the last intermediate (floating point) result to the output nrrd, should we clamp the values to the range of Modified: teem/trunk/src/nrrd/resampleContext.c =================================================================== --- teem/trunk/src/nrrd/resampleContext.c 2012-09-26 02:29:53 UTC (rev 5660) +++ teem/trunk/src/nrrd/resampleContext.c 2012-09-26 02:32:32 UTC (rev 5661) @@ -93,7 +93,7 @@ rsmc->boundary = nrrdDefaultResampleBoundary; rsmc->typeOut = nrrdDefaultResampleType; rsmc->renormalize = nrrdDefaultResampleRenormalize; - rsmc->round = nrrdDefaultResampleRound; + rsmc->roundlast = nrrdDefaultResampleRound; rsmc->clamp = nrrdDefaultResampleClamp; rsmc->defaultCenter = nrrdDefaultCenter; rsmc->nonExistent = nrrdDefaultResampleNonExistent; @@ -502,7 +502,7 @@ int nrrdResampleRoundSet(NrrdResampleContext *rsmc, - int round) { + int roundlast) { static const char me[]="nrrdResampleRoundSet"; if (!rsmc) { @@ -510,8 +510,8 @@ return 1; } - if (rsmc->round != round) { - rsmc->round = round; + if (rsmc->roundlast != roundlast) { + rsmc->roundlast = roundlast; rsmc->flag[flagRound] = AIR_TRUE; } @@ -1110,7 +1110,7 @@ size_t strideIn, strideOut, lineNum, lineIdx, coordIn[NRRD_DIM_MAX], coordOut[NRRD_DIM_MAX]; nrrdResample_t *line, *weight, *rsmpIn, *rsmpOut; - int *index; + int *indx; const void *dataIn; void *dataOut; NrrdResampleAxis *axisIn, *axisOut; @@ -1207,7 +1207,7 @@ } line = (nrrdResample_t *)(axisIn->nline->data); - index = (int *)(axisIn->nindex->data); + indx = (int *)(axisIn->nindex->data); weight = (nrrdResample_t *)(axisIn->nweight->data); /* the skinny */ @@ -1244,7 +1244,7 @@ wsum = 0.0; for (dotIdx=0; dotIdx<dotLen; dotIdx++) { double tmpV, tmpW; - tmpV = line[index[dotIdx + dotLen*smpIdx]]; + tmpV = line[indx[dotIdx + dotLen*smpIdx]]; if (AIR_EXISTS(tmpV)) { tmpW = weight[dotIdx + dotLen*smpIdx]; val += tmpV*tmpW; @@ -1263,7 +1263,7 @@ /* nrrdResampleNonExistentNoop: do convolution sum w/out worries about value existance */ for (dotIdx=0; dotIdx<dotLen; dotIdx++) { - val += (line[index[dotIdx + dotLen*smpIdx]] + val += (line[indx[dotIdx + dotLen*smpIdx]] * weight[dotIdx + dotLen*smpIdx]); } } @@ -1340,7 +1340,7 @@ typeOut = (nrrdTypeDefault == rsmc->typeOut ? rsmc->nin->type : rsmc->typeOut); - doRound = rsmc->round && nrrdTypeIsIntegral[typeOut]; + doRound = rsmc->roundlast && nrrdTypeIsIntegral[typeOut]; if (doRound && (nrrdTypeInt == typeOut || nrrdTypeUInt == typeOut || nrrdTypeLLong == typeOut Modified: teem/trunk/src/nrrd/resampleNrrd.c =================================================================== --- teem/trunk/src/nrrd/resampleNrrd.c 2012-09-26 02:29:53 UTC (rev 5660) +++ teem/trunk/src/nrrd/resampleNrrd.c 2012-09-26 02:32:32 UTC (rev 5661) @@ -298,7 +298,7 @@ const Nrrd *nin, const NrrdResampleInfo *info, unsigned int ai) { static const char me[]="_nrrdResampleMakeWeightIndex"; - int sizeIn, sizeOut, center, dotLen, halfLen, *index, base, idx; + int sizeIn, sizeOut, center, dotLen, halfLen, *indx, base, idx; nrrdResample_t minIn, maxIn, minOut, maxOut, spcIn, spcOut, ratio, support, integral, pos, idxD, wght; nrrdResample_t *weight; @@ -352,8 +352,8 @@ biffAddf(NRRD, "%s: can't allocate weight array", me); *weightP = NULL; *indexP = NULL; return 0; } - index = AIR_CALLOC(sizeOut*dotLen, int); - if (!index) { + indx = AIR_CALLOC(sizeOut*dotLen, int); + if (!indx) { biffAddf(NRRD, "%s: can't allocate index arrays", me); *weightP = NULL; *indexP = NULL; return 0; } @@ -367,8 +367,8 @@ NRRD_IDX(center, minIn, maxIn, sizeIn, pos)); base = (int)floor(idxD) - halfLen + 1; for (e=0; e<dotLen; e++) { - index[e + dotLen*i] = base + e; - weight[e + dotLen*i] = idxD - index[e + dotLen*i]; + indx[e + dotLen*i] = base + e; + weight[e + dotLen*i] = idxD - indx[e + dotLen*i]; } /* ******** if (!i) { @@ -376,7 +376,7 @@ } fprintf(stderr, "%s: %d (sample locations)\n ", me, i); for (e=0; e<dotLen; e++) { - fprintf(stderr, "%d/%g ", index[e + dotLen*i], weight[e + dotLen*i]); + fprintf(stderr, "%d/%g ", indx[e + dotLen*i], weight[e + dotLen*i]); } fprintf(stderr, "\n"); ******** */ @@ -384,7 +384,7 @@ /* figure out what to do with the out-of-range indices */ for (i=0; i<dotLen*sizeOut; i++) { - idx = index[i]; + idx = indx[i]; if (!AIR_IN_CL(0, idx, sizeIn-1)) { switch(info->boundary) { case nrrdBoundaryPad: @@ -405,7 +405,7 @@ me, info->boundary); *weightP = NULL; *indexP = NULL; return 0; } - index[i] = idx; + indx[i] = idx; } } @@ -422,7 +422,7 @@ for (i=0; i<sizeOut; i++) { fprintf(stderr, "%s: %d (sample weights)\n ", me, i); for (e=0; e<dotLen; e++) { - fprintf(stderr, "%d/%g ", index[e + dotLen*i], weight[e + dotLen*i]); + fprintf(stderr, "%d/%g ", indx[e + dotLen*i], weight[e + dotLen*i]); } fprintf(stderr, "\n"); } @@ -436,12 +436,12 @@ for (i=0; i<sizeOut; i++) { wght = 0; for (e=0; e<dotLen; e++) { - if (sizeIn != index[e + dotLen*i]) { + if (sizeIn != indx[e + dotLen*i]) { wght += weight[e + dotLen*i]; } } for (e=0; e<dotLen; e++) { - idx = index[e + dotLen*i]; + idx = indx[e + dotLen*i]; if (sizeIn != idx) { weight[e + dotLen*i] *= integral/wght; } else { @@ -478,7 +478,7 @@ fprintf(stderr, "%s: %d\n ", me, i); wght = 0; for (e=0; e<dotLen; e++) { - fprintf(stderr, "%d/%g ", index[e + dotLen*i], weight[e + dotLen*i]); + fprintf(stderr, "%d/%g ", indx[e + dotLen*i], weight[e + dotLen*i]); wght += weight[e + dotLen*i]; } fprintf(stderr, " (sum = %g)\n", wght); @@ -486,7 +486,7 @@ ******** */ *weightP = weight; - *indexP = index; + *indexP = indx; /* fprintf(stderr, "!%s: dotLen = %d\n", me, dotLen); */ @@ -576,7 +576,7 @@ doRound, /* actually do rounding on output: we DO NOT round when info->round but the output type is not integral */ - *index; /* dotLen*sizeOut 2D array of input indices */ + *indx; /* dotLen*sizeOut 2D array of input indices */ size_t I, /* swiss-army int */ strideIn, /* the stride between samples in the input @@ -750,7 +750,7 @@ airMopAdd(mop, inVec, airFree, airMopAlways); inVec[sizeIn] = AIR_CAST(nrrdResample_t, info->padValue); - dotLen = _nrrdResampleMakeWeightIndex(&weight, &index, &ratio, + dotLen = _nrrdResampleMakeWeightIndex(&weight, &indx, &ratio, nin, info, ai); if (!dotLen) { biffAddf(NRRD, "%s: trouble creating weight and index vector arrays", @@ -759,7 +759,7 @@ } ratios[ai] = ratio; airMopAdd(mop, weight, airFree, airMopAlways); - airMopAdd(mop, index, airFree, airMopAlways); + airMopAdd(mop, indx, airFree, airMopAlways); /* the skinny: resample all the scanlines */ _inVec = array[pi]; @@ -786,10 +786,10 @@ fprintf(stderr, "%s: i = %d (tmpF=0)\n", me, (int)i); */ for (s=0; s<dotLen; s++) { - tmpF += inVec[index[s + dotLen*i]]*weight[s + dotLen*i]; + tmpF += inVec[indx[s + dotLen*i]]*weight[s + dotLen*i]; /* fprintf(stderr, " tmpF += %g*%g == %g\n", - inVec[index[s + dotLen*i]], weight[s + dotLen*i], tmpF); + inVec[indx[s + dotLen*i]], weight[s + dotLen*i], tmpF); */ } _outVec[i*strideOut] = tmpF; @@ -817,10 +817,10 @@ /* pass-specific clean up */ airMopSub(mop, weight, airFree); - airMopSub(mop, index, airFree); + airMopSub(mop, indx, airFree); airMopSub(mop, inVec, airFree); weight = (nrrdResample_t*)airFree(weight); - index = (int*)airFree(index); + indx = (int*)airFree(indx); inVec = (nrrdResample_t*)airFree(inVec); } Modified: teem/trunk/src/pull/parmPull.c =================================================================== --- teem/trunk/src/pull/parmPull.c 2012-09-26 02:29:53 UTC (rev 5660) +++ teem/trunk/src/pull/parmPull.c 2012-09-26 02:32:32 UTC (rev 5661) @@ -491,7 +491,7 @@ ** you can pass in a NULL FILE* if you want */ int -pullLogAddSet(pullContext *pctx, FILE *log) { +pullLogAddSet(pullContext *pctx, FILE *flog) { static const char me[]="pullLogAddSet"; if (!(pctx)) { @@ -499,6 +499,6 @@ return 1; } - pctx->logAdd = log; + pctx->logAdd = flog; return 0; } Modified: teem/trunk/src/ten/tendFiber.c =================================================================== --- teem/trunk/src/ten/tendFiber.c 2012-09-26 02:29:53 UTC (rev 5660) +++ teem/trunk/src/ten/tendFiber.c 2012-09-26 02:32:32 UTC (rev 5661) @@ -282,11 +282,11 @@ if (worldSpaceOut && !worldSpace) { /* have to convert output to worldspace */ unsigned int ii; - double index[4], world[3]; + double indx[4], world[3]; for (ii=0; ii<fiberPld->xyzwNum; ii++) { - ELL_4V_COPY(index, fiberPld->xyzw + 4*ii); - ELL_4V_HOMOG(index, index); - gageShapeItoW(tfx->gtx->shape, world, index); + ELL_4V_COPY(indx, fiberPld->xyzw + 4*ii); + ELL_4V_HOMOG(indx, indx); + gageShapeItoW(tfx->gtx->shape, world, indx); ELL_3V_COPY_TT(fiberPld->xyzw + 4*ii, float, world); (fiberPld->xyzw + 4*ii)[3] = 1.0; } Modified: teem/trunk/src/unrrdu/i2w.c =================================================================== --- teem/trunk/src/unrrdu/i2w.c 2012-09-26 02:29:53 UTC (rev 5660) +++ teem/trunk/src/unrrdu/i2w.c 2012-09-26 02:32:32 UTC (rev 5661) @@ -42,7 +42,7 @@ char *err; int center; - double minPos, maxPos, pos, index, size; + double minPos, maxPos, pos, indx, size; mop = airMopNew(); hestOptAdd(&opt, NULL, "center", airTypeEnum, 1, 1, ¢er, NULL, @@ -58,14 +58,14 @@ "highest position associated with highest index"); hestOptAdd(&opt, NULL, "num", airTypeDouble, 1, 1, &size, NULL, "number of intervals into which position has been quantized"); - hestOptAdd(&opt, NULL, "index", airTypeDouble, 1, 1, &index, NULL, + hestOptAdd(&opt, NULL, "index", airTypeDouble, 1, 1, &indx, NULL, "the input index position, to be converted to world"); airMopAdd(mop, opt, (airMopper)hestOptFree, airMopAlways); USAGE(_unrrdu_i2wInfoL); PARSE(); airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways); - pos = NRRD_POS(center, minPos, maxPos, size, index); + pos = NRRD_POS(center, minPos, maxPos, size, indx); printf("%g\n", pos); airMopOkay(mop); Modified: teem/trunk/src/unrrdu/w2i.c =================================================================== --- teem/trunk/src/unrrdu/w2i.c 2012-09-26 02:29:53 UTC (rev 5660) +++ teem/trunk/src/unrrdu/w2i.c 2012-09-26 02:32:32 UTC (rev 5661) @@ -41,7 +41,7 @@ char *err; int center; - double minPos, maxPos, pos, index, size; + double minPos, maxPos, pos, indx, size; mop = airMopNew(); hestOptAdd(&opt, NULL, "center", airTypeEnum, 1, 1, ¢er, NULL, @@ -64,8 +64,8 @@ PARSE(); airMopAdd(mop, opt, (airMopper)hestParseFree, airMopAlways); - index = NRRD_IDX(center, minPos, maxPos, size, pos); - printf("%g\n", index); + indx = NRRD_IDX(center, minPos, maxPos, size, pos); + printf("%g\n", indx); airMopOkay(mop); return 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |