[PATCH] D159397: [StaticAnalyzer] Use switch statement in MallocChecker::performKernelMalloc. NFC
Brad Smith via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 2 01:10:51 PDT 2023
brad created this revision.
brad added reviewers: vabridgers, NoQ.
brad added a project: clang.
Herald added subscribers: steakhal, manas, ASDenysPetrov, martong, dkrupp, donat.nagy, Szelethus, a.sidorin, szepet, baloghadamsoftware.
Herald added a project: All.
brad requested review of this revision.
Use switch statement in MallocChecker::performKernelMalloc.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D159397
Files:
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
Index: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -1141,22 +1141,28 @@
llvm::Triple::OSType OS = Ctx.getTargetInfo().getTriple().getOS();
if (!KernelZeroFlagVal) {
- if (OS == llvm::Triple::FreeBSD)
+ switch (OS) {
+ case llvm::Triple::FreeBSD:
KernelZeroFlagVal = 0x0100;
- else if (OS == llvm::Triple::NetBSD)
+ break;
+ case llvm::Triple::NetBSD:
KernelZeroFlagVal = 0x0002;
- else if (OS == llvm::Triple::OpenBSD)
+ break;
+ case llvm::Triple::OpenBSD:
KernelZeroFlagVal = 0x0008;
- else if (OS == llvm::Triple::Linux)
+ break;
+ case llvm::Triple::Linux:
// __GFP_ZERO
KernelZeroFlagVal = 0x8000;
- else
+ break;
+ default:
// FIXME: We need a more general way of getting the M_ZERO value.
// See also: O_CREAT in UnixAPIChecker.cpp.
// Fall back to normal malloc behavior on platforms where we don't
// know M_ZERO.
return std::nullopt;
+ }
}
// We treat the last argument as the flags argument, and callers fall-back to
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159397.555568.patch
Type: text/x-patch
Size: 1263 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230902/59d94339/attachment.bin>
More information about the cfe-commits
mailing list