diff mbox series

[ovs-dev,shadow,8/8] Add -Wshadow for compilers that support it.

Message ID 1519804863-73126-9-git-send-email-jpettit@ovn.org
State Accepted
Headers show
Series Remove shadowed declarations | expand

Commit Message

Justin Pettit Feb. 28, 2018, 8:01 a.m. UTC
Signed-off-by: Justin Pettit <jpettit@ovn.org>
---
 configure.ac | 1 +
 1 file changed, 1 insertion(+)

Comments

Ben Pfaff Feb. 28, 2018, 9:23 p.m. UTC | #1
On Wed, Feb 28, 2018 at 12:01:03AM -0800, Justin Pettit wrote:
> Signed-off-by: Justin Pettit <jpettit@ovn.org>

I get one additional error when this is applied:

../lib/stream-ssl.c:1250:15: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
../lib/stream-ssl.c:163:31: note: previous declaration is here

After that's fixed then I can ack this:
Acked-by: Ben Pfaff <blp@ovn.org>
Justin Pettit Feb. 28, 2018, 11:04 p.m. UTC | #2
> On Feb 28, 2018, at 1:23 PM, Ben Pfaff <blp@ovn.org> wrote:
> 
> On Wed, Feb 28, 2018 at 12:01:03AM -0800, Justin Pettit wrote:
>> Signed-off-by: Justin Pettit <jpettit@ovn.org>
> 
> I get one additional error when this is applied:
> 
> ../lib/stream-ssl.c:1250:15: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
> ../lib/stream-ssl.c:163:31: note: previous declaration is here

Whoops.  I hadn't compiled with openssl.  I fixed it with the incremental at the end of the message.

> After that's fixed then I can ack this:
> Acked-by: Ben Pfaff <blp@ovn.org>

Thanks for the quick reviews.  I pushed this to master.

--Justin


-=-=-=-=-=-=-=-

diff --git a/lib/stream-ssl.c b/lib/stream-ssl.c
index 278468083165..ebb6f3a6c8bb 100644
--- a/lib/stream-ssl.c
+++ b/lib/stream-ssl.c
@@ -1247,12 +1247,12 @@ read_cert_file(const char *file_name, X509 ***certs, size_t *n_certs)
     }
 
     for (;;) {
-        X509 *certificate;
+        X509 *cert;
         int c;
 
         /* Read certificate from file. */
-        certificate = PEM_read_X509(file, NULL, NULL, NULL);
-        if (!certificate) {
+        cert = PEM_read_X509(file, NULL, NULL, NULL);
+        if (!cert) {
             size_t i;
 
             VLOG_ERR("PEM_read_X509 failed reading %s: %s",
@@ -1271,7 +1271,7 @@ read_cert_file(const char *file_name, X509 ***certs, size_t *n_certs)
         if (*n_certs >= allocated_certs) {
             *certs = x2nrealloc(*certs, &allocated_certs, sizeof **certs);
         }
-        (*certs)[(*n_certs)++] = certificate;
+        (*certs)[(*n_certs)++] = cert;
 
         /* Are there additional certificates in the file? */
         do {
diff mbox series

Patch

diff --git a/configure.ac b/configure.ac
index 84fed062cfa3..9940a1a453a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -168,6 +168,7 @@  OVS_ENABLE_OPTION([-Wbool-compare])
 OVS_ENABLE_OPTION([-Wshift-negative-value])
 OVS_ENABLE_OPTION([-Wduplicated-cond])
 OVS_ENABLE_OPTION([-Qunused-arguments])
+OVS_ENABLE_OPTION([-Wshadow])
 OVS_CONDITIONAL_CC_OPTION([-Wno-unused], [HAVE_WNO_UNUSED])
 OVS_CONDITIONAL_CC_OPTION([-Wno-unused-parameter], [HAVE_WNO_UNUSED_PARAMETER])
 OVS_ENABLE_WERROR