Segfault in SDL_DisplayFormat? (sdl 1.2.2)

Yeah. I’d have written (or tried to write) “if(NULL == e_t)” in the first
place, to enable the compiler to catch it if I accidentally missed a "="
such a typo directly.

Of course, gcc with -Wall -Werror is even better, is it would refuse to
compile either version with a single “=” - you need extra parentheses to
get away with such an expression where you really want it. (As in
assignment of function returns to variables inside if() conditions.)

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Tuesday 12 February 2002 02:47, John Popplewell wrote:

Hi,

HUD::HUD() {
e_t = SDL_LoadBMP(“images/energy.bmp”);
if(e_t = NULL) { <-----------------------------
LOG.WRITE(“Could not load e_temp”);
LOG.WRITE(SDL_GetError());
exit(1);
}

If you really only have one ‘=’ sign in that test
then the problem is revealed,

Hi,

HUD::HUD() {
e_t = SDL_LoadBMP(“images/energy.bmp”);
if(e_t = NULL) { <-----------------------------
LOG.WRITE(“Could not load e_temp”);
LOG.WRITE(SDL_GetError());
exit(1);
}

If your compiler did not flag this as a warning, you should check your
settings. You may want to consider having compiler warnings be treated
as errors
if this type of error is slipping past you. You may also want to
consider the technique of using the constant as the first element in
the evaluation so this won’t happen again. Something like this:

if(NULL == e_t)
{

}

Your compiler will generate an error and halt if you substitute an
equals sign.

Doh! (Sorry about that - I’ve been away for two weeks, and there are 379
unread messages in my SDL folder, so I’m having some trouble finding all
replies to a message before I reply to it… heh)

Always pay attention to compiler warnings. They can be ignored only in
very rare situations.

Indeed. I’m currently doing all Kobo Deluxe development with gcc -Wall
-Werror. Not much work getting it to compile, and now it’s much easier to
avoid bugs hinted by warnings. There’s also a chance that the portability
is slightly improved, as I’ve fixed some code that wasn’t valid ANSI C++.

BTW, I had to do some Autoconfig changes to get two of the tests to compile with -Werror! Dunno if they're correct, but It Works Here (TM). (The C test code of the RETSIGTYPE and some other test generate warnings, which become errors, and thus, the results of the test are wrong.)

In there a way to avoid passing the -Werror flag on to the Autoconf
script? Is that the correct way, or are those warnings actually bugs?

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Tuesday 12 February 2002 02:55, Gene Z. Ragan wrote:

BTW, I had to do some Autoconfig changes to get two of the tests to compile with -Werror! Dunno if they're correct, but It Works Here (TM). (The C test code of the RETSIGTYPE and some other test generate warnings, which become errors, and thus, the results of the test are wrong.)

In there a way to avoid passing the -Werror flag on to the Autoconf
script? Is that the correct way, or are those warnings actually bugs?

It is not clear to me what you are doing, but my understanding is that the
test use and sets the CFLAGS, LDFLAGS, LIBS and CPPFLAGS. If you wish to
use special flags for some tests, you’d usually maintain your own set of
"real" flags, and set the other flags appropiatly before each test. When
all tests are done, you would set the CFLAGS, etc to the value of your
real flags.

Dunno if that had anything to do with your question though. :wink:

MadsOn Fri, 1 Mar 2002, David Olofson wrote:


Mads Bondo Dydensborg. @Mads_Bondo_Dydensbor
"'Tis some script kidd3z," I muttered, “tapping at my server
port - Only this, and nothing more.”

                           - Barbarian, /.

Well, I’m just setting CFLAGS and CXXFLAGS when invoking configure on the
command line. Normally, this is not a problem, but when I wanted to skip
the “grepping for compiler warnings” step, it turned that setting them to
"-Wall -Werror" makes some of the Autoconf tests fail.

More specifically, the RETSIGTYPE test failed for the wrong reasons, and
gave me an answer that won’t compile on Linux, and likewise with the test
for an ANSI compliant “const”, which came in conflict with the system C
headers when I tried to pass a callback to qsort().

The warnings (that -Werror turns into errors, thus making the tests fail)
are caused by unused variables and the like - so I just added bogus
"code" to get rid of them. Better than skipping the tests IMHO, but of
course, I can’t be sure that my changes won’t cause other compilers than
GCC to complain for reasons that the autoconf tests aren’t interested
in…

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Friday 01 March 2002 20:14, Mads Bondo Dydensborg wrote:

On Fri, 1 Mar 2002, David Olofson wrote:

BTW, I had to do some Autoconfig changes to get two of the tests to compile with -Werror! Dunno if they're correct, but It Works Here (TM). (The C test code of the RETSIGTYPE and some other test generate warnings, which become errors, and thus, the results of the test are wrong.)

In there a way to avoid passing the -Werror flag on to the Autoconf
script? Is that the correct way, or are those warnings actually bugs?

It is not clear to me what you are doing, but my understanding is that
the test use and sets the CFLAGS, LDFLAGS, LIBS and CPPFLAGS. If you
wish to use special flags for some tests, you’d usually maintain your
own set of “real” flags, and set the other flags appropiatly before
each test. When all tests are done, you would set the CFLAGS, etc to
the value of your real flags.

Dunno if that had anything to do with your question though. :wink: