[PATCH] D159397: [analyzer][NFC] Use switch statement in MallocChecker::performKernelMalloc
Brad Smith via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 4 22:08:39 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0a73e1eb47dd: [analyzer][NFC] Use switch statement in MallocChecker::performKernelMalloc (authored by brad).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D159397/new/
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.555801.patch
Type: text/x-patch
Size: 1263 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230905/458e90a6/attachment.bin>
More information about the cfe-commits
mailing list