From beb22912bbcd54decea94debe2892bf3489c33ce Mon Sep 17 00:00:00 2001 From: Petr Hosek Date: Thu, 21 Dec 2017 20:51:16 +0000 Subject: [sanitizer] Make function declarations C-compatible The public sanitizer headers are intended to be usable from either C++ or C, but they declare no-argument functions with the syntax that is not a proper prototype declaration in C. This goes unnoticed until someone uses -Wsystem-headers. Patch By: mcgrathr Reviewers: phosek, vitalybuka Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D41475 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@321305 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/sanitizer/allocator_interface.h | 10 +++++----- include/sanitizer/asan_interface.h | 24 ++++++++++++------------ include/sanitizer/common_interface_defs.h | 2 +- include/sanitizer/coverage_interface.h | 4 ++-- include/sanitizer/esan_interface.h | 4 ++-- include/sanitizer/hwasan_interface.h | 6 +++--- include/sanitizer/lsan_interface.h | 14 +++++++------- include/sanitizer/msan_interface.h | 8 ++++---- include/sanitizer/scudo_interface.h | 2 +- 9 files changed, 37 insertions(+), 37 deletions(-) diff --git a/include/sanitizer/allocator_interface.h b/include/sanitizer/allocator_interface.h index 2d35804b3..89f328301 100644 --- a/include/sanitizer/allocator_interface.h +++ b/include/sanitizer/allocator_interface.h @@ -32,7 +32,7 @@ extern "C" { size_t __sanitizer_get_allocated_size(const volatile void *p); /* Number of bytes, allocated and not yet freed by the application. */ - size_t __sanitizer_get_current_allocated_bytes(); + size_t __sanitizer_get_current_allocated_bytes(void); /* Number of bytes, mmaped by the allocator to fulfill allocation requests. Generally, for request of X bytes, allocator can reserve and add to free @@ -40,17 +40,17 @@ extern "C" { All these chunks count toward the heap size. Currently, allocator never releases memory to OS (instead, it just puts freed chunks to free lists). */ - size_t __sanitizer_get_heap_size(); + size_t __sanitizer_get_heap_size(void); /* Number of bytes, mmaped by the allocator, which can be used to fulfill allocation requests. When a user program frees memory chunk, it can first fall into quarantine and will count toward __sanitizer_get_free_bytes() later. */ - size_t __sanitizer_get_free_bytes(); + size_t __sanitizer_get_free_bytes(void); /* Number of bytes in unmapped pages, that are released to OS. Currently, always returns 0. */ - size_t __sanitizer_get_unmapped_bytes(); + size_t __sanitizer_get_unmapped_bytes(void); /* Malloc hooks that may be optionally provided by user. __sanitizer_malloc_hook(ptr, size) is called immediately after @@ -81,7 +81,7 @@ extern "C" { resources in attempt to reduce process RSS. Currently available with ASan only. */ - void __sanitizer_purge_allocator(); + void __sanitizer_purge_allocator(void); #ifdef __cplusplus } // extern "C" diff --git a/include/sanitizer/asan_interface.h b/include/sanitizer/asan_interface.h index e689a730e..f2d77143b 100644 --- a/include/sanitizer/asan_interface.h +++ b/include/sanitizer/asan_interface.h @@ -64,19 +64,19 @@ extern "C" { // Useful for calling from a debugger to get information about an ASan error. // Returns 1 if an error has been (or is being) reported, otherwise returns 0. - int __asan_report_present(); + int __asan_report_present(void); // Useful for calling from a debugger to get information about an ASan error. // If an error has been (or is being) reported, the following functions return // the pc, bp, sp, address, access type (0 = read, 1 = write), access size and // bug description (e.g. "heap-use-after-free"). Otherwise they return 0. - void *__asan_get_report_pc(); - void *__asan_get_report_bp(); - void *__asan_get_report_sp(); - void *__asan_get_report_address(); - int __asan_get_report_access_type(); - size_t __asan_get_report_access_size(); - const char *__asan_get_report_description(); + void *__asan_get_report_pc(void); + void *__asan_get_report_bp(void); + void *__asan_get_report_sp(void); + void *__asan_get_report_address(void); + int __asan_get_report_access_type(void); + size_t __asan_get_report_access_size(void); + const char *__asan_get_report_description(void); // Useful for calling from the debugger to get information about a pointer. // Returns the category of the given pointer as a constant string. @@ -118,21 +118,21 @@ extern "C" { // User may provide function that would be called right when ASan detects // an error. This can be used to notice cases when ASan detects an error, but // the program crashes before ASan report is printed. - void __asan_on_error(); + void __asan_on_error(void); // Prints accumulated stats to stderr. Used for debugging. - void __asan_print_accumulated_stats(); + void __asan_print_accumulated_stats(void); // This function may be optionally provided by user and should return // a string containing ASan runtime options. See asan_flags.h for details. - const char* __asan_default_options(); + const char* __asan_default_options(void); // The following 2 functions facilitate garbage collection in presence of // asan's fake stack. // Returns an opaque handler to be used later in __asan_addr_is_in_fake_stack. // Returns NULL if the current thread does not have a fake stack. - void *__asan_get_current_fake_stack(); + void *__asan_get_current_fake_stack(void); // If fake_stack is non-NULL and addr belongs to a fake frame in // fake_stack, returns the address on real stack that corresponds to diff --git a/include/sanitizer/common_interface_defs.h b/include/sanitizer/common_interface_defs.h index 4a1de968b..6d4326f74 100644 --- a/include/sanitizer/common_interface_defs.h +++ b/include/sanitizer/common_interface_defs.h @@ -115,7 +115,7 @@ extern "C" { const void *beg, const void *mid, const void *end); // Print the stack trace leading to this call. Useful for debugging user code. - void __sanitizer_print_stack_trace(); + void __sanitizer_print_stack_trace(void); // Symbolizes the supplied 'pc' using the format string 'fmt'. // Outputs at most 'out_buf_size' bytes into 'out_buf'. diff --git a/include/sanitizer/coverage_interface.h b/include/sanitizer/coverage_interface.h index 081033cec..bc95a5caf 100644 --- a/include/sanitizer/coverage_interface.h +++ b/include/sanitizer/coverage_interface.h @@ -20,10 +20,10 @@ extern "C" { #endif // Record and dump coverage info. - void __sanitizer_cov_dump(); + void __sanitizer_cov_dump(void); // Clear collected coverage info. - void __sanitizer_cov_reset(); + void __sanitizer_cov_reset(void); // Dump collected coverage info. Sorts pcs by module into individual .sancov // files. diff --git a/include/sanitizer/esan_interface.h b/include/sanitizer/esan_interface.h index 4aff8d47b..c755ed330 100644 --- a/include/sanitizer/esan_interface.h +++ b/include/sanitizer/esan_interface.h @@ -37,11 +37,11 @@ extern "C" { // This function can be called mid-run (or at the end of a run for // a server process that doesn't shut down normally) to request that // data for that point in the run be reported from the tool. -void COMPILER_RT_WEAK __esan_report(); +void COMPILER_RT_WEAK __esan_report(void); // This function returns the number of samples that the esan tool has collected // to this point. This is useful for testing. -unsigned int COMPILER_RT_WEAK __esan_get_sample_count(); +unsigned int COMPILER_RT_WEAK __esan_get_sample_count(void); #ifdef __cplusplus } // extern "C" diff --git a/include/sanitizer/hwasan_interface.h b/include/sanitizer/hwasan_interface.h index f70d87875..0c306cf27 100644 --- a/include/sanitizer/hwasan_interface.h +++ b/include/sanitizer/hwasan_interface.h @@ -21,10 +21,10 @@ extern "C" { #endif // This function may be optionally provided by user and should return // a string containing HWASan runtime options. See asan_flags.h for details. - const char* __hwasan_default_options(); + const char* __hwasan_default_options(void); - void __hwasan_enable_allocator_tagging(); - void __hwasan_disable_allocator_tagging(); + void __hwasan_enable_allocator_tagging(void); + void __hwasan_disable_allocator_tagging(void); #ifdef __cplusplus } // extern "C" diff --git a/include/sanitizer/lsan_interface.h b/include/sanitizer/lsan_interface.h index e3e509ff7..731b37314 100644 --- a/include/sanitizer/lsan_interface.h +++ b/include/sanitizer/lsan_interface.h @@ -21,8 +21,8 @@ extern "C" { #endif // Allocations made between calls to __lsan_disable() and __lsan_enable() will // be treated as non-leaks. Disable/enable pairs may be nested. - void __lsan_disable(); - void __lsan_enable(); + void __lsan_disable(void); + void __lsan_enable(void); // The heap object into which p points will be treated as a non-leak. void __lsan_ignore_object(const void *p); @@ -49,7 +49,7 @@ extern "C" { // the time of first invocation of this function. // By calling this function early during process shutdown, you can instruct // LSan to ignore shutdown-only leaks which happen later on. - void __lsan_do_leak_check(); + void __lsan_do_leak_check(void); // Check for leaks now. Returns zero if no leaks have been found or if leak // detection is disabled, non-zero otherwise. @@ -58,7 +58,7 @@ extern "C" { // terminate the process. It does not affect the behavior of // __lsan_do_leak_check() or the end-of-process leak check, and is not // affected by them. - int __lsan_do_recoverable_leak_check(); + int __lsan_do_recoverable_leak_check(void); // The user may optionally provide this function to disallow leak checking // for the program it is linked into (if the return value is non-zero). This @@ -66,15 +66,15 @@ extern "C" { // that is unsupported. // To avoid dead stripping, you may need to define this function with // __attribute__((used)) - int __lsan_is_turned_off(); + int __lsan_is_turned_off(void); // This function may be optionally provided by user and should return // a string containing LSan runtime options. See lsan_flags.inc for details. - const char *__lsan_default_options(); + const char *__lsan_default_options(void); // This function may be optionally provided by the user and should return // a string containing LSan suppressions. - const char *__lsan_default_suppressions(); + const char *__lsan_default_suppressions(void); #ifdef __cplusplus } // extern "C" diff --git a/include/sanitizer/msan_interface.h b/include/sanitizer/msan_interface.h index 6d6a37652..a87c954c1 100644 --- a/include/sanitizer/msan_interface.h +++ b/include/sanitizer/msan_interface.h @@ -31,10 +31,10 @@ extern "C" { int __msan_origin_is_descendant_or_same(uint32_t this_id, uint32_t prev_id); /* Returns non-zero if tracking origins. */ - int __msan_get_track_origins(); + int __msan_get_track_origins(void); /* Returns the origin id of the latest UMR in the calling thread. */ - uint32_t __msan_get_umr_origin(); + uint32_t __msan_get_umr_origin(void); /* Make memory region fully initialized (without changing its contents). */ void __msan_unpoison(const volatile void *a, size_t size); @@ -82,7 +82,7 @@ extern "C" { void __msan_dump_shadow(const volatile void *x, size_t size); /* Returns true if running under a dynamic tool (DynamoRio-based). */ - int __msan_has_dynamic_component(); + int __msan_has_dynamic_component(void); /* Tell MSan about newly allocated memory (ex.: custom allocator). Memory will be marked uninitialized, with origin at the call site. */ @@ -93,7 +93,7 @@ extern "C" { /* This function may be optionally provided by user and should return a string containing Msan runtime options. See msan_flags.h for details. */ - const char* __msan_default_options(); + const char* __msan_default_options(void); /* Deprecated. Call __sanitizer_set_death_callback instead. */ void __msan_set_death_callback(void (*callback)(void)); diff --git a/include/sanitizer/scudo_interface.h b/include/sanitizer/scudo_interface.h index cab7e0f5f..ec7a9e4e1 100644 --- a/include/sanitizer/scudo_interface.h +++ b/include/sanitizer/scudo_interface.h @@ -20,7 +20,7 @@ extern "C" { #endif // This function may be optionally provided by a user and should return // a string containing Scudo runtime options. See scudo_flags.h for details. - const char* __scudo_default_options(); + const char* __scudo_default_options(void); // This function allows to set the RSS limit at runtime. This can be either // the hard limit (HardLimit=1) or the soft limit (HardLimit=0). The limit -- cgit v1.2.3