From 541c5a079773e25fb09f80e8c9147bea1d32cd88 Mon Sep 17 00:00:00 2001 From: Kostya Kortchinsky Date: Thu, 4 Jan 2018 17:05:04 +0000 Subject: [PATCH] [scudo] s/unsigned long/size_t/ for __scudo_set_rss_limit Summary: `__scudo_set_rss_limit`'s `LimitMb` should really be a `size_t`. Update accordingly the prototype. To avoid the `NOLINT` and conform with the other Sanitizers, use the sanitizers types for the internal definition. This should have no functional change. Additionally, capitalize a variable name to follow the LLVM coding standards. Reviewers: alekseyshl, flowerhack Reviewed By: alekseyshl Subscribers: #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D41704 llvm-svn: 321803 --- compiler-rt/include/sanitizer/scudo_interface.h | 2 +- compiler-rt/lib/scudo/scudo_allocator.cpp | 6 +++--- compiler-rt/lib/scudo/scudo_interface_internal.h | 7 ++++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/compiler-rt/include/sanitizer/scudo_interface.h b/compiler-rt/include/sanitizer/scudo_interface.h index ec7a9e4e150c..25979fb23a70 100644 --- a/compiler-rt/include/sanitizer/scudo_interface.h +++ b/compiler-rt/include/sanitizer/scudo_interface.h @@ -26,7 +26,7 @@ extern "C" { // the hard limit (HardLimit=1) or the soft limit (HardLimit=0). The limit // can be removed by setting LimitMb to 0. This function's parameters should // be fully trusted to avoid security mishaps. - void __scudo_set_rss_limit(unsigned long LimitMb, int HardLimit); + void __scudo_set_rss_limit(size_t LimitMb, int HardLimit); #ifdef __cplusplus } // extern "C" #endif diff --git a/compiler-rt/lib/scudo/scudo_allocator.cpp b/compiler-rt/lib/scudo/scudo_allocator.cpp index e5a4d714c66e..1329497f41ab 100644 --- a/compiler-rt/lib/scudo/scudo_allocator.cpp +++ b/compiler-rt/lib/scudo/scudo_allocator.cpp @@ -721,8 +721,8 @@ uptr __sanitizer_get_unmapped_bytes() { return 1; } -uptr __sanitizer_get_estimated_allocated_size(uptr size) { - return size; +uptr __sanitizer_get_estimated_allocated_size(uptr Size) { + return Size; } int __sanitizer_get_ownership(const void *Ptr) { @@ -736,7 +736,7 @@ uptr __sanitizer_get_allocated_size(const void *Ptr) { // Interface functions extern "C" { -void __scudo_set_rss_limit(unsigned long LimitMb, int HardLimit) { // NOLINT +void __scudo_set_rss_limit(uptr LimitMb, s32 HardLimit) { if (!SCUDO_CAN_USE_PUBLIC_INTERFACE) return; Instance.setRssLimit(LimitMb, !!HardLimit); diff --git a/compiler-rt/lib/scudo/scudo_interface_internal.h b/compiler-rt/lib/scudo/scudo_interface_internal.h index 3f39e0c4ee0b..7e8a12c834b4 100644 --- a/compiler-rt/lib/scudo/scudo_interface_internal.h +++ b/compiler-rt/lib/scudo/scudo_interface_internal.h @@ -14,9 +14,14 @@ #ifndef SCUDO_INTERFACE_INTERNAL_H_ #define SCUDO_INTERFACE_INTERNAL_H_ +#include "sanitizer_common/sanitizer_internal_defs.h" + +using __sanitizer::uptr; +using __sanitizer::s32; + extern "C" { SANITIZER_INTERFACE_ATTRIBUTE -void __scudo_set_rss_limit(unsigned long LimitMb, int HardLimit); // NOLINT +void __scudo_set_rss_limit(uptr LimitMb, s32 HardLimit); } // extern "C" #endif // SCUDO_INTERFACE_INTERNAL_H_