Skip to content

Commit 4add789

Browse files
committed
some sanitizer warnings
1 parent 58e428f commit 4add789

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

build/build.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,8 @@ echo "#include \"my_config.hpp\"" > $CONFIG_H
441441
C_FLAGS+="-include config.h"
442442
rm -f src/precompiled.hpp.gch
443443

444+
EXTRA_CHECKS=" -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer -fno-common"
445+
444446
#
445447
# for backtraces, but it doesn't help much
446448
#
@@ -501,8 +503,8 @@ case "$MY_OS_NAME" in
501503
DSYM="dsymutil \${TARGET_GAME} &"
502504

503505
if [[ $OPT_DEV2 != "" ]]; then
504-
C_FLAGS+=" -fsanitize=address -fno-omit-frame-pointer"
505-
LDFLAGS+=" -fsanitize=address"
506+
C_FLAGS+="$EXTRA_CHECKS"
507+
LDFLAGS+="$EXTRA_CHECKS"
506508
fi
507509
;;
508510
*inux*)
@@ -511,8 +513,8 @@ case "$MY_OS_NAME" in
511513
LDLIBS+="-lGL "
512514

513515
if [[ $OPT_DEV2 != "" ]]; then
514-
C_FLAGS+=" -fsanitize=address -fno-omit-frame-pointer -fno-common"
515-
LDFLAGS+=" -fsanitize=address"
516+
C_FLAGS+="$EXTRA_CHECKS"
517+
LDFLAGS+="$EXTRA_CHECKS"
516518
fi
517519

518520
pkg-config --print-provides libunwind >/dev/null 2>/dev/null
@@ -562,7 +564,7 @@ if [[ $OPT_REL != "" ]]; then
562564
#
563565
echo "COMPILER_FLAGS=$WERROR $C_FLAGS -O3 -ffast-math -g" > .Makefile
564566
else
565-
echo "COMPILER_FLAGS=$WERROR $C_FLAGS -O0 -g" > .Makefile
567+
echo "COMPILER_FLAGS=$WERROR $C_FLAGS -Og -g" > .Makefile
566568
fi
567569

568570
if [[ $OPT_DEV2 != "" ]]; then
@@ -581,8 +583,9 @@ WARNING_FLAGS+=-Wno-unknown-warning-option
581583
#
582584
# Additional warnings for uninitialized variables; seem to be gcc only
583585
#
586+
WARNING_FLAGS+=-Wuninitialized
584587
WARNING_FLAGS+=-Wmaybe-uninitialized
585-
#WARNING_FLAGS+=-Wuninitialized=verbose
588+
WARNING_FLAGS+=-Wuninitialized=verbose
586589
#WARNING_FLAGS+=-Wunsafe-buffer-usage -fsafe-buffer-usage-suggestions
587590
#
588591
# When compiling C, give string constants the type const char[length] so that copying the address of

src/thing_display_ascii.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,13 @@ void Thing::blit_ascii_adjust_color(color &c, bool fg, bool left_bar)
248248
}
249249
float brightness = 1.0 - (((float) distance_to_player() - 1) / light_dist);
250250

251+
if (brightness < 0) {
252+
brightness = 0;
253+
}
254+
if (brightness > 1) {
255+
brightness = 1;
256+
}
257+
251258
IF_DEBUG2 { brightness = 1.0; }
252259

253260
c.r = ((float) c.r) * brightness;

0 commit comments

Comments
 (0)