svn commit: r345423 - projects/capsicum-test/contrib/capsicum-test

Enji Cooper ngie at FreeBSD.org
Fri Mar 22 19:15:16 UTC 2019


Author: ngie
Date: Fri Mar 22 19:15:14 2019
New Revision: 345423
URL: https://svnweb.freebsd.org/changeset/base/345423

Log:
  Fix a -Wdangling-else issue with g++
  
  g++ fails to compile capability-fd.cc with the following issues, ad nauseum:
  ```
  contrib/capsicum-test/capability-fd.cc: In function 'void TryDirOps(int, cap_rights_t)':
  contrib/capsicum-test/capability-fd.cc:716:6: error: suggest explicit braces to avoid ambiguous 'else' [-Werror=dangling-else]
     if (rc >= 0) EXPECT_OK(close(rc));
  ```
  
  Wrap the `EXPECT_OK(..)` macro with do-while so it's properly treated like a
  code block, as `EXPECT_LT(..)` expands to a much larger block of code.

Modified:
  projects/capsicum-test/contrib/capsicum-test/capsicum-test.h

Modified: projects/capsicum-test/contrib/capsicum-test/capsicum-test.h
==============================================================================
--- projects/capsicum-test/contrib/capsicum-test/capsicum-test.h	Fri Mar 22 19:08:48 2019	(r345422)
+++ projects/capsicum-test/contrib/capsicum-test/capsicum-test.h	Fri Mar 22 19:15:14 2019	(r345423)
@@ -134,7 +134,10 @@ const char *TmpFile(const char *pathname);
     void ICLASS_NAME(test_case_name, test_name)::InnerTestBody()
 
 // Emit errno information on failure
-#define EXPECT_OK(v) EXPECT_LE(0, v) << "   errno " << errno << " " << strerror(errno)
+#define EXPECT_OK(v) \
+    do { \
+      EXPECT_LE(0, v) << "   errno " << errno << " " << strerror(errno); \
+    } while (0)
 
 // Expect a syscall to fail with the given error.
 #define EXPECT_SYSCALL_FAIL(E, C) \


More information about the svn-src-projects mailing list