print_ error dead code

print_ error dead code

Return to topic list

Sat Nov 4 06:00:56 2023   by   Mizuki
All the function print_ error does is a few fprintf lines, does it actually use these arguments?

void print_ error(char *filename, char *ext)
print_ error(do_ file ? filename : "standard output", !do_ file ? "" : file_ ext(file_ type));
 
Sat Nov 4 06:05:48 2023   by   Mizuki
Even gcc itself warns that these arguments are unused...

planet.c: In function ‘print_ error’:
planet.c:2174:24: warning: unused parameter ‘filename’ [-Wunused-parameter]
2174 | void print_ error(char *filename, char *ext)
planet.c:2174:40: warning: unused parameter ‘ext’ [-Wunused-parameter]
2174 | void print_ error(char *filename, char *ext)


 
Mon Nov 6 09:16:27 2023   by   Torben
I think these parameters were added by Jim Burrows for Macintosh, but since they are not used in this function, they can be removed here.  They are used in other places for creating file names for output.
 
Mon Nov 6 09:30:59 2023   by   Mizuki
I see
also this part of the color reading code, is this for loop unused?

nocols = cNum + 1;
if (nocols < 10) nocols = 10;

HIGHEST = nocols - 1;
SEA = (HIGHEST + LOWEST) / 2;
LAND = SEA + 1;

for (i = cNum + 1; i < nocols; i++) {
/* fill up rest of colour table with last read colour */
rtable[i] = rtable[cNum];
gtable[i] = gtable[cNum];
btable[i] = btable[cNum];
}

since nocols is defined as cNum + 1, it becomes (i = nocols; i < nocols; i++)
won't that for loop never run?
 

Return to topic list



New message:
Topic:
Posted by:

Type the values of the dice shown below:

Return to topic list