[PATCH] kconfig: fix warning in get_prompt_str()

From: Pavel Roskin
Date: Mon Dec 01 2014 - 11:52:48 EST


gcc 4.9.1 cannot figure out that jump would be initialized if both head
and location are not null. Initialize jump with NULL and check that it's
not NULL before using.

jump is not NULL at menu.c:590 if and only if head and location are not
NULL. Once jump is assigned a non-NULL value, head and location cannot go
from NULL to non-NULL or vice versa. It means that (jump != NULL) is
equal to (head && location != 0).

Thus remove checks for head and location. The intent of the check is to
ensure that jump is initialized, so make the code match its intent and
easier to read.

There should be no behavior change in get_prompt_str() regardless of the
input.

Signed-off-by: Pavel Roskin <proski@xxxxxxx>
---
scripts/kconfig/menu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index a26cc5d..72c9dba 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -548,7 +548,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
{
int i, j;
struct menu *submenu[8], *menu, *location = NULL;
- struct jump_key *jump;
+ struct jump_key *jump = NULL;

str_printf(r, _("Prompt: %s\n"), _(prop->text));
menu = prop->menu->parent;
@@ -586,7 +586,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
str_printf(r, _(" Location:\n"));
for (j = 4; --i >= 0; j += 2) {
menu = submenu[i];
- if (head && location && menu == location)
+ if (jump && menu == location)
jump->offset = strlen(r->s);
str_printf(r, "%*c-> %s", j, ' ',
_(menu_get_prompt(menu)));

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/