15 Sep, 2013, Michael wrote in the 1st comment:
Votes: 0
I have the webwho snippet installed and it works great. However, if I compile under gcc-3.4 it compiles error free, when I try to use GCC 4.1 it gives me the following error:

Compiling –> o/websrv.o…
cc1: warnings being treated as errors
websrv.c: In function add_linebreaks:
websrv.c:912: warning: value computed is not used
make[1]: *** [o/websrv.o] Error 1
make: *** [all] Error 2


The add_linebreaks code is as follows:

void add_linebreaks( char *buffer, char const *txt )
{
const char *i;
for( i = txt; *i; *i++ ) <—- Line 912
{
if( *i == '\n' )
{
*buffer = '<';
*++buffer = 'b';
*++buffer = 'r';
*++buffer = '>';
*++buffer = '\0';
}
*buffer = *i;
*++buffer = '\0';
}
*buffer = '\0';
return;
}


I don't really know what I can do to avoid the error. Any help would be appreciated. I am sure its a simple fix.
15 Sep, 2013, Tyche wrote in the 2nd comment:
Votes: 0
Should be this:
for( i = txt; *i; i++ )

But there's much more munged up in that function.
Need to look at the context in which it's called.
15 Sep, 2013, Zeno wrote in the 3rd comment:
Votes: 0
There's actually no error, just a warning. But you're compiling in a way that forces warnings to be errors, and does not end up compiling.
15 Sep, 2013, Michael wrote in the 4th comment:
Votes: 0
Thank you for the quick response Tyche. This allowed the code to compile without the error. I realize the code is pretty messy. All it does it add the <br> to the end of each line in a help file to allow it to look right on the website. Functions like this are not something I am good with. I also didn't write it. But again, I thank you very much.
15 Sep, 2013, Michael wrote in the 5th comment:
Votes: 0
Quote
There's actually no error, just a warning. But you're compiling in a way that forces warnings to be errors, and does not end up compiling.


I have -Werror enabled in my Makefile. I like knowing that my code doesn't have any unused variables or simple problems like that. The add_linebreaks was the last warning standing in my way between a clean compile under GCC-4.1. Tyche's fix cleared the problem up and everything still works properly.
15 Sep, 2013, Tyche wrote in the 6th comment:
Votes: 0
I'd do something like this.
void add_linebreaks( char *buffer, char const *txt )
{
const char *i;
for( i = txt; *i; i++ )
{
if( *i == '\n' )
{
*buffer = '<';
*++buffer = 'b';
*++buffer = 'r';
*++buffer = '>';
} else {
*buffer = *i;
}
buffer++;
}
*buffer = '\0';
return;
}

It's just that it was more complicated than it needed to be.
0.0/6