From 2d3de008f5af27abdae01c92956fa44464aa3f2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Wed, 14 Dec 2022 16:54:01 +0000 Subject: [PATCH] CMake: Disable UTF-8 debug checks for release builds Disable UTF-8 debug checks for release builds for optimization purposes. Also remove unused macro that currently lacks a proper use case. Change version info to be more complete about the build type without being too verbose. --- CMakeLists.txt | 2 +- CMakeOptions.txt | 2 +- ui/version_info.c | 14 ++++++++++---- wsutil/unicode-utils.h | 10 ---------- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3364b79e72..b38a12c752 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -459,7 +459,7 @@ set_property(DIRECTORY "G_DISABLE_SINGLE_INCLUDES" $<$>,$>:WS_DISABLE_ASSERT> $<$>,$>:WS_DISABLE_DEBUG> - $<$:WS_DEBUG_UTF_8> + $<$,$>:WS_DEBUG_UTF_8> ) if(WIN32) diff --git a/CMakeOptions.txt b/CMakeOptions.txt index eaa1347fa2..daa0356c95 100644 --- a/CMakeOptions.txt +++ b/CMakeOptions.txt @@ -54,7 +54,7 @@ option(BUILD_fuzzshark "Build fuzzshark" OFF) option(ENABLE_WERROR "Treat warnings as errors" ON) option(ENABLE_DEBUG "Enable debug code" ON) option(ENABLE_ASSERT "Enable assertions" ON) -option(ENABLE_DEBUG_MBS "Enable extra debug checks for detecting invalid multibyte (UTF-8) strings" ON) +option(ENABLE_DEBUG_MBS "Enable extra debug checks for detecting invalid multibyte (UTF-8) strings" OFF) option(ENABLE_DEBUG_A2W "Enable line directive from .cnf file" OFF) option(ENABLE_CCACHE "Speed up compiling and linking using ccache if possible" OFF) diff --git a/ui/version_info.c b/ui/version_info.c index 40b1950614..f7adb2753e 100644 --- a/ui/version_info.c +++ b/ui/version_info.c @@ -208,18 +208,24 @@ get_compiled_version_info(gather_feature_func gather_compile) #endif #ifdef WS_DISABLE_DEBUG - g_string_append(str, ", release build"); + g_string_append(str, ", release build ("); +#else + g_string_append(str, ", debug build ("); #endif #ifdef WS_DISABLE_ASSERT - g_string_append(str, ", without assertions"); + g_string_append(str, "-assert"); +#else + g_string_append(str, "+assert"); #endif #ifdef WS_DEBUG_UTF_8 - g_string_append(str, ", with UTF-8 validation"); + g_string_append(str, " +utf8"); +#else + g_string_append(str, " -utf8"); #endif - g_string_append(str, "."); + g_string_append(str, ")."); end_string(str); free_features(&l); diff --git a/wsutil/unicode-utils.h b/wsutil/unicode-utils.h index 049f0dd1cd..cacb606b4d 100644 --- a/wsutil/unicode-utils.h +++ b/wsutil/unicode-utils.h @@ -49,16 +49,6 @@ extern "C" { #define WS_UTF_8_DEBUG_HERE(str, len) \ _CHECK_UTF_8(LOG_LEVEL_ECHO, str, len) -#define WS_UTF_8_SANITIZE_STRBUF(buf) \ - do { \ - const char *__uni_endptr; \ - if (!wmem_strbuf_utf8_validate(buf, &__uni_endptr)) { \ - ws_log_utf8(buf->str, buf->len, __uni_endptr); \ - wmem_strbuf_utf8_make_valid(buf); \ - } \ - } while (0) - - WSUTIL_EXPORT int ws_utf8_seqlen[256];