From: "Rodolfo García Peñas (kix)" <k...@kix.es> The default case is moved to the bottom of the switch case.
The default case should be removed, because the icon has always a right value, because the icon creation always uses a real value: kix@debian:~/src/wmaker/wmaker-crm/src$ grep wAppIconCreateForDock *c appicon.c:WAppIcon *wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile) dock.c: btn = wAppIconCreateForDock(scr, NULL, "Logo", "WMClip", TILE_CLIP); dock.c: btn = wAppIconCreateForDock(scr, NULL, "Logo", "WMDock", TILE_NORMAL); dock.c: btn = wAppIconCreateForDock(scr, NULL, name, "WMDrawer", TILE_DRAWER); dock.c: aicon = wAppIconCreateForDock(scr, command, winstance, wclass, TILE_NORMAL); (1)dock.c: aicon = wAppIconCreateForDock(dock->screen_ptr, NULL, kix@debian:~/src/wmaker/wmaker-crm/src$ kix@debian:~/src/wmaker/wmaker-crm/src$ grep TILE_ *c | grep -v ICON_TILE_SIZE ***[2]appicon.c: tile = TILE_CLIP; dock.c: btn = wAppIconCreateForDock(scr, NULL, "Logo", "WMClip", TILE_CLIP); dock.c: btn = wAppIconCreateForDock(scr, NULL, "Logo", "WMDock", TILE_NORMAL); dock.c: btn = wAppIconCreateForDock(scr, NULL, name, "WMDrawer", TILE_DRAWER); dock.c: aicon = wAppIconCreateForDock(scr, command, winstance, wclass, TILE_NORMAL); (2)dock.c: wm_instance, wm_class, TILE_NORMAL); ***[3]icon.c: icon->tile_type = TILE_NORMAL; icon.c: case TILE_NORMAL: icon.c: case TILE_CLIP: icon.c: case TILE_DRAWER: kix@debian:~/src/wmaker/wmaker-crm/src$ grep tile_type *c icon.c: icon->tile_type = TILE_NORMAL; ***[1]icon.c: icon->tile_type = tile; icon.c: switch (icon->tile_type) { icon.c: wwarning("Unknown tile type: %d.\n", icon->tile_type); kix@debian:~/src/wmaker/wmaker-crm/src$ There are only three cases without value (asterisk in the line start) set as preprocessor variable. (1) and (2) is the same call. These are the three cases: Case [1]: -------------8<-------------- WIcon *icon_create_for_dock(WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile) { WIcon *icon; icon = icon_create_core(scr, 0, 0); icon->tile_type = tile; -------------8<-------------- Calls to icon_create_for_dock, is only call in appicon.c: -------------8<-------------- kix@debian:~/src/wmaker/wmaker-crm/src$ grep icon_create_for_dock *c appicon.c: aicon->icon = icon_create_for_dock(scr, command, wm_instance, wm_class, tile); icon.c:WIcon *icon_create_for_dock(WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile) kix@debian:~/src/wmaker/wmaker-crm/src$ -------------8<-------------- The call: -------------8<-------------- WAppIcon *wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile) { [snip] if (strcmp(wm_class, "WMDock") == 0 && wPreferences.flags.clip_merged_in_dock) tile = TILE_CLIP; aicon->icon = icon_create_for_dock(scr, command, wm_instance, wm_class, tile); -------------8<-------------- And the calls to wAppIconCreateForDock() are checked before. The case [2] is just the line: -------------8<-------------- WAppIcon *wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance, char *wm_class, int tile) { [snip] if (strcmp(wm_class, "WMDock") == 0 && wPreferences.flags.clip_merged_in_dock) *** tile = TILE_CLIP; aicon->icon = icon_create_for_dock(scr, command, wm_instance, wm_class, tile); -------------8<-------------- Then, is sure too. The case [3] is: -------------8<-------------- WIcon *icon_create_for_wwindow(WWindow *wwin) { [snip] icon->tile_type = TILE_NORMAL; -------------8<-------------- All windows have TILE_NORMAL. Then, all cases are secure. --- src/icon.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/icon.c b/src/icon.c index e0ea97a..1033734 100644 --- a/src/icon.c +++ b/src/icon.c @@ -250,17 +250,20 @@ static void icon_update_pixmap(WIcon *icon, RImage *image) case TILE_NORMAL: tile = RCloneImage(scr->icon_tile); break; - default: - wwarning("Unknown tileType: %d.\n", icon->tile_type); - // fallthrough to TILE_CLIP (emulate previous behaviour) case TILE_CLIP: - assert(scr->clip_tile); tile = RCloneImage(scr->clip_tile); break; case TILE_DRAWER: - assert(scr->drawer_tile); tile = RCloneImage(scr->drawer_tile); break; + default: + /* + * The icon has always rigth value, this case is + * only to avoid a compiler warning with "tile" + * "may be used uninitialized" + */ + wwarning("Unknown tile type: %d.\n", icon->tile_type); + tile = RCloneImage(scr->icon_tile); } if (image) { -- 1.7.10.4 -- To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.