[Spice-devel,v2,1/6] display-channel: current_remove: rename inner variable 'container'

Submitted by Uri Lublin on Dec. 6, 2016, 4:06 p.m.

Details

Message ID 20161206160631.30624-2-uril@redhat.com
State Accepted
Commit a286da42d2376b6eb22b9022069e44fe6faba5b7
Headers show
Series "More coverity fixes" ( rev: 3 ) in Spice

Not browsing as part of any series.

Commit Message

Uri Lublin Dec. 6, 2016, 4:06 p.m.
It shadows the outer one.

Renamed also the outer 'container' variable.

Signed-off-by: Uri Lublin <uril@redhat.com>
---
 server/display-channel.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/server/display-channel.c b/server/display-channel.c
index 061a99d..c6ab57d 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -418,7 +418,7 @@  static void current_remove(DisplayChannel *display, TreeItem *item)
 
     /* depth-first tree traversal, TODO: do a to tree_foreach()? */
     for (;;) {
-        Container *container = now->container;
+        Container *container_of_now = now->container;
         RingItem *ring_item;
 
         if (now->type == TREE_ITEM_TYPE_DRAWABLE) {
@@ -427,25 +427,25 @@  static void current_remove(DisplayChannel *display, TreeItem *item)
             drawable_remove_from_pipes(drawable);
             current_remove_drawable(display, drawable);
         } else {
-            Container *container = CONTAINER(now);
+            Container *now_as_container = CONTAINER(now);
 
             spice_assert(now->type == TREE_ITEM_TYPE_CONTAINER);
 
-            if ((ring_item = ring_get_head(&container->items))) {
+            if ((ring_item = ring_get_head(&now_as_container->items))) {
                 now = SPICE_CONTAINEROF(ring_item, TreeItem, siblings_link);
                 continue;
             }
             ring_item = now->siblings_link.prev;
-            container_free(container);
+            container_free(now_as_container);
         }
         if (now == item) {
             return;
         }
 
-        if ((ring_item = ring_next(&container->items, ring_item))) {
+        if ((ring_item = ring_next(&container_of_now->items, ring_item))) {
             now = SPICE_CONTAINEROF(ring_item, TreeItem, siblings_link);
         } else {
-            now = &container->base;
+            now = &container_of_now->base;
         }
     }
 }

Comments

> 
> It shadows the outer one.
> 
> Renamed also the outer 'container' variable.
> 
> Signed-off-by: Uri Lublin <uril@redhat.com>
> ---
>  server/display-channel.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/server/display-channel.c b/server/display-channel.c
> index 061a99d..c6ab57d 100644
> --- a/server/display-channel.c
> +++ b/server/display-channel.c
> @@ -418,7 +418,7 @@ static void current_remove(DisplayChannel *display,
> TreeItem *item)
>  
>      /* depth-first tree traversal, TODO: do a to tree_foreach()? */
>      for (;;) {
> -        Container *container = now->container;
> +        Container *container_of_now = now->container;
>          RingItem *ring_item;
>  
>          if (now->type == TREE_ITEM_TYPE_DRAWABLE) {
> @@ -427,25 +427,25 @@ static void current_remove(DisplayChannel *display,
> TreeItem *item)
>              drawable_remove_from_pipes(drawable);
>              current_remove_drawable(display, drawable);
>          } else {
> -            Container *container = CONTAINER(now);
> +            Container *now_as_container = CONTAINER(now);
>  
>              spice_assert(now->type == TREE_ITEM_TYPE_CONTAINER);
>  
> -            if ((ring_item = ring_get_head(&container->items))) {
> +            if ((ring_item = ring_get_head(&now_as_container->items))) {
>                  now = SPICE_CONTAINEROF(ring_item, TreeItem, siblings_link);
>                  continue;
>              }
>              ring_item = now->siblings_link.prev;
> -            container_free(container);
> +            container_free(now_as_container);
>          }
>          if (now == item) {
>              return;
>          }
>  
> -        if ((ring_item = ring_next(&container->items, ring_item))) {
> +        if ((ring_item = ring_next(&container_of_now->items, ring_item))) {
>              now = SPICE_CONTAINEROF(ring_item, TreeItem, siblings_link);
>          } else {
> -            now = &container->base;
> +            now = &container_of_now->base;
>          }
>      }
>  }

OT: maybe adding -Wshadow could help?

Acked-by: Frediano Ziglio <fziglio@redhat.com>

Frediano