I've had alook at them, and most of them are harmless, in the sense that they are telling us that we have some result we're not using. Generally, the variables are pointers or ints assigned the return value of a system call (fgets(), system(), or similar).
When debugging, it is interesting to look at those values, even if we aren't actually using them in the code.
A couple of the warnings are more sinister, though.
Code:
gcc -g -O2 -Wall -Wno-char-subscripts -c -o act.item.o act.item.c
act.item.c: In function ‘do_drink’:
act.item.c:883:61: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]
if ((GET_OBJ_VAL(temp, 1) == 0) || (!GET_OBJ_VAL(temp, 0) == 1)) {
Which is obviously a bug (the !x == 1 should be x != 1), and
Code:
gcc -g -O2 -Wall -Wno-char-subscripts -c -o dg_olc.o dg_olc.c
dg_olc.c: In function ‘script_syntax_highlighting’:
dg_olc.c:464:24: warning: iteration 35u invokes undefined behavior [-Waggressive-loop-optimizations]
line = str_replace(line, command_color_replacement[i][0], command_color_replacement[i][1]);
^
dg_olc.c:463:13: note: containing loop
for (i=0;i <= COMMAND_TERMS;i++) {
^
dg_olc.c:459:24: warning: iteration 49u invokes undefined behavior [-Waggressive-loop-optimizations]
line = str_replace(line, syntax_color_replacement[i][0], syntax_color_replacement[i][1]);
^
dg_olc.c:458:13: note: containing loop
for (i=0;i <= SYNTAX_TERMS;i++) {
^
which is a more subtle bug - off-by-one.
Because the compiler can determine everything that is happening in this function it will unwind it - making it faster. In the process, it determines that at the end of the loops, we are trying to dereference unassigned memory.
The fix is simple enough - use < instead of <= when comparing in the loops.
I have pushed those changesto tbamud master branch on github.