Bug Summary

File:src/dye/methodsDye.c
Location:line 211, column 3
Description:Value stored to 'str' is never read

Annotated Source Code

1/*
2 Teem: Tools to process and visualize scientific data and images .
3 Copyright (C) 2013, 2012, 2011, 2010, 2009 University of Chicago
4 Copyright (C) 2008, 2007, 2006, 2005 Gordon Kindlmann
5 Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998 University of Utah
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public License
9 (LGPL) as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11 The terms of redistributing and/or modifying this software also
12 include exceptions to the LGPL that facilitate static linking.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with this library; if not, write to Free Software Foundation, Inc.,
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22*/
23
24
25#include "dye.h"
26
27const int
28dyePresent = 42;
29
30const char *
31dyeBiffKey = "dye";
32
33const char *
34dyeSpaceToStr[DYE_MAX_SPACE7+1] = {
35 "(unknown)",
36 "HSV",
37 "HSL",
38 "RGB",
39 "XYZ",
40 "LAB",
41 "LUV",
42 "LCH"
43};
44
45static const char *
46_dyeSpaceDesc[DYE_MAX_SPACE7+1] = {
47 "unknown colorspace",
48 "single hexcone",
49 "double hexcone",
50 "traditional device primaries",
51 "CIE 1931 XYZ space",
52 "CIE L*a*b*",
53 "CIE 1976 L*u*v*",
54 "polar coord(L*a*b*)"
55};
56
57static const airEnum
58_dyeSpace = {
59 "colorspace",
60 DYE_MAX_SPACE7,
61 dyeSpaceToStr, NULL((void*)0),
62 _dyeSpaceDesc,
63 NULL((void*)0), NULL((void*)0),
64 AIR_FALSE0
65};
66const airEnum *const
67dyeSpace = &_dyeSpace;
68
69/*
70** this function predates the dyeSpace airEnum, so we'll keep it.
71*/
72int
73dyeStrToSpace(char *_str) {
74 int spc;
75 char *str;
76
77 spc = dyeSpaceUnknown;
78 if ( (str = airStrdup(_str)) ) {
79 airToUpper(str);
80 for (spc=0; spc<dyeSpaceLast; spc++) {
81 if (!strcmp(str, dyeSpaceToStr[spc])) {
82 break;
83 }
84 }
85 if (dyeSpaceLast == spc) {
86 spc = dyeSpaceUnknown;
87 }
88 str = (char *)airFree(str);
89 }
90 return spc;
91}
92
93dyeColor *
94dyeColorInit(dyeColor *col) {
95
96 if (col) {
97 ELL_3V_SET(col->val[0], AIR_NAN, AIR_NAN, AIR_NAN)((col->val[0])[0] = ((airFloatQNaN.f)), (col->val[0])[1
] = ((airFloatQNaN.f)), (col->val[0])[2] = ((airFloatQNaN.
f)))
;
98 ELL_3V_SET(col->val[1], AIR_NAN, AIR_NAN, AIR_NAN)((col->val[1])[0] = ((airFloatQNaN.f)), (col->val[1])[1
] = ((airFloatQNaN.f)), (col->val[1])[2] = ((airFloatQNaN.
f)))
;
99 col->xWhite = col->yWhite = AIR_NAN(airFloatQNaN.f);
100 col->spc[0] = dyeSpaceUnknown;
101 col->spc[1] = dyeSpaceUnknown;
102 col->ii = 0;
103 }
104 return col;
105}
106
107dyeColor *
108dyeColorSet(dyeColor *col, int space, float v0, float v1, float v2) {
109
110 if (col && DYE_VALID_SPACE(space)(((dyeSpaceUnknown) < ((space)) && ((space)) < (
dyeSpaceLast)))
) {
111 col->ii = AIR_CLAMP(0, col->ii, 1)((col->ii) < (0) ? (0) : ((col->ii) > (1) ? (1) :
(col->ii)))
;
112
113 /* We switch to the other one if the current one seems to be used,
114 but we don't switch if new and current colorspaces are the same.
115 If the other one is being used too, oh well. */
116 if (dyeSpaceUnknown != col->spc[col->ii] &&
117 AIR_EXISTS(col->val[col->ii][0])(((int)(!((col->val[col->ii][0]) - (col->val[col->
ii][0])))))
&&
118 col->spc[col->ii] != space) {
119 col->ii = 1 - col->ii;
120 }
121
122 ELL_3V_SET(col->val[col->ii], v0, v1, v2)((col->val[col->ii])[0] = (v0), (col->val[col->ii
])[1] = (v1), (col->val[col->ii])[2] = (v2))
;
123 col->spc[col->ii] = space;
124 }
125 return col;
126}
127
128int
129dyeColorGet(float *v0P, float *v1P, float *v2P, dyeColor *col) {
130 int spc;
131
132 spc = dyeSpaceUnknown;
133 if (v0P && v1P && v2P && col) {
134 col->ii = AIR_CLAMP(0, col->ii, 1)((col->ii) < (0) ? (0) : ((col->ii) > (1) ? (1) :
(col->ii)))
;
135 spc = col->spc[col->ii];
136 ELL_3V_GET(*v0P, *v1P, *v2P, col->val[col->ii])((*v0P) = (col->val[col->ii])[0], (*v1P) = (col->val
[col->ii])[1], (*v2P) = (col->val[col->ii])[2])
;
137 }
138 return spc;
139}
140
141int
142dyeColorGetAs(float *v0P, float *v1P, float *v2P,
143 dyeColor *colIn, int space) {
144 dyeColor _col, *col;
145
146 col = &_col;
147 dyeColorCopy(col, colIn);
148 /* hope for no error */
149 dyeConvert(col, space);
150 return dyeColorGet(v0P, v1P, v2P, col);
151}
152
153dyeColor *
154dyeColorNew() {
155 dyeColor *col;
156
157 col = (dyeColor *)calloc(1, sizeof(dyeColor));
158 col = dyeColorInit(col);
159 return col;
160}
161
162dyeColor *
163dyeColorCopy(dyeColor *c1, dyeColor *c0) {
164
165 if (c1 && c0) {
166 memcpy(c1, c0, sizeof(dyeColor))__builtin___memcpy_chk (c1, c0, sizeof(dyeColor), __builtin_object_size
(c1, 0))
;
167 }
168 return c1;
169}
170
171dyeColor *
172dyeColorNix(dyeColor *col) {
173
174 if (col) {
175 col = (dyeColor *)airFree(col);
176 }
177 return NULL((void*)0);
178}
179
180int
181dyeColorParse(dyeColor *col, char *_str) {
182 static const char me[]="dyeColorParse";
183 char *str;
184 char *colon, *valS;
185 float v0, v1, v2;
186 int spc;
187
188 if (!(col && _str)) {
189 biffAddf(DYEdyeBiffKey, "%s: got NULL pointer", me);
190 return 1;
191 }
192 if (!(str = airStrdup(_str))) {
193 biffAddf(DYEdyeBiffKey, "%s: couldn't strdup!", me);
194 return 1;
195 }
196 if (!(colon = strchr(str, ':'))) {
197 biffAddf(DYEdyeBiffKey, "%s: given string \"%s\" didn't contain colon", me, str);
198 return 1;
199 }
200 *colon = '\0';
201 valS = colon+1;
202 if (3 != sscanf(valS, "%g,%g,%g", &v0, &v1, &v2)) {
203 biffAddf(DYEdyeBiffKey, "%s: couldn't parse three floats from \"%s\"", me, valS);
204 return 1;
205 }
206 spc = dyeStrToSpace(str);
207 if (dyeSpaceUnknown == spc) {
208 biffAddf(DYEdyeBiffKey, "%s: couldn't parse colorspace from \"%s\"", me, str);
209 return 1;
210 }
211 str = (char *)airFree(str);
Value stored to 'str' is never read
212
213 dyeColorSet(col, spc, v0, v1, v2);
214 return 0;
215}
216
217char *
218dyeColorSprintf(char *str, dyeColor *col) {
219
220 if (str && col) {
221 col->ii = AIR_CLAMP(0, col->ii, 1)((col->ii) < (0) ? (0) : ((col->ii) > (1) ? (1) :
(col->ii)))
;
222 sprintf(str, "%s:%g,%g,%g", dyeSpaceToStr[col->spc[col->ii]],__builtin___sprintf_chk (str, 0, __builtin_object_size (str, 2
> 1 ? 1 : 0), "%s:%g,%g,%g", dyeSpaceToStr[col->spc[col
->ii]], col->val[col->ii][0], col->val[col->ii
][1], col->val[col->ii][2])
223 col->val[col->ii][0],__builtin___sprintf_chk (str, 0, __builtin_object_size (str, 2
> 1 ? 1 : 0), "%s:%g,%g,%g", dyeSpaceToStr[col->spc[col
->ii]], col->val[col->ii][0], col->val[col->ii
][1], col->val[col->ii][2])
224 col->val[col->ii][1],__builtin___sprintf_chk (str, 0, __builtin_object_size (str, 2
> 1 ? 1 : 0), "%s:%g,%g,%g", dyeSpaceToStr[col->spc[col
->ii]], col->val[col->ii][0], col->val[col->ii
][1], col->val[col->ii][2])
225 col->val[col->ii][2])__builtin___sprintf_chk (str, 0, __builtin_object_size (str, 2
> 1 ? 1 : 0), "%s:%g,%g,%g", dyeSpaceToStr[col->spc[col
->ii]], col->val[col->ii][0], col->val[col->ii
][1], col->val[col->ii][2])
;
226 }
227 return str;
228}