diff --git a/CMakeLists.txt b/CMakeLists.txt index f2c95c35ff..dbae74b7f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -186,8 +186,14 @@ else() set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") endif() +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + set(USING_CLANG ON) +else() + set(USING_CLANG OFF) +endif() + if(C_LINUX) - if(CMAKE_COMPILER_IS_GNUCXX) + if(CMAKE_COMPILER_IS_GNUCXX OR USING_CLANG) # Set _GNU_SOURCE for O_LARGEFILE, O_CLOEXEC, O_DIRECTORY, O_NOFOLLOW, etc flags on older systems # (pre POSIX.1-2008: glibc 2.11 and earlier). #4042 set(_GNU_SOURCE 1) diff --git a/clamonacc/c-thread-pool/thpool.c b/clamonacc/c-thread-pool/thpool.c index bf73be24a1..ddc1f883ad 100644 --- a/clamonacc/c-thread-pool/thpool.c +++ b/clamonacc/c-thread-pool/thpool.c @@ -8,7 +8,7 @@ * ********************************/ -#define _POSIX_C_SOURCE 200809L +#define _GNU_SOURCE #include #include #include @@ -471,14 +471,14 @@ static struct job* jobqueue_pull(jobqueue* jobqueue_p){ break; case 1: /* if one job in queue */ - logg(LOGG_DEBUG_NV, "jobqueue_pull: Thread %d pulled last job from queue.\n", syscall(SYS_gettid)); + logg(LOGG_DEBUG_NV, "jobqueue_pull: Thread %ld pulled last job from queue.\n", syscall(SYS_gettid)); jobqueue_p->front = NULL; jobqueue_p->rear = NULL; jobqueue_p->len = 0; break; default: /* if >1 jobs in queue */ - logg(LOGG_DEBUG_NV, "jobqueue_pull: Thread %d pulled a job from queue.\n", syscall(SYS_gettid)); + logg(LOGG_DEBUG_NV, "jobqueue_pull: Thread %ld pulled a job from queue.\n", syscall(SYS_gettid)); jobqueue_p->front = job_p->prev; jobqueue_p->len--; /* more than one job in queue -> post it */ diff --git a/clamonacc/clamonacc.c b/clamonacc/clamonacc.c index d6bf7ba372..7483307619 100644 --- a/clamonacc/clamonacc.c +++ b/clamonacc/clamonacc.c @@ -61,7 +61,7 @@ pthread_t ddd_pid = 0; pthread_t scan_queue_pid = 0; -static void onas_handle_signals(); +static void onas_handle_signals(void); static int startup_checks(struct onas_context *ctx); static struct onas_context *g_ctx = NULL; @@ -247,7 +247,7 @@ int main(int argc, char **argv) exit(ret); } -static void onas_handle_signals() +static void onas_handle_signals(void) { sigset_t sigset; struct sigaction act; diff --git a/clamonacc/client/socket.h b/clamonacc/client/socket.h index 915f9086ca..ea84fb4c41 100644 --- a/clamonacc/client/socket.h +++ b/clamonacc/client/socket.h @@ -31,4 +31,4 @@ struct onas_sock_t { }; cl_error_t onas_set_sock_only_once(struct onas_context *ctx); -int onas_get_sockd(); +int onas_get_sockd(void); diff --git a/clamonacc/inotif/hash.c b/clamonacc/inotif/hash.c index ec3bb31412..736626056b 100644 --- a/clamonacc/inotif/hash.c +++ b/clamonacc/inotif/hash.c @@ -58,7 +58,7 @@ #if defined(HAVE_SYS_FANOTIFY_H) -static struct onas_bucket *onas_bucket_init(); +static struct onas_bucket *onas_bucket_init(void); static void onas_free_bucket(struct onas_bucket *bckt); static int onas_bucket_insert(struct onas_bucket *bckt, struct onas_element *elem); static int onas_bucket_remove(struct onas_bucket *bckt, struct onas_element *elem); diff --git a/clamonacc/inotif/inotif.c b/clamonacc/inotif/inotif.c index 4ed78927f7..04756d5b89 100644 --- a/clamonacc/inotif/inotif.c +++ b/clamonacc/inotif/inotif.c @@ -66,7 +66,7 @@ static int onas_ddd_init_ht(uint32_t ht_size); static int onas_ddd_init_wdlt(uint64_t nwatches); -static int onas_ddd_grow_wdlt(); +static int onas_ddd_grow_wdlt(void); static int onas_ddd_watch(const char *pathname, int fan_fd, uint64_t fan_mask, int in_fd, uint64_t in_mask); static int onas_ddd_watch_hierarchy(const char *pathname, size_t len, int fd, uint64_t mask, uint32_t type); @@ -116,7 +116,7 @@ static int onas_ddd_init_wdlt(uint64_t nwatches) /** * @brief Initialize watch descriptor lookup table which we use alongside inotify to keep track of which open watchpoints correspond to which objects */ -static int onas_ddd_grow_wdlt() +static int onas_ddd_grow_wdlt(void) { char **ptr = NULL; diff --git a/clamonacc/scan/onas_queue.c b/clamonacc/scan/onas_queue.c index c0425ebf1e..b11f8c6b35 100644 --- a/clamonacc/scan/onas_queue.c +++ b/clamonacc/scan/onas_queue.c @@ -80,7 +80,7 @@ static cl_error_t onas_new_event_queue_node(struct onas_event_queue_node **node) return CL_SUCCESS; } -static void *onas_init_event_queue() +static void *onas_init_event_queue(void) { if (CL_EMEM == onas_new_event_queue_node(&g_onas_event_queue_head)) { @@ -120,7 +120,7 @@ static void onas_destroy_event_queue_node(struct onas_event_queue_node *node) return; } -static void onas_destroy_event_queue() +static void onas_destroy_event_queue(void) { if (NULL == g_onas_event_queue_head) { @@ -189,7 +189,7 @@ void *onas_scan_queue_th(void *arg) pthread_cleanup_pop(1); } -static int onas_queue_is_b_empty() +static int onas_queue_is_b_empty(void) { if (g_onas_event_queue.head->next == g_onas_event_queue.tail) { diff --git a/cmake/FindLLVM.cmake b/cmake/FindLLVM.cmake index 7c395bdc44..6357585e85 100644 --- a/cmake/FindLLVM.cmake +++ b/cmake/FindLLVM.cmake @@ -113,7 +113,7 @@ else() ) if(result_code) _LLVM_FAIL("Failed to execute llvm-config ('${LLVM_CONFIG}', result code: '${result_code})'") - else() + else() file(TO_CMAKE_PATH "${tmplibs}" tmplibs) string(REGEX MATCHALL "${pattern}[^ ]+" LLVM_${var} ${tmplibs}) endif() @@ -163,9 +163,15 @@ else() set(LLVM_NATIVE_ARCH ${CMAKE_MATCH_1}) message(STATUS "LLVM_NATIVE_ARCH: ${LLVM_NATIVE_ARCH}") + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + set(USING_CLANG ON) + else() + set(USING_CLANG OFF) + endif() + # On CMake builds of LLVM, the output of llvm-config --cxxflags does not # include -fno-rtti, leading to linker errors. Be sure to add it. - if(NOT MSVC AND (CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"))) + if(NOT MSVC AND (CMAKE_COMPILER_IS_GNUCXX OR USING_CLANG)) if(NOT ${LLVM_CXXFLAGS} MATCHES "-fno-rtti") set(LLVM_CXXFLAGS "${LLVM_CXXFLAGS} -fno-rtti") endif() @@ -181,7 +187,7 @@ else() endif() # Remove gcc-specific flags for clang. - if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") + if(USING_CLANG) string(REPLACE "-Wno-maybe-uninitialized " "" LLVM_CXXFLAGS ${LLVM_CXXFLAGS}) endif() diff --git a/common/misc.h b/common/misc.h index 436c73117b..63fdea0f50 100644 --- a/common/misc.h +++ b/common/misc.h @@ -72,7 +72,7 @@ int daemonize(void); /*closes stdin, stdout, stderr. This is called by daemonize, but not * daemonize_all_return. Users of daemonize_all_return should call this * when initialization is complete.*/ -int close_std_descriptors(); +int close_std_descriptors(void); /*Returns the return value of fork. All processes return */ int daemonize_all_return(void); diff --git a/libclamav/bytecode.h b/libclamav/bytecode.h index 57520c7c94..d8440cee26 100644 --- a/libclamav/bytecode.h +++ b/libclamav/bytecode.h @@ -106,7 +106,7 @@ void cli_bytecode_context_destroy(struct cli_bc_ctx *ctx); #ifdef __cplusplus extern "C" { #endif -extern LIBCLAMAV_EXPORT bool have_clamjit(); +extern LIBCLAMAV_EXPORT bool have_clamjit(void); #ifdef __cplusplus } #endif diff --git a/libclamav/bytecode_detect.c b/libclamav/bytecode_detect.c index 503bce629d..3ebe64f49e 100644 --- a/libclamav/bytecode_detect.c +++ b/libclamav/bytecode_detect.c @@ -41,7 +41,7 @@ #define CHECK_ARCH(a) \ if (!strcmp(TARGET_ARCH_TYPE, #a)) env->arch = arch_##a -extern bool have_clamjit(); +extern bool have_clamjit(void); static void cli_print_environment(struct cli_environment *env) { diff --git a/libclamav/matcher-pcre.h b/libclamav/matcher-pcre.h index fb2a5aab60..4de49e8137 100644 --- a/libclamav/matcher-pcre.h +++ b/libclamav/matcher-pcre.h @@ -77,13 +77,13 @@ void cli_pcre_freetable(struct cli_matcher *root); /* * The following are defined to simple stub functions in matcher-pcre.c if HAVE_PCRE is not defined. */ -cl_error_t cli_pcre_init(); +cl_error_t cli_pcre_init(void); cl_error_t cli_pcre_build(struct cli_matcher *root, long long unsigned match_limit, long long unsigned recmatch_limit, const struct cli_dconf *dconf); cl_error_t cli_pcre_scanbuf(const unsigned char *buffer, uint32_t length, const char **virname, struct cli_ac_result **res, const struct cli_matcher *root, struct cli_ac_data *mdata, const struct cli_pcre_off *data, cli_ctx *ctx); cl_error_t cli_pcre_recaloff(struct cli_matcher *root, struct cli_pcre_off *data, struct cli_target_info *info, cli_ctx *ctx); void cli_pcre_freeoff(struct cli_pcre_off *data); -void cli_pcre_perf_print(); -void cli_pcre_perf_events_destroy(); +void cli_pcre_perf_print(void); +void cli_pcre_perf_events_destroy(void); #endif /*__MATCHER_PCRE_H*/ diff --git a/libclamav/others.h b/libclamav/others.h index 3809d49aa0..3d1b5afe70 100644 --- a/libclamav/others.h +++ b/libclamav/others.h @@ -1224,7 +1224,7 @@ cl_error_t cli_realpath(const char *file_name, char **real_filename); * This is required for unit tests to be able to link with clamav.dll and not * directly manipulate libclamav global variables. */ -uint8_t cli_get_debug_flag(); +uint8_t cli_get_debug_flag(void); /** * @brief Set the libclamav debug flag to a specific value. diff --git a/libclamav/regex_pcre.h b/libclamav/regex_pcre.h index adb51e80f3..94561af476 100644 --- a/libclamav/regex_pcre.h +++ b/libclamav/regex_pcre.h @@ -76,7 +76,7 @@ struct cli_pcre_results { }; #endif -cl_error_t cli_pcre_init_internal(); +cl_error_t cli_pcre_init_internal(void); cl_error_t cli_pcre_addoptions(struct cli_pcre_data *pd, const char **opt, int errout); cl_error_t cli_pcre_compile(struct cli_pcre_data *pd, long long unsigned match_limit, long long unsigned match_limit_recursion, unsigned int options, int opt_override);