On Mon,  7 Oct 2013 at 23:49:27 +0200, [email protected] wrote:
> From: Daniel Déchelotte <[email protected]>
> 
> ---
>  src/dock.c |   27 ++++++++++++++++++++-------
>  1 file changed, 20 insertions(+), 7 deletions(-)
> 
> diff --git a/src/dock.c b/src/dock.c
> index 4c02fad..41c8ee3 100644
> --- a/src/dock.c
> +++ b/src/dock.c
> @@ -4383,13 +4383,26 @@ static void drawerDestroy(WDock *drawer)
>  
>       wDefaultPurgeInfo(scr, drawer->icon_array[0]->wm_instance,
>                       drawer->icon_array[0]->wm_class);
> -     icons = WMCreateArray(drawer->icon_count - 1);
> -     for (i = 1; i < drawer->max_icons; i++) {
> -             if (!(aicon = drawer->icon_array[i]))
> -                     continue;
> -             WMAddToArray(icons, aicon);
> +     if (drawer->icon_count == 2) {
> +             // Drawer contains a single appicon: dock it where the drawer 
> was
> +             for (i = 1; i < drawer->max_icons; i++) {
> +                     if ((aicon = drawer->icon_array[i]))
> +                             break;
> +             }
> +             wDockMoveIconBetweenDocks(drawer, scr->dock, aicon,
> +                                     0, (drawer->y_pos - scr->dock->y_pos) / 
> ICON_SIZE);
> +             XMoveWindow(dpy, aicon->icon->core->window, drawer->x_pos, 
> drawer->y_pos);
> +             XMapWindow(dpy, aicon->icon->core->window);
> +     }
> +     else if (drawer->icon_count > 2) {
> +             icons = WMCreateArray(drawer->icon_count - 1);
> +             for (i = 1; i < drawer->max_icons; i++) {
> +                     if (!(aicon = drawer->icon_array[i]))
> +                             continue;
> +                     WMAddToArray(icons, aicon);
> +             }
> +             removeIcons(icons, drawer);
>       }
> -     removeIcons(icons, drawer);

Is there a way to avoid this warning?

dock.c: In function 'removeDrawerCallback':
dock.c:4369:24: warning: 'aicon' may be used uninitialized in this function 
[-Wmaybe-uninitialized]
dock.c:4346:12: note: 'aicon' was declared here

It looks like the code is safe, but the warning is annoying.

And btw, it is preferred to avoid setting variables inside if()'s, it's much
more readable to first set the variable in one line and then check it
in another.


-- 
To unsubscribe, send mail to [email protected].

Reply via email to