Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable and Resolve [-Wzero-as-null-pointer-constant] #11709

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 54 additions & 54 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ endif()
if(ENABLE_VTUNE)
set(VTUNE_DIR "/opt/intel/vtune_amplifier")
add_definitions(-DUSE_VTUNE)
include_directories("${VTUNE_DIR}/include")
include_directories(SYSTEM "${VTUNE_DIR}/include")
set(VTUNE_LIBRARIES
"${VTUNE_DIR}/lib64/libjitprofiling.a"
"${VTUNE_DIR}/lib64/libittnotify.a"
Expand Down Expand Up @@ -533,7 +533,7 @@ set(OpenGL_GL_PREFERENCE GLVND CACHE STRING "Linux-only: if GLVND, use the vendo
set_property(CACHE OpenGL_GL_PREFERENCE PROPERTY STRINGS GLVND LEGACY)
find_package(OpenGL)
if (OPENGL_GL)
include_directories(${OPENGL_INCLUDE_DIR})
include_directories(SYSTEM ${OPENGL_INCLUDE_DIR})
endif()

if(ENABLE_X11)
Expand Down Expand Up @@ -636,7 +636,7 @@ if(ENABLE_SDL)
set(SDL_TEST OFF)
set(SDL_TEST_ENABLED_BY_DEFAULT OFF)
set(OPT_DEF_LIBC ON)
add_subdirectory(Externals/SDL/SDL)
add_subdirectory(Externals/SDL/SDL SYSTEM)
if (TARGET SDL2)
dolphin_disable_warnings_msvc(SDL2)
endif()
Expand Down Expand Up @@ -682,32 +682,32 @@ endif()
# Externals/zlib/CMakeLists.txt (that is: NOT in some Src/ subdirectory)
#
if (_M_X86)
add_subdirectory(Externals/Bochs_disasm)
add_subdirectory(Externals/Bochs_disasm SYSTEM)
endif()
add_subdirectory(Externals/cpp-optparse)
add_subdirectory(Externals/cpp-optparse SYSTEM)

find_package(fmt 8)
if(fmt_FOUND)
message(STATUS "Using shared fmt ${fmt_VERSION}")
else()
check_vendoring_approved(fmt)
message(STATUS "Using static fmt from Externals")
add_subdirectory(Externals/fmt EXCLUDE_FROM_ALL)
add_subdirectory(Externals/fmt EXCLUDE_FROM_ALL SYSTEM)
endif()
add_subdirectory(Externals/imgui)
add_subdirectory(Externals/implot)
add_subdirectory(Externals/glslang)
add_subdirectory(Externals/imgui SYSTEM)
add_subdirectory(Externals/implot SYSTEM)
add_subdirectory(Externals/glslang SYSTEM)
# SPIRV-Cross is used on Windows for GLSL to HLSL conversion for the Direct3D 11 and Direct3D 12
# video backends, and on Apple devices for the Metal video backend.
if(WIN32 OR APPLE)
add_subdirectory(Externals/spirv_cross)
add_subdirectory(Externals/spirv_cross SYSTEM)
endif()

if(ENABLE_VULKAN)
add_definitions(-DHAS_VULKAN)

if(APPLE AND USE_BUNDLED_MOLTENVK)
add_subdirectory(Externals/MoltenVK)
add_subdirectory(Externals/MoltenVK SYSTEM)
endif()
endif()

Expand All @@ -720,7 +720,7 @@ find_package(pugixml)
if(NOT pugixml_FOUND)
check_vendoring_approved(pugixml)
message(STATUS "Using static pugixml from Externals")
add_subdirectory(Externals/pugixml)
add_subdirectory(Externals/pugixml SYSTEM)
endif()

if(USE_SHARED_ENET)
Expand All @@ -747,13 +747,13 @@ if (ENET_FOUND)
else()
check_vendoring_approved(enet)
message(STATUS "Using static enet from Externals")
include_directories(Externals/enet/include)
add_subdirectory(Externals/enet)
include_directories(SYSTEM Externals/enet/include)
add_subdirectory(Externals/enet SYSTEM)
endif()

if(NOT XXHASH_FOUND)
message(STATUS "Using static xxhash from Externals")
add_subdirectory(Externals/xxhash)
add_subdirectory(Externals/xxhash SYSTEM)
endif()

find_package(BZip2)
Expand All @@ -762,7 +762,7 @@ if(BZIP2_FOUND)
else()
check_vendoring_approved(bzip2)
message(STATUS "Shared bzip2 not found, falling back to the static library")
add_subdirectory(Externals/bzip2)
add_subdirectory(Externals/bzip2 SYSTEM)
endif()

# macOS ships with liblzma.dylib but no headers, so check for the headers too
Expand All @@ -774,7 +774,7 @@ if(LIBLZMA_FOUND)
else()
check_vendoring_approved(lzma)
message(STATUS "Shared lzma not found, falling back to the static library")
add_subdirectory(Externals/liblzma)
add_subdirectory(Externals/liblzma SYSTEM)
endif()

pkg_check_modules(ZSTD QUIET libzstd>=1.4.0 IMPORTED_TARGET)
Expand All @@ -784,20 +784,20 @@ if(ZSTD_FOUND)
else()
check_vendoring_approved(zstd)
message(STATUS "Shared zstd not found, falling back to the static library")
add_subdirectory(Externals/zstd)
add_subdirectory(Externals/zstd SYSTEM)
endif()

add_subdirectory(Externals/zlib-ng)
add_subdirectory(Externals/zlib-ng SYSTEM)

pkg_check_modules(MINIZIP minizip>=3.0.0)
if(MINIZIP_FOUND)
message(STATUS "Using shared minizip")
include_directories(${MINIZIP_INCLUDE_DIRS})
include_directories(SYSTEM ${MINIZIP_INCLUDE_DIRS})
else()
check_vendoring_approved(minizip)
message(STATUS "Shared minizip not found, falling back to the static library")
add_subdirectory(Externals/minizip)
include_directories(External/minizip)
add_subdirectory(Externals/minizip SYSTEM)
include_directories(SYSTEM External/minizip)
endif()

if(NOT APPLE)
Expand All @@ -808,7 +808,7 @@ if(LZO_FOUND)
else()
check_vendoring_approved(lzo)
message(STATUS "Using static lzo from Externals")
add_subdirectory(Externals/LZO)
add_subdirectory(Externals/LZO SYSTEM)
set(LZO lzo2)
endif()

Expand All @@ -818,33 +818,33 @@ if (pc_spng_FOUND AND TARGET PkgConfig::pc_spng)
set(spng_target PkgConfig::pc_spng)
else()
message(STATUS "Using static libspng from Externals")
add_subdirectory(Externals/libspng)
add_subdirectory(Externals/libspng SYSTEM)
set(spng_target spng)
endif()

# Using static FreeSurround from Externals
# There is no system FreeSurround library.
message(STATUS "Using static FreeSurround from Externals")
add_subdirectory(Externals/FreeSurround)
add_subdirectory(Externals/FreeSurround SYSTEM)

if (APPLE OR WIN32)
message(STATUS "Using ed25519 from Externals")
add_subdirectory(Externals/ed25519)
include_directories(Externals/ed25519)
add_subdirectory(Externals/ed25519 SYSTEM)
include_directories(SYSTEM Externals/ed25519)
endif()

# Using static soundtouch from Externals
# Unable to use system soundtouch library: We require shorts, not floats.
add_subdirectory(Externals/soundtouch)
include_directories(Externals/soundtouch)
add_subdirectory(Externals/soundtouch SYSTEM)
include_directories(SYSTEM Externals/soundtouch)

find_package(CUBEB)
if(CUBEB_FOUND)
message(STATUS "Using the system cubeb")
else()
check_vendoring_approved(cubeb)
message(STATUS "Using static cubeb from Externals")
add_subdirectory(Externals/cubeb EXCLUDE_FROM_ALL)
add_subdirectory(Externals/cubeb EXCLUDE_FROM_ALL SYSTEM)
endif()

if(NOT ANDROID)
Expand All @@ -854,11 +854,11 @@ if(NOT ANDROID)
endif()
if(LIBUSB_FOUND AND NOT APPLE)
message(STATUS "Using shared LibUSB")
include_directories(${LIBUSB_INCLUDE_DIR})
include_directories(SYSTEM ${LIBUSB_INCLUDE_DIR})
else()
check_vendoring_approved(libusb)
message(STATUS "Using static LibUSB from Externals")
add_subdirectory(Externals/libusb)
add_subdirectory(Externals/libusb SYSTEM)
set(LIBUSB_LIBRARIES usb)
endif()
set(LIBUSB_FOUND true)
Expand All @@ -874,8 +874,8 @@ else()
check_vendoring_approved(sfml)
message(STATUS "Using static SFML ${SFML_REQD_VERSION} from Externals")
add_definitions(-DSFML_STATIC)
add_subdirectory(Externals/SFML)
include_directories(BEFORE Externals/SFML/include)
add_subdirectory(Externals/SFML SYSTEM)
include_directories(BEFORE SYSTEM Externals/SFML/include)
endif()

if(USE_UPNP)
Expand All @@ -887,7 +887,7 @@ if(USE_UPNP)
else()
check_vendoring_approved(miniupnpc)
message(STATUS "Using static miniupnpc from Externals")
add_subdirectory(Externals/miniupnpc)
add_subdirectory(Externals/miniupnpc SYSTEM)
endif()
add_definitions(-DUSE_UPNP)
endif()
Expand All @@ -897,25 +897,25 @@ if(NOT APPLE)
endif()
if(MBEDTLS_FOUND)
message(STATUS "Using shared mbed TLS")
include_directories(${MBEDTLS_INCLUDE_DIRS})
include_directories(SYSTEM ${MBEDTLS_INCLUDE_DIRS})
else()
check_vendoring_approved(mbedtls)
message(STATUS "Using static mbed TLS from Externals")
set(MBEDTLS_LIBRARIES mbedtls mbedcrypto mbedx509)
add_subdirectory(Externals/mbedtls/ EXCLUDE_FROM_ALL)
include_directories(Externals/mbedtls/include)
add_subdirectory(Externals/mbedtls/ EXCLUDE_FROM_ALL SYSTEM)
include_directories(SYSTEM Externals/mbedtls/include)
endif()

find_package(CURL)
if(CURL_FOUND)
message(STATUS "Using shared libcurl")
include_directories(${CURL_INCLUDE_DIRS})
include_directories(SYSTEM ${CURL_INCLUDE_DIRS})
else()
check_vendoring_approved(curl)
message(STATUS "Using static libcurl from Externals")
add_subdirectory(Externals/curl)
add_subdirectory(Externals/curl SYSTEM)
set(CURL_LIBRARIES curl)
include_directories(BEFORE Externals/curl/include)
include_directories(BEFORE SYSTEM Externals/curl/include)
endif()

if (NOT ANDROID)
Expand All @@ -928,8 +928,8 @@ if (NOT ANDROID AND ICONV_LIBRARIES AND ICONV_INCLUDE_DIR)
else()
check_vendoring_approved(iconv)
message(STATUS "Using static iconv from Externals")
include_directories(Externals/libiconv-1.14/include)
add_subdirectory(Externals/libiconv-1.14)
include_directories(SYSTEM Externals/libiconv-1.14/include)
add_subdirectory(Externals/libiconv-1.14 SYSTEM)
set(ICONV_LIBRARIES iconv)
endif()

Expand All @@ -938,14 +938,14 @@ if(NOT ANDROID)
if(NOT HIDAPI_FOUND)
check_vendoring_approved(hidapi)
message(STATUS "Using static HIDAPI from Externals")
add_subdirectory(Externals/hidapi EXCLUDE_FROM_ALL)
add_subdirectory(Externals/hidapi EXCLUDE_FROM_ALL SYSTEM)
endif()
endif()

if(USE_DISCORD_PRESENCE)
message(STATUS "Using static DiscordRPC from Externals")
add_subdirectory(Externals/discord-rpc EXCLUDE_FROM_ALL)
include_directories(Externals/discord-rpc/include)
add_subdirectory(Externals/discord-rpc EXCLUDE_FROM_ALL SYSTEM)
include_directories(SYSTEM Externals/discord-rpc/include)
endif()

if(NOT ENABLE_QT)
Expand All @@ -955,7 +955,7 @@ if(USE_MGBA)
find_package(LIBMGBA)
if(NOT LIBMGBA_FOUND)
message(STATUS "Using static libmgba from Externals")
add_subdirectory(Externals/mGBA)
add_subdirectory(Externals/mGBA SYSTEM)
endif()
endif()

Expand All @@ -972,17 +972,17 @@ if(STEAM)
endif()

if (WIN32)
include_directories(Externals/WIL/include)
include_directories(Externals/OpenAL/include)
include_directories(SYSTEM Externals/WIL/include)
include_directories(SYSTEM Externals/OpenAL/include)
endif()

include_directories(Externals/picojson)
include_directories(SYSTEM Externals/picojson)

add_subdirectory(Externals/expr)
add_subdirectory(Externals/expr SYSTEM)

add_subdirectory(Externals/rangeset)
add_subdirectory(Externals/rangeset SYSTEM)

add_subdirectory(Externals/FatFs)
add_subdirectory(Externals/FatFs SYSTEM)

if (USE_RETRO_ACHIEVEMENTS)
add_subdirectory(Externals/rcheevos)
Expand Down Expand Up @@ -1014,7 +1014,7 @@ if(ENABLE_TESTS)
message(STATUS "Using static gtest from Externals")
# Force gtest to link the C runtime dynamically on Windows in order to avoid runtime mismatches.
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
add_subdirectory(Externals/gtest EXCLUDE_FROM_ALL)
add_subdirectory(Externals/gtest EXCLUDE_FROM_ALL SYSTEM)
else()
message(STATUS "Unit tests are disabled")
endif()
Expand Down
2 changes: 1 addition & 1 deletion Externals/cpp-optparse/OptionParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Values {
class Option {
public:
Option(const OptionParser& p) :
_parser(p), _action("store"), _type("string"), _nargs(1), _callback(0) {}
_parser(p), _action("store"), _type("string"), _nargs(1), _callback(nullptr) {}
virtual ~Option() {}

Option& action(const std::string& a);
Expand Down
2 changes: 1 addition & 1 deletion Externals/picojson/picojson.h
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ template <typename Iter> inline std::string parse(value &out, Iter &pos, const I

template <typename Context, typename Iter> inline Iter _parse(Context &ctx, const Iter &first, const Iter &last, std::string *err) {
input<Iter> in(first, last);
if (!_parse(ctx, in) && err != NULL) {
if (!_parse(ctx, in) && err != nullptr) {
char buf[64];
SNPRINTF(buf, sizeof(buf), "syntax error at line %d near: ", in.line());
*err = buf;
Expand Down
2 changes: 1 addition & 1 deletion Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ else()
#check_and_add_flag(SWITCH_DEFAULT -Wswitch-default)
#check_and_add_flag(FLOAT_EQUAL -Wfloat-equal)
#check_and_add_flag(CONVERSION -Wconversion)
#check_and_add_flag(ZERO_AS_NULL_POINTER_CONSTANT -Wzero-as-null-pointer-constant)
check_and_add_flag(ZERO_AS_NULL_POINTER_CONSTANT -Wzero-as-null-pointer-constant)
check_and_add_flag(TYPE_LIMITS -Wtype-limits)
check_and_add_flag(SIGN_COMPARE -Wsign-compare)
check_and_add_flag(IGNORED_QUALIFIERS -Wignored-qualifiers)
Expand Down
16 changes: 16 additions & 0 deletions Source/Core/Common/FatFsUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,15 @@ bool SyncSDFolderToSDImage(const std::function<bool()>& cancelled, bool determin
FatFsErrorToString(mount_error_code));
return false;
}

#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
#endif
Common::ScopeGuard unmount_guard{[] { f_unmount(""); }};
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif

if (!Pack(cancelled, root, true, tmp_buffer))
{
Expand Down Expand Up @@ -795,7 +803,15 @@ bool SyncSDImageToSDFolder(const std::function<bool()>& cancelled)
FatFsErrorToString(mount_error_code));
return false;
}

#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
#endif
Common::ScopeGuard unmount_guard{[] { f_unmount(""); }};
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif

// Unpack() and GetTempFilenameForAtomicWrite() don't want the trailing separator.
const std::string target_dir_without_slash = target_dir.substr(0, target_dir.length() - 1);
Expand Down
Loading