Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Mar 2019 23:55:41 +0000 (UTC)
From:      Enji Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r345213 - projects/capsicum-test/contrib/capsicum-test
Message-ID:  <201903152355.x2FNtfgQ067347@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Fri Mar 15 23:55:41 2019
New Revision: 345213
URL: https://svnweb.freebsd.org/changeset/base/345213

Log:
  Fix -Wshadow issues with `EXPECT_OPEN_OK(..)` macro
  
  * Wrap in do-while(0) block to avoid variable shadowing issue with multiple
    calls in the same function.
  * Prefix block local variables with `_` to try and avoid variable name clashes
    with values local to test methods.

Modified:
  projects/capsicum-test/contrib/capsicum-test/openat.cc

Modified: projects/capsicum-test/contrib/capsicum-test/openat.cc
==============================================================================
--- projects/capsicum-test/contrib/capsicum-test/openat.cc	Fri Mar 15 23:52:37 2019	(r345212)
+++ projects/capsicum-test/contrib/capsicum-test/openat.cc	Fri Mar 15 23:55:41 2019	(r345213)
@@ -11,9 +11,9 @@
 
 // Check an open call works and close the resulting fd.
 #define EXPECT_OPEN_OK(f) do { \
-    int fd = f;                \
-    EXPECT_OK(fd);             \
-    close(fd);                 \
+    int _fd = f;               \
+    EXPECT_OK(_fd);            \
+    close(_fd);                \
   } while (0)
 
 static void CreateFile(const char *filename, const char *contents) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201903152355.x2FNtfgQ067347>