[compiler-rt] Remove some cpplint filters

llvm-svn: 371704
This commit is contained in:
Vitaly Buka 2019-09-12 02:20:36 +00:00
parent 6e8c21857e
commit d2af368aee
22 changed files with 77 additions and 63 deletions

View File

@ -284,9 +284,9 @@ class FuzzedDataProvider {
// Avoid using implementation-defined unsigned to signer conversions.
// To learn more, see https://stackoverflow.com/questions/13150449.
if (value <= std::numeric_limits<TS>::max())
if (value <= std::numeric_limits<TS>::max()) {
return static_cast<TS>(value);
else {
} else {
constexpr auto TS_min = std::numeric_limits<TS>::min();
return TS_min + static_cast<char>(value - TS_min);
}

View File

@ -528,10 +528,11 @@ void ReplaceSystemMalloc() {
(uptr)WRAP(RtlAllocateHeap),
(uptr *)&REAL(RtlAllocateHeap));
} else {
#define INTERCEPT_UCRT_FUNCTION(func) \
if (!INTERCEPT_FUNCTION_DLLIMPORT("ucrtbase.dll", \
"api-ms-win-core-heap-l1-1-0.dll", func)) \
VPrintf(2, "Failed to intercept ucrtbase.dll import %s\n", #func);
#define INTERCEPT_UCRT_FUNCTION(func) \
if (!INTERCEPT_FUNCTION_DLLIMPORT( \
"ucrtbase.dll", "api-ms-win-core-heap-l1-1-0.dll", func)) { \
VPrintf(2, "Failed to intercept ucrtbase.dll import %s\n", #func); \
}
INTERCEPT_UCRT_FUNCTION(HeapAlloc);
INTERCEPT_UCRT_FUNCTION(HeapFree);
INTERCEPT_UCRT_FUNCTION(HeapReAlloc);

View File

@ -410,8 +410,12 @@ static bool IsInvalidPointerPair(uptr a1, uptr a2) {
static INLINE void CheckForInvalidPointerPair(void *p1, void *p2) {
switch (flags()->detect_invalid_pointer_pairs) {
case 0 : return;
case 1 : if (p1 == nullptr || p2 == nullptr) return; break;
case 0:
return;
case 1:
if (p1 == nullptr || p2 == nullptr)
return;
break;
}
uptr a1 = reinterpret_cast<uptr>(p1);

View File

@ -181,11 +181,11 @@ static void ThreadStartHook(void *hook, uptr os_id) {
asanThreadRegistry().GetThreadLocked(thread->tid())->status;
DCHECK(status == ThreadStatusCreated || status == ThreadStatusRunning);
// Determine whether we are starting or restarting the thread.
if (status == ThreadStatusCreated)
if (status == ThreadStatusCreated) {
// In lieu of AsanThread::ThreadStart.
asanThreadRegistry().StartThread(thread->tid(), os_id, ThreadType::Regular,
nullptr);
else {
} else {
// In a thread restart, a thread may resume execution at an
// arbitrary function entry point, with its stack and TLS state
// reset. We unpoison the stack in that case.

View File

@ -43,7 +43,7 @@ struct ScarinessScoreBase {
internal_strlcat(descr, "-", sizeof(descr));
internal_strlcat(descr, reason, sizeof(descr));
score += add_to_score;
};
}
int GetScore() const { return score; }
const char *GetDescription() const { return descr; }
void Print() const {

View File

@ -367,8 +367,9 @@ uptr AsanThread::GetStackVariableShadowStart(uptr addr) {
} else if (has_fake_stack()) {
bottom = fake_stack()->AddrIsInFakeStack(addr);
CHECK(bottom);
} else
} else {
return 0;
}
uptr aligned_addr = RoundDownTo(addr, SANITIZER_WORDSIZE / 8); // align addr.
u8 *shadow_ptr = (u8*)MemToShadow(aligned_addr);

View File

@ -38,7 +38,7 @@ dfsan_label dfsan_union(dfsan_label l1, dfsan_label l2);
} // extern "C"
template <typename T>
void dfsan_set_label(dfsan_label label, T &data) {
void dfsan_set_label(dfsan_label label, T &data) { // NOLINT
dfsan_set_label(label, (void *)&data, sizeof(T));
}

View File

@ -505,7 +505,7 @@ int __dfsw_getrusage(int who, struct rusage *usage, dfsan_label who_label,
SANITIZER_INTERFACE_ATTRIBUTE
char *__dfsw_strcpy(char *dest, const char *src, dfsan_label dst_label,
dfsan_label src_label, dfsan_label *ret_label) {
char *ret = strcpy(dest, src);
char *ret = strcpy(dest, src); // NOLINT
if (ret) {
internal_memcpy(shadow_for(dest), shadow_for(src),
sizeof(dfsan_label) * (strlen(src) + 1));

View File

@ -883,8 +883,8 @@ uptr InternalGetProcAddress(void *module, const char *func_name) {
// Check that the module header is full and present.
RVAPtr<IMAGE_DOS_HEADER> dos_stub(module, 0);
RVAPtr<IMAGE_NT_HEADERS> headers(module, dos_stub->e_lfanew);
if (!module || dos_stub->e_magic != IMAGE_DOS_SIGNATURE || // "MZ"
headers->Signature != IMAGE_NT_SIGNATURE || // "PE\0\0"
if (!module || dos_stub->e_magic != IMAGE_DOS_SIGNATURE || // "MZ"
headers->Signature != IMAGE_NT_SIGNATURE || // "PE\0\0"
headers->FileHeader.SizeOfOptionalHeader <
sizeof(IMAGE_OPTIONAL_HEADER)) {
return 0;
@ -963,8 +963,8 @@ bool OverrideImportedFunction(const char *module_to_patch,
// Check that the module header is full and present.
RVAPtr<IMAGE_DOS_HEADER> dos_stub(module, 0);
RVAPtr<IMAGE_NT_HEADERS> headers(module, dos_stub->e_lfanew);
if (!module || dos_stub->e_magic != IMAGE_DOS_SIGNATURE || // "MZ"
headers->Signature != IMAGE_NT_SIGNATURE || // "PE\0\0"
if (!module || dos_stub->e_magic != IMAGE_DOS_SIGNATURE || // "MZ"
headers->Signature != IMAGE_NT_SIGNATURE || // "PE\0\0"
headers->FileHeader.SizeOfOptionalHeader <
sizeof(IMAGE_OPTIONAL_HEADER)) {
return false;

View File

@ -535,7 +535,7 @@ static void ReportIfNotSuspended(ThreadContextBase *tctx, void *arg) {
if (i >= suspended_threads.size() || suspended_threads[i] != tctx->os_id)
Report("Running thread %d was not suspended. False leaks are possible.\n",
tctx->os_id);
};
}
}
static void ReportUnsuspendedThreads(

View File

@ -346,10 +346,11 @@ const int STACK_TRACE_TAG_POISON = StackTrace::TAG_CUSTOM + 1;
#define GET_STORE_STACK_TRACE \
GET_STORE_STACK_TRACE_PC_BP(StackTrace::GetCurrentPc(), GET_CURRENT_FRAME())
#define GET_FATAL_STACK_TRACE_PC_BP(pc, bp) \
BufferedStackTrace stack; \
if (msan_inited) \
stack.Unwind(pc, bp, nullptr, common_flags()->fast_unwind_on_fatal)
#define GET_FATAL_STACK_TRACE_PC_BP(pc, bp) \
BufferedStackTrace stack; \
if (msan_inited) { \
stack.Unwind(pc, bp, nullptr, common_flags()->fast_unwind_on_fatal); \
}
#define GET_FATAL_STACK_TRACE_HERE \
GET_FATAL_STACK_TRACE_PC_BP(StackTrace::GetCurrentPc(), GET_CURRENT_FRAME())

View File

@ -3070,13 +3070,14 @@ INTERCEPTOR(int, sendmmsg, int fd, struct __sanitizer_mmsghdr *msgvec,
COMMON_INTERCEPTOR_FD_RELEASE(ctx, fd);
}
int res = REAL(sendmmsg)(fd, msgvec, vlen, flags);
if (res >= 0 && msgvec)
if (res >= 0 && msgvec) {
for (int i = 0; i < res; ++i) {
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, &msgvec[i].msg_len,
sizeof(msgvec[i].msg_len));
if (common_flags()->intercept_send)
read_msghdr(ctx, &msgvec[i].msg_hdr, msgvec[i].msg_len);
}
}
return res;
}
#define INIT_SENDMMSG COMMON_INTERCEPT_FUNCTION(sendmmsg);
@ -3207,20 +3208,21 @@ INTERCEPTOR(uptr, ptrace, int request, int pid, void *addr, void *data) {
__sanitizer_iovec local_iovec;
if (data) {
if (request == ptrace_setregs)
if (request == ptrace_setregs) {
COMMON_INTERCEPTOR_READ_RANGE(ctx, data, struct_user_regs_struct_sz);
else if (request == ptrace_setfpregs)
} else if (request == ptrace_setfpregs) {
COMMON_INTERCEPTOR_READ_RANGE(ctx, data, struct_user_fpregs_struct_sz);
else if (request == ptrace_setfpxregs)
} else if (request == ptrace_setfpxregs) {
COMMON_INTERCEPTOR_READ_RANGE(ctx, data, struct_user_fpxregs_struct_sz);
else if (request == ptrace_setvfpregs)
} else if (request == ptrace_setvfpregs) {
COMMON_INTERCEPTOR_READ_RANGE(ctx, data, struct_user_vfpregs_struct_sz);
else if (request == ptrace_setsiginfo)
} else if (request == ptrace_setsiginfo) {
COMMON_INTERCEPTOR_READ_RANGE(ctx, data, siginfo_t_sz);
// Some kernel might zero the iovec::iov_base in case of invalid
// write access. In this case copy the invalid address for further
// inspection.
else if (request == ptrace_setregset || request == ptrace_getregset) {
} else if (request == ptrace_setregset || request == ptrace_getregset) {
__sanitizer_iovec *iovec = (__sanitizer_iovec*)data;
COMMON_INTERCEPTOR_READ_RANGE(ctx, iovec, sizeof(*iovec));
local_iovec = *iovec;
@ -3237,19 +3239,19 @@ INTERCEPTOR(uptr, ptrace, int request, int pid, void *addr, void *data) {
if (!res && data) {
// Note that PEEK* requests assign different meaning to the return value.
// This function does not handle them (nor does it need to).
if (request == ptrace_getregs)
if (request == ptrace_getregs) {
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data, struct_user_regs_struct_sz);
else if (request == ptrace_getfpregs)
} else if (request == ptrace_getfpregs) {
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data, struct_user_fpregs_struct_sz);
else if (request == ptrace_getfpxregs)
} else if (request == ptrace_getfpxregs) {
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data, struct_user_fpxregs_struct_sz);
else if (request == ptrace_getvfpregs)
} else if (request == ptrace_getvfpregs) {
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data, struct_user_vfpregs_struct_sz);
else if (request == ptrace_getsiginfo)
} else if (request == ptrace_getsiginfo) {
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data, siginfo_t_sz);
else if (request == ptrace_geteventmsg)
} else if (request == ptrace_geteventmsg) {
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data, sizeof(unsigned long));
else if (request == ptrace_getregset) {
} else if (request == ptrace_getregset) {
__sanitizer_iovec *iovec = (__sanitizer_iovec*)data;
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, iovec, sizeof(*iovec));
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, local_iovec.iov_base,
@ -7842,10 +7844,11 @@ INTERCEPTOR(int, modctl, int operation, void *argp) {
if (iov)
COMMON_INTERCEPTOR_WRITE_RANGE(
ctx, iov->iov_base, Min(iov_len, iov->iov_len));
} else if (operation == modctl_exists)
} else if (operation == modctl_exists) {
ret = REAL(modctl)(operation, argp);
else
} else {
ret = REAL(modctl)(operation, argp);
}
return ret;
}

View File

@ -83,8 +83,9 @@ void FlagParser::parse_flag(const char *env_option_name) {
Printf("%s: ERROR: expected '=' in %s\n", SanitizerToolName,
env_option_name);
Die();
} else
} else {
fatal_error("expected '='");
}
}
char *name = ll_strndup(buf_ + name_start, pos_ - name_start);

View File

@ -24,7 +24,7 @@ class FlagHandlerBase {
virtual bool Parse(const char *value) { return false; }
protected:
~FlagHandlerBase() {};
~FlagHandlerBase() {}
};
template <typename T>

View File

@ -1404,7 +1404,7 @@ static void ioctl_table_fill() {
_(SNDCTL_DSP_SKIP, NONE, 0);
_(SNDCTL_DSP_SILENCE, NONE, 0);
#undef _
}
} // NOLINT
static bool ioctl_initialized = false;

View File

@ -63,10 +63,11 @@ void *internal_memmove(void *dest, const void *src, uptr n) {
for (i = 0; i < signed_n; ++i)
d[i] = s[i];
} else {
if (d > s && signed_n > 0)
for (i = signed_n - 1; i >= 0 ; --i) {
if (d > s && signed_n > 0) {
for (i = signed_n - 1; i >= 0; --i) {
d[i] = s[i];
}
}
}
return dest;
}
@ -270,9 +271,9 @@ bool mem_is_zero(const char *beg, uptr size) {
for (; aligned_beg < aligned_end; aligned_beg++)
all |= *aligned_beg;
// Epilogue.
if ((char*)aligned_end >= beg)
for (const char *mem = (char*)aligned_end; mem < end; mem++)
all |= *mem;
if ((char *)aligned_end >= beg) {
for (const char *mem = (char *)aligned_end; mem < end; mem++) all |= *mem;
}
return all == 0;
}

View File

@ -223,10 +223,11 @@ bool ThreadSuspender::SuspendAllThreads() {
case ThreadLister::Ok:
break;
}
for (tid_t tid : threads)
for (tid_t tid : threads) {
if (SuspendThread(tid))
retry = true;
};
}
}
return suspended_threads_list_.ThreadCount();
}

View File

@ -106,8 +106,9 @@ void ReportMmapWriteExec(int prot) {
if (StackTrace::WillUseFastUnwind(fast)) {
GetThreadStackTopAndBottom(false, &top, &bottom);
stack->Unwind(kStackTraceMax, pc, bp, nullptr, top, bottom, true);
} else
} else {
stack->Unwind(kStackTraceMax, pc, 0, nullptr, 0, 0, false);
}
Printf("%s", d.Warning());
Report("WARNING: %s: writable-executable page usage\n", SanitizerToolName);

View File

@ -17,15 +17,15 @@ fi
# Filters
# TODO: remove some of these filters
COMMON_LINT_FILTER=-build/include,-build/header_guard,-legal/copyright,-whitespace/comments,-readability/casting,\
-build/namespaces,-readability/braces,-build/c++11,-runtime/int
-build/namespaces,-build/c++11,-runtime/int
COMMON_LIT_TEST_LINT_FILTER=-whitespace/indent,-whitespace/line_length,-runtime/arrays
ASAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER}
ASAN_TEST_LINT_FILTER=${COMMON_LINT_FILTER},-runtime/sizeof,-runtime/printf,-runtime/threadsafe_fn
ASAN_TEST_LINT_FILTER=${COMMON_LINT_FILTER},-runtime/printf,-runtime/threadsafe_fn
ASAN_LIT_TEST_LINT_FILTER=${ASAN_TEST_LINT_FILTER},${COMMON_LIT_TEST_LINT_FILTER}
TSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER}
TSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER},-readability/braces
TSAN_TEST_LINT_FILTER=${TSAN_RTL_LINT_FILTER},-runtime/threadsafe_fn
TSAN_LIT_TEST_LINT_FILTER=${TSAN_TEST_LINT_FILTER},${COMMON_LIT_TEST_LINT_FILTER}
@ -34,10 +34,10 @@ MSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER}
LSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER}
LSAN_LIT_TEST_LINT_FILTER=${LSAN_RTL_LINT_FILTER},${COMMON_LIT_TEST_LINT_FILTER}
DFSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER},-runtime/printf,-runtime/references,-readability/function
DFSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER}
SCUDO_RTL_LINT_FILTER=${COMMON_LINT_FILTER}
COMMON_RTL_INC_LINT_FILTER=${COMMON_LINT_FILTER},-runtime/sizeof,-runtime/printf,-readability/fn_size
COMMON_RTL_INC_LINT_FILTER=${COMMON_LINT_FILTER}
SANITIZER_INCLUDES_LINT_FILTER=${COMMON_LINT_FILTER}

View File

@ -33,7 +33,7 @@ TEST(Printf, Basic) {
TEST(Printf, OverflowStr) {
char buf[] = "123456789";
uptr len = internal_snprintf(buf, 4, "%s", "abcdef");
uptr len = internal_snprintf(buf, 4, "%s", "abcdef"); // NOLINT
EXPECT_EQ(len, (uptr)6);
EXPECT_STREQ("abc", buf);
EXPECT_EQ(buf[3], 0);
@ -47,7 +47,7 @@ TEST(Printf, OverflowStr) {
TEST(Printf, OverflowInt) {
char buf[] = "123456789";
internal_snprintf(buf, 4, "%d", -123456789);
internal_snprintf(buf, 4, "%d", -123456789); // NOLINT
EXPECT_STREQ("-12", buf);
EXPECT_EQ(buf[3], 0);
EXPECT_EQ(buf[4], '5');
@ -66,7 +66,7 @@ TEST(Printf, OverflowUint) {
} else {
val = (uptr)0x123456789ULL;
}
internal_snprintf(buf, 4, "a%zx", val);
internal_snprintf(buf, 4, "a%zx", val); // NOLINT
EXPECT_STREQ("a12", buf);
EXPECT_EQ(buf[3], 0);
EXPECT_EQ(buf[4], '5');
@ -85,7 +85,7 @@ TEST(Printf, OverflowPtr) {
} else {
p = (void*)0x123456789ULL;
}
internal_snprintf(buf, 4, "%p", p);
internal_snprintf(buf, 4, "%p", p); // NOLINT
EXPECT_STREQ("0x0", buf);
EXPECT_EQ(buf[3], 0);
EXPECT_EQ(buf[4], '5');
@ -149,7 +149,7 @@ TEST(Printf, Precision) {
EXPECT_STREQ("12345 ", buf);
// Check that width does not overflow the smaller buffer, although
// 10 chars is requested, it stops at the buffer size, 8.
len = internal_snprintf(buf, 8, "%-10s", "12345");
len = internal_snprintf(buf, 8, "%-10s", "12345"); // NOLINT
EXPECT_EQ(10U, len); // The required size reported.
EXPECT_STREQ("12345 ", buf);
}

View File

@ -18,7 +18,7 @@ namespace __sanitizer {
static bool MyMatch(const char *templ, const char *func) {
char tmp[1024];
strcpy(tmp, templ);
snprintf(tmp, sizeof(tmp), "%s", templ);
return TemplateMatch(tmp, func);
}

View File

@ -155,9 +155,9 @@ int main(int argc, char **argv) {
case 10: StackBufferOverflow<char>(0, Write); break;
case 11: StackBufferOverflow<int64_t>(0, Read); break;
case 12:
if (scale <= 3)
if (scale <= 3) {
StackBufferOverflow<int>(16, Write);
else {
} else {
// At large shadow granularity, there is not enough redzone
// between stack elements to detect far-from-bounds. Pretend
// that this test passes.