From 95f39ad82eeb3388efdd66aec7b32d1a95e3fd29 Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Sat, 14 Oct 2023 13:16:04 -0700 Subject: [PATCH] Add submodule check, fix some warnings --- CMakeLists.txt | 6 +++++- src/ApplicationPaths.cpp | 38 +++++++++++++++++++------------------- src/ezusb.c | 4 ++-- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 64bf49e..e1a5fb0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,7 +47,7 @@ elseif(${CMAKE_C_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_C_COMPILER_ID} STREQUA string(APPEND CMAKE_C_FLAGS " -Wall") if(USE_WERROR) - string(APPEND CMAKE_CXX_FLAGS " -Werror") + string(APPEND CMAKE_C_FLAGS " -Werror") endif() else() @@ -105,6 +105,10 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) find_package(USB1 REQUIRED) +if(NOT EXISTS CLI11/LICENSE) + message(FATAL_ERROR "CLI11 submodule missing, please run 'git submodule update --init'") +endif() + # CLI11 is a header only library add_library(CLI11 INTERFACE) target_include_directories(CLI11 INTERFACE CLI11/include) diff --git a/src/ApplicationPaths.cpp b/src/ApplicationPaths.cpp index 124b15d..dc8e302 100644 --- a/src/ApplicationPaths.cpp +++ b/src/ApplicationPaths.cpp @@ -76,8 +76,8 @@ std::string getExecutableDir() { std::string getExecutablePath() { char rawPathName[PATH_MAX]; - realpath(PROC_SELF_EXE, rawPathName); - return std::string(rawPathName); + (void)realpath(PROC_SELF_EXE, rawPathName); + return std::string(rawPathName); } std::string getExecutableDir() { @@ -92,25 +92,25 @@ std::string getExecutableDir() { #endif #ifdef __APPLE__ - std::string getExecutablePath() { - char rawPathName[PATH_MAX]; - char realPathName[PATH_MAX]; - uint32_t rawPathSize = (uint32_t)sizeof(rawPathName); - - if(!_NSGetExecutablePath(rawPathName, &rawPathSize)) { - realpath(rawPathName, realPathName); - } - return std::string(realPathName); - } +std::string getExecutablePath() { + char rawPathName[PATH_MAX]; + char realPathName[PATH_MAX]; + uint32_t rawPathSize = (uint32_t)sizeof(rawPathName); - std::string getExecutableDir() { - std::string executablePath = getExecutablePath(); - char *executablePathStr = new char[executablePath.length() + 1]; - strcpy(executablePathStr, executablePath.c_str()); - char* executableDir = dirname(executablePathStr); - delete [] executablePathStr; - return std::string(executableDir); + if(!_NSGetExecutablePath(rawPathName, &rawPathSize)) { + realpath(rawPathName, realPathName); } + return std::string(realPathName); +} + +std::string getExecutableDir() { + std::string executablePath = getExecutablePath(); + char *executablePathStr = new char[executablePath.length() + 1]; + strcpy(executablePathStr, executablePath.c_str()); + char* executableDir = dirname(executablePathStr); + delete [] executablePathStr; + return std::string(executableDir); +} #endif } diff --git a/src/ezusb.c b/src/ezusb.c index 5778ae2..fec5ac8 100644 --- a/src/ezusb.c +++ b/src/ezusb.c @@ -395,7 +395,7 @@ int parse_ihex ( for (idx = 0, cp = buf+9 ; idx < len ; idx += 1, cp += 2) { tmp = cp[2]; cp[2] = '\0'; - data [data_len + idx] = strtoul(cp, 0, 16); + data [data_len + idx] = (uint8_t)strtoul(cp, 0, 16); cp[2] = tmp; } data_len += len; @@ -582,7 +582,7 @@ int ezusb_load_ram (libusb_device_handle *device, const char *path, ezusb_chip_t } if (verbose) - logerror("... WROTE: %d bytes, %d segments, avg %d\n", + logerror("... WROTE: %zu bytes, %zu segments, avg %zu\n", ctx.total, ctx.count, ctx.total / ctx.count); /* now reset the CPU so it runs what we just downloaded */