From: Paul Eggert Date: Sat, 16 Apr 2011 15:38:15 +0000 (-0700) Subject: * xmenu.c (xmenu_show): Don't use uninitialized vars. X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~268^2~29 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=eef9bc799ad1f9c0df0cc23669496d9fbcc326ca;p=emacs.git * xmenu.c (xmenu_show): Don't use uninitialized vars. --- diff --git a/src/ChangeLog b/src/ChangeLog index c009a8fadee..9a429af4b9e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,7 @@ 2011-04-16 Paul Eggert + * xmenu.c (xmenu_show): Don't use uninitialized vars. + * xterm.c: Fix problems found by static analysis with other toolkits. (toolkit_scroll_bar_interaction): Define and use only if USE_X_TOOLKIT. (x_dispatch_event): Declare static only if !USE_GTK && USE_X_TOOLKIT. diff --git a/src/xmenu.c b/src/xmenu.c index f5bbca14047..938e5696b21 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -2299,7 +2299,8 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, y += f->top_pos; /* Create all the necessary panes and their items. */ - maxlines = lines = i = 0; + maxwidth = maxlines = lines = i = 0; + lpane = XM_FAILURE; while (i < menu_items_used) { if (EQ (XVECTOR (menu_items)->contents[i], Qt)) @@ -2327,7 +2328,6 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, i += MENU_ITEMS_PANE_LENGTH; /* Find the width of the widest item in this pane. */ - maxwidth = 0; j = i; while (j < menu_items_used) { @@ -2379,10 +2379,11 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, else item_data = SSDATA (item_name); - if (XMenuAddSelection (FRAME_X_DISPLAY (f), - menu, lpane, 0, item_data, - !NILP (enable), help_string) - == XM_FAILURE) + if (lpane == XM_FAILURE + || (XMenuAddSelection (FRAME_X_DISPLAY (f), + menu, lpane, 0, item_data, + !NILP (enable), help_string) + == XM_FAILURE)) { XMenuDestroy (FRAME_X_DISPLAY (f), menu); *error_name = "Can't add selection to menu"; @@ -2462,6 +2463,7 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, status = XMenuActivate (FRAME_X_DISPLAY (f), menu, &pane, &selidx, x, y, ButtonReleaseMask, &datap, menu_help_callback); + entry = pane_prefix = Qnil; switch (status) { @@ -2508,14 +2510,12 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, case XM_FAILURE: *error_name = "Can't activate menu"; case XM_IA_SELECT: - entry = Qnil; break; case XM_NO_SELECT: /* Make "Cancel" equivalent to C-g unless FOR_CLICK (which means the menu was invoked with a mouse event as POSITION). */ if (! for_click) Fsignal (Qquit, Qnil); - entry = Qnil; break; }