]> source.dussan.org Git - tigervnc.git/commitdiff
Enable stream sanity checks in debug builds
authorPierre Ossman <ossman@cendio.se>
Wed, 6 Apr 2022 13:38:45 +0000 (15:38 +0200)
committerPierre Ossman <ossman@cendio.se>
Wed, 6 Apr 2022 13:39:19 +0000 (15:39 +0200)
Enable this automatically for developers so we increase the chance of
these problems getting caught. There is a risk of overhead though so
keep them disabled for release builds.

CMakeLists.txt
common/rdr/InStream.h
win/CMakeLists.txt

index 57de9baa89defbf95c3624955756f5fb9efbbe09..1c6b99fd616d5f87c20379d3ad82c3f9c2373649 100644 (file)
@@ -62,6 +62,11 @@ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -UNDEBUG")
 set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -UNDEBUG")
 set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -UNDEBUG")
 
+# But extra debug checks are still gated by this custom define
+IF(CMAKE_BUILD_TYPE MATCHES Debug)
+  add_definitions(-D_DEBUG)
+ENDIF()
+
 # Make sure we get a sane C version
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
 
index 60ea4997ee3985fac4d6698bbb59b7049994921f..c02e967fc2ce77aad5c5069da696fbd6a13fc320 100644 (file)
@@ -31,7 +31,9 @@
 
 // Check that callers are using InStream properly,
 // useful when writing new protocol handling
-#undef RFB_INSTREAM_CHECK
+#ifdef _DEBUG
+#define RFB_INSTREAM_CHECK
+#endif
 
 namespace rdr {
 
index cd6fc34f9542f2e68cd71235e2e9a68e901fdf3e..951f16ad15959162e429cf3c39cc4568dc9e5749 100644 (file)
@@ -2,10 +2,6 @@ include_directories(${CMAKE_SOURCE_DIR}/common ${CMAKE_SOURCE_DIR}/win)
 
 configure_file(resdefs.h.in ${CMAKE_CURRENT_BINARY_DIR}/resdefs.h)
 
-IF(CMAKE_BUILD_TYPE MATCHES Debug)
-  add_definitions(-D_DEBUG)
-ENDIF()
-
 add_subdirectory(rfb_win32)
 
 if(BUILD_WINVNC)