[ovs-dev,2/3] dpctl: Fix shadowed iterator in show_dpif().
diff mbox

Message ID 1468351162-349-2-git-send-email-jpettit@ovn.org
State Accepted
Headers show

Commit Message

Justin Pettit July 12, 2016, 7:19 p.m. UTC
Signed-off-by: Justin Pettit <jpettit@ovn.org>
---
 lib/dpctl.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

Comments

Daniele Di Proietto July 13, 2016, 1:36 a.m. UTC | #1
Looks good to me, thanks!

Acked-by: Daniele Di Proietto <diproiettod@vmware.com>

2016-07-12 12:19 GMT-07:00 Justin Pettit <jpettit@ovn.org>:

> Signed-off-by: Justin Pettit <jpettit@ovn.org>
> ---
>  lib/dpctl.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/lib/dpctl.c b/lib/dpctl.c
> index b870e30..003602a 100644
> --- a/lib/dpctl.c
> +++ b/lib/dpctl.c
> @@ -577,13 +577,10 @@ show_dpif(struct dpif *dpif, struct dpctl_params
> *dpctl_p)
>                  smap_init(&config);
>                  error = netdev_get_config(netdev, &config);
>                  if (!error) {
> -                    const struct smap_node **nodes;
> -                    size_t i;
> -
> -                    nodes = smap_sort(&config);
> -                    for (i = 0; i < smap_count(&config); i++) {
> -                        const struct smap_node *node = nodes[i];
> -                        dpctl_print(dpctl_p, "%c %s=%s", i ? ',' : ':',
> +                    const struct smap_node **nodes = smap_sort(&config);
> +                    for (size_t j = 0; j < smap_count(&config); j++) {
> +                        const struct smap_node *node = nodes[j];
> +                        dpctl_print(dpctl_p, "%c %s=%s", j ? ',' : ':',
>                                      node->key, node->value);
>                      }
>                      free(nodes);
> --
> 1.9.1
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
Justin Pettit July 13, 2016, 2:22 a.m. UTC | #2
Thanks.  Do you mind looking at the other patches, too?  I think they're pretty obviously correct.

--Justin


> On Jul 12, 2016, at 6:36 PM, Daniele Di Proietto <diproiettod@ovn.org> wrote:
> 
> Looks good to me, thanks!
> 
> Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
> 
> 2016-07-12 12:19 GMT-07:00 Justin Pettit <jpettit@ovn.org>:
> Signed-off-by: Justin Pettit <jpettit@ovn.org>
> ---
>  lib/dpctl.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/dpctl.c b/lib/dpctl.c
> index b870e30..003602a 100644
> --- a/lib/dpctl.c
> +++ b/lib/dpctl.c
> @@ -577,13 +577,10 @@ show_dpif(struct dpif *dpif, struct dpctl_params *dpctl_p)
>                  smap_init(&config);
>                  error = netdev_get_config(netdev, &config);
>                  if (!error) {
> -                    const struct smap_node **nodes;
> -                    size_t i;
> -
> -                    nodes = smap_sort(&config);
> -                    for (i = 0; i < smap_count(&config); i++) {
> -                        const struct smap_node *node = nodes[i];
> -                        dpctl_print(dpctl_p, "%c %s=%s", i ? ',' : ':',
> +                    const struct smap_node **nodes = smap_sort(&config);
> +                    for (size_t j = 0; j < smap_count(&config); j++) {
> +                        const struct smap_node *node = nodes[j];
> +                        dpctl_print(dpctl_p, "%c %s=%s", j ? ',' : ':',
>                                      node->key, node->value);
>                      }
>                      free(nodes);
> --
> 1.9.1
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>

Patch
diff mbox

diff --git a/lib/dpctl.c b/lib/dpctl.c
index b870e30..003602a 100644
--- a/lib/dpctl.c
+++ b/lib/dpctl.c
@@ -577,13 +577,10 @@  show_dpif(struct dpif *dpif, struct dpctl_params *dpctl_p)
                 smap_init(&config);
                 error = netdev_get_config(netdev, &config);
                 if (!error) {
-                    const struct smap_node **nodes;
-                    size_t i;
-
-                    nodes = smap_sort(&config);
-                    for (i = 0; i < smap_count(&config); i++) {
-                        const struct smap_node *node = nodes[i];
-                        dpctl_print(dpctl_p, "%c %s=%s", i ? ',' : ':',
+                    const struct smap_node **nodes = smap_sort(&config);
+                    for (size_t j = 0; j < smap_count(&config); j++) {
+                        const struct smap_node *node = nodes[j];
+                        dpctl_print(dpctl_p, "%c %s=%s", j ? ',' : ':',
                                     node->key, node->value);
                     }
                     free(nodes);