From 42287213519d1fc5a659206959a928c0f83cdda0 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 5 Feb 2016 14:19:14 -0600 Subject: [PATCH 1/3] Enable running when built with Clang's -fsanitize=address --- src/autosegs.h | 6 ++++-- src/dobjtype.cpp | 2 +- src/doomtype.h | 10 ++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/autosegs.h b/src/autosegs.h index 61872610c..f62632139 100644 --- a/src/autosegs.h +++ b/src/autosegs.h @@ -35,6 +35,8 @@ #ifndef AUTOSEGS_H #define AUTOSEGS_H +#include "doomtype.h" + #define REGMARKER(x) (x) typedef void * const REGINFO; typedef void * NCREGINFO; @@ -73,11 +75,11 @@ class FAutoSegIterator } Probe = Head; } - NCREGINFO operator*() const + NCREGINFO operator*() const NO_SANITIZE { return *Probe; } - FAutoSegIterator &operator++() + FAutoSegIterator &operator++() NO_SANITIZE { do { diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index cc0a077f2..d9af4044a 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -1986,7 +1986,7 @@ END_POINTERS // //========================================================================== -static int STACK_ARGS cregcmp (const void *a, const void *b) +static int STACK_ARGS cregcmp (const void *a, const void *b) NO_SANITIZE { const PClass *class1 = *(const PClass **)a; const PClass *class2 = *(const PClass **)b; diff --git a/src/doomtype.h b/src/doomtype.h index 06541f526..0d9a13ff4 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -113,6 +113,16 @@ typedef TMap FClassMap; #define NOVTABLE #endif +#if defined(__clang__) +#if defined(__has_feature) && __has_feature(address_sanitizer)) +#define NO_SANITIZE __attribute__((no_sanitize("address"))) +#else +#define NO_SANITIZE +#endif +#else +#define NO_SANITIZE +#endif + #include "basictypes.h" // Bounding box coordinate storage. From 26eb3356226c18b7004c33009a9bdc2db42e5ff1 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 5 Feb 2016 16:07:18 -0600 Subject: [PATCH 2/3] Quiet a couple GCC warnings --- src/name.cpp | 2 +- src/p_lnspec.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/name.cpp b/src/name.cpp index 5ab361d42..359f3398c 100644 --- a/src/name.cpp +++ b/src/name.cpp @@ -182,7 +182,7 @@ void FName::NameManager::InitBuckets () // Register built-in names. 'None' must be name 0. for (size_t i = 0; i < countof(PredefinedNames); ++i) { - assert((NULL == FindName(PredefinedNames[i], true)) && "Predefined name already inserted"); + assert((0 == FindName(PredefinedNames[i], true)) && "Predefined name already inserted"); FindName (PredefinedNames[i], false); } } diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 1e1f76923..c74378f61 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -3777,7 +3777,7 @@ int P_ExecuteSpecial(int num, int arg4, int arg5) { - if (num >= 0 && num < countof(LineSpecials)) + if (num >= 0 && num < (int)countof(LineSpecials)) { return LineSpecials[num](line, activator, backSide, arg1, arg2, arg3, arg4, arg5); } From 3ad2e4191dd584153905de8c5597e1df2dc5b25c Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 5 Feb 2016 16:08:20 -0600 Subject: [PATCH 3/3] Remove fudging from the end of (O)WallMost - This might have been added in an effort to fix problems caused by mixing inclusive and exclusive right edges. It might not be needed anymore. Let's find out... --- src/r_segs.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 59bf12b39..96a0595d7 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -520,7 +520,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) wallupper[i] = mceilingclip[i]; } mceilingclip = wallupper; - } + } if (fake3D & FAKE3D_CLIPBOTTOM) { OWallMost(walllower, sclipBottom - viewz, &WallC); @@ -2763,11 +2763,6 @@ int OWallMost (short *mostbuf, fixed_t z, const FWallCoords *wallc) } #endif #endif - if (mostbuf[ix1] < 0) mostbuf[ix1] = 0; - else if (mostbuf[ix1] > viewheight) mostbuf[ix1] = (short)viewheight; - if (mostbuf[ix2-1] < 0) mostbuf[ix2-1] = 0; - else if (mostbuf[ix2-1] > viewheight) mostbuf[ix2-1] = (short)viewheight; - return bad; } @@ -2921,11 +2916,6 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) qinterpolatedown16short (&mostbuf[ix1], ix2-ix1, y + centeryfrac,yinc); } - if (mostbuf[ix1] < 0) mostbuf[ix1] = 0; - else if (mostbuf[ix1] > viewheight) mostbuf[ix1] = (short)viewheight; - if (mostbuf[ix2-1] < 0) mostbuf[ix2-1] = 0; - else if (mostbuf[ix2-1] > viewheight) mostbuf[ix2-1] = (short)viewheight; - return bad; }