diff options
author | Alex Cherepanov <alex.cherepanov@artifex.com> | 2012-04-24 10:15:59 -0400 |
---|---|---|
committer | Alex Cherepanov <alex.cherepanov@artifex.com> | 2012-04-24 10:15:59 -0400 |
commit | c2a982ffda019b2822799a918d53022ec06342fa (patch) | |
tree | bd948ec563fe3582bde4d72776a0f8c647a47d07 | |
parent | f10560765a226f668b72fd9b8298d644cbce08ab (diff) |
Pacify Valgrind: don't calculate unused values from undefined data.
-rw-r--r-- | gs/lcms2/src/cmsopt.c | 93 |
1 files changed, 48 insertions, 45 deletions
diff --git a/gs/lcms2/src/cmsopt.c b/gs/lcms2/src/cmsopt.c index 1b0d33e7c..9a4e0b924 100644 --- a/gs/lcms2/src/cmsopt.c +++ b/gs/lcms2/src/cmsopt.c @@ -383,58 +383,61 @@ cmsBool PatchLUT(cmsStage* CLUT, cmsUInt16Number At[], cmsUInt16Number Value[], return FALSE; } - px = ((cmsFloat64Number) At[0] * (p16->Domain[0])) / 65535.0; - py = ((cmsFloat64Number) At[1] * (p16->Domain[1])) / 65535.0; - pz = ((cmsFloat64Number) At[2] * (p16->Domain[2])) / 65535.0; - pw = ((cmsFloat64Number) At[3] * (p16->Domain[3])) / 65535.0; - - x0 = (int) floor(px); - y0 = (int) floor(py); - z0 = (int) floor(pz); - w0 = (int) floor(pw); - - if (nChannelsIn == 4) { - - if (((px - x0) != 0) || - ((py - y0) != 0) || - ((pz - z0) != 0) || - ((pw - w0) != 0)) return FALSE; // Not on exact node - - index = p16 -> opta[3] * x0 + - p16 -> opta[2] * y0 + - p16 -> opta[1] * z0 + - p16 -> opta[0] * w0; - } - else - if (nChannelsIn == 3) { + switch (nChannelsIn) { + case 4: + px = ((cmsFloat64Number) At[0] * (p16->Domain[0])) / 65535.0; + x0 = (int) floor(px); + py = ((cmsFloat64Number) At[1] * (p16->Domain[1])) / 65535.0; + y0 = (int) floor(py); + pz = ((cmsFloat64Number) At[2] * (p16->Domain[2])) / 65535.0; + z0 = (int) floor(pz); + pw = ((cmsFloat64Number) At[3] * (p16->Domain[3])) / 65535.0; + w0 = (int) floor(pw); if (((px - x0) != 0) || ((py - y0) != 0) || - ((pz - z0) != 0)) return FALSE; // Not on exact node - - index = p16 -> opta[2] * x0 + - p16 -> opta[1] * y0 + - p16 -> opta[0] * z0; - } - else - if (nChannelsIn == 1) { - - if (((px - x0) != 0)) return FALSE; // Not on exact node - - index = p16 -> opta[0] * x0; - } - else { - cmsSignalError(CLUT->ContextID, cmsERROR_INTERNAL, "(internal) %d Channels are not supported on PatchLUT", nChannelsIn); - return FALSE; - } + ((pz - z0) != 0) || + ((pw - w0) != 0)) return FALSE; // Not on exact node + + index = p16 -> opta[3] * x0 + + p16 -> opta[2] * y0 + + p16 -> opta[1] * z0 + + p16 -> opta[0] * w0; + break; + case 3: + px = ((cmsFloat64Number) At[0] * (p16->Domain[0])) / 65535.0; + x0 = (int) floor(px); + py = ((cmsFloat64Number) At[1] * (p16->Domain[1])) / 65535.0; + y0 = (int) floor(py); + pz = ((cmsFloat64Number) At[2] * (p16->Domain[2])) / 65535.0; + z0 = (int) floor(pz); + if (((px - x0) != 0) || + ((py - y0) != 0) || + ((pz - z0) != 0)) return FALSE; // Not on exact node + + index = p16 -> opta[2] * x0 + + p16 -> opta[1] * y0 + + p16 -> opta[0] * z0; + break; + case 1: + px = ((cmsFloat64Number) At[0] * (p16->Domain[0])) / 65535.0; + x0 = (int) floor(px); + if (((px - x0) != 0)) return FALSE; // Not on exact node + index = p16 -> opta[0] * x0; + break; + default: + cmsSignalError(CLUT->ContextID, cmsERROR_INTERNAL, "(internal) %d Channels are not supported on PatchLUT", nChannelsIn); + return FALSE; + } - for (i=0; i < nChannelsOut; i++) - Grid -> Tab.T[index + i] = Value[i]; + for (i=0; i < nChannelsOut; i++) + Grid -> Tab.T[index + i] = Value[i]; - return TRUE; + return TRUE; } -// Auxiliar, to see if two values are equal or very different + +// Auxiliary, to see if two values are equal or very different static cmsBool WhitesAreEqual(int n, cmsUInt16Number White1[], cmsUInt16Number White2[] ) { |