-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[sanitizer] Fix type in some Min() calls #119248
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
Conversation
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Stefan Schulze Frielinghaus (stefan-sf-ibm) ChangesThis is a follow-up to 6dec338 and #116957 and #119114. Full diff: https://github.com/llvm/llvm-project/pull/119248.diff 1 Files Affected:
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
index 47436a6cd20f0b..c724c9e826f40b 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -532,8 +532,8 @@ INTERCEPTOR(int, strncmp, const char *s1, const char *s2, usize size) {
for (; i1 < size && s1[i1]; i1++) {}
for (; i2 < size && s2[i2]; i2++) {}
}
- COMMON_INTERCEPTOR_READ_RANGE((ctx), (s1), Min(i1 + 1, size));
- COMMON_INTERCEPTOR_READ_RANGE((ctx), (s2), Min(i2 + 1, size));
+ COMMON_INTERCEPTOR_READ_RANGE((ctx), (s1), Min<uptr>(i1 + 1, size));
+ COMMON_INTERCEPTOR_READ_RANGE((ctx), (s2), Min<uptr>(i2 + 1, size));
int result = CharCmpX(c1, c2);
CALL_WEAK_INTERCEPTOR_HOOK(__sanitizer_weak_hook_strncmp, GET_CALLER_PC(), s1,
s2, size, result);
@@ -595,8 +595,8 @@ INTERCEPTOR(int, strncasecmp, const char *s1, const char *s2, SIZE_T size) {
for (; i1 < size && s1[i1]; i1++) {}
for (; i2 < size && s2[i2]; i2++) {}
}
- COMMON_INTERCEPTOR_READ_RANGE((ctx), (s1), Min(i1 + 1, size));
- COMMON_INTERCEPTOR_READ_RANGE((ctx), (s2), Min(i2 + 1, size));
+ COMMON_INTERCEPTOR_READ_RANGE((ctx), (s1), Min<uptr>(i1 + 1, size));
+ COMMON_INTERCEPTOR_READ_RANGE((ctx), (s2), Min<uptr>(i2 + 1, size));
int result = CharCaseCmp(c1, c2);
CALL_WEAK_INTERCEPTOR_HOOK(__sanitizer_weak_hook_strncasecmp, GET_CALLER_PC(),
s1, s2, size, result);
@@ -857,8 +857,8 @@ int MemcmpInterceptorCommon(void *ctx,
c2 = s2[i];
if (c1 != c2) break;
}
- COMMON_INTERCEPTOR_READ_RANGE(ctx, s1, Min(i + 1, size));
- COMMON_INTERCEPTOR_READ_RANGE(ctx, s2, Min(i + 1, size));
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, s1, Min<uptr>(i + 1, size));
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, s2, Min<uptr>(i + 1, size));
int r = CharCmpX(c1, c2);
CALL_WEAK_INTERCEPTOR_HOOK(__sanitizer_weak_hook_memcmp, GET_CALLER_PC(),
a1, a2, size, r);
|
Porting commits
/cc @vitalybuka |
Ping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on cleaning this up. Many years ago I did something similar in the downstream CHERI fork but never got around to upstreaming since I thought we were the only architecture where it mattered.
Could you please change the type of the local variables instead? With that change this LGTM.
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
Outdated
Show resolved
Hide resolved
This is a follow-up to 6dec338 and llvm#116957 and llvm#119114.
659e411
to
a3b701a
Compare
This is a follow-up to 6dec338 and #116957 and #119114.