[PATCH] ivi-controller: do refactor send_surface_add_event

Ucan, Emre (ADITG/SW1) eucan at de.adit-jv.com
Fri Jun 3 04:54:33 EDT 2016


Hello Natsume-san,

You are right the if statement is not required. But we can optimize the code further, if we move ivi_controller_surface_send_layer into the wl_list_for_each, e.g.:

@@ -164,26 +164,21 @@ send_surface_add_event(struct ivisurface *ivisurf,
     else if (mask & IVI_NOTIFICATION_ADD) {
         for (i = 0; i < (int)length; i++) {
             /* Send new surface event */
-            ivilayer = NULL;
             if (wl_list_empty(&shell->list_layer)) {
                 break;
             }
 
             wl_list_for_each(ivilayer, &shell->list_layer, link) {
                 if (ivilayer->layout_layer == pArray[i]) {
-                    break;
-                }
-            }
-
-            if (ivilayer == NULL) {
-                continue;
-            }
-
-            layer_resource = wl_resource_find_for_client(&ivilayer->resource_list,
+                    layer_resource = wl_resource_find_for_client(&ivilayer->resource_list,
                                                          client);
 
-            if (layer_resource != NULL) {
-                ivi_controller_surface_send_layer(resource, layer_resource);
+                    if (layer_resource != NULL) {
+                        ivi_controller_surface_send_layer(resource, layer_resource);
+                    }
+
+                    break;
+                }
             }
         }
     }


This change can be also done for the other patch.

Best regards

Emre Ucan
Software Group I (ADITG/SW1)

Tel. +49 5121 49 6937

> -----Original Message-----
> From: genivi-ivi-layer-management-bounces at lists.genivi.org [mailto:genivi-
> ivi-layer-management-bounces at lists.genivi.org] On Behalf Of Natsume,
> Wataru (ADITJ/SWG)
> Sent: Dienstag, 31. Mai 2016 13:32
> To: genivi-ivi-layer-management at lists.genivi.org
> Cc: securitycheck at denso.co.jp
> Subject: [PATCH] ivi-controller: do refactor send_surface_add_event
> 
> Check logic should be improved because ivilayer is never null.
> 
> Signed-off-by: Wataru Natsume <wataru_natsume at xddp.denso.co.jp>
> ---
>  weston-ivi-shell/src/ivi-controller-impl.c |   20 +++++++++-----------
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/weston-ivi-shell/src/ivi-controller-impl.c b/weston-ivi-shell/src/ivi-
> controller-impl.c
> index af79ded..b5087fc 100644
> --- a/weston-ivi-shell/src/ivi-controller-impl.c
> +++ b/weston-ivi-shell/src/ivi-controller-impl.c
> @@ -164,26 +164,24 @@ send_surface_add_event(struct ivisurface *ivisurf,
>      else if (mask & IVI_NOTIFICATION_ADD) {
>          for (i = 0; i < (int)length; i++) {
>              /* Send new surface event */
> -            ivilayer = NULL;
>              if (wl_list_empty(&shell->list_layer)) {
>                  break;
>              }
> 
> +            int found = 0;
>              wl_list_for_each(ivilayer, &shell->list_layer, link) {
>                  if (ivilayer->layout_layer == pArray[i]) {
> -                    break;
> +                    found = 1;
> +                    break;
>                  }
>              }
> 
> -            if (ivilayer == NULL) {
> -                continue;
> -            }
> -
> -            layer_resource = wl_resource_find_for_client(&ivilayer-
> >resource_list,
> -                                                         client);
> -
> -            if (layer_resource != NULL) {
> -                ivi_controller_surface_send_layer(resource, layer_resource);
> +            if (found == 1) {
> +                layer_resource = wl_resource_find_for_client(&ivilayer-
> >resource_list,
> +                                                             client);
> +                if (layer_resource != NULL) {
> +                    ivi_controller_surface_send_layer(resource, layer_resource);
> +                }
>              }
>          }
>      }
> --
> 1.7.9.5




More information about the genivi-ivi-layer-management mailing list