[PATCH] D150573: [Coverity] Fix unchecked return value, NFC

Phoebe Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 15 07:08:04 PDT 2023


pengfei created this revision.
pengfei added a reviewer: barannikov88.
Herald added a subscriber: hiraditya.
Herald added a project: All.
pengfei requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150573

Files:
  llvm/lib/ObjectYAML/ELFEmitter.cpp


Index: llvm/lib/ObjectYAML/ELFEmitter.cpp
===================================================================
--- llvm/lib/ObjectYAML/ELFEmitter.cpp
+++ llvm/lib/ObjectYAML/ELFEmitter.cpp
@@ -51,7 +51,7 @@
   raw_svector_ostream OS;
   Error ReachedLimitErr = Error::success();
 
-  bool checkLimit(uint64_t Size) {
+  [[nodiscard]] bool checkLimit(uint64_t Size) {
     if (!ReachedLimitErr && getOffset() + Size <= MaxSize)
       return true;
     if (!ReachedLimitErr)
@@ -70,7 +70,7 @@
 
   Error takeLimitError() {
     // Request to write 0 bytes to check we did not reach the limit.
-    checkLimit(0);
+    (void)checkLimit(0);
     return std::move(ReachedLimitErr);
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150573.522175.patch
Type: text/x-patch
Size: 684 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230515/5d590beb/attachment.bin>


More information about the llvm-commits mailing list