bison: avoid warnings from static code analysis

A static analysis tool reports that some callers of symbol_list_n_get
might get NULL and not handle it properly.  This is not the case, yet
we can suppress this pattern.

Reported by Mike Sullivan.
<https://lists.gnu.org/archive/html/bug-bison/2013-12/msg00027.html>

* src/symlist.c (symbol_list_n_get): Actually it is never called
to return 0.  Enforce this postcondition via aver.
(symbol_list_n_type_name_get): Simplify accordingly.  In particular,
discards a (translated) useless error message.
* src/symlist.h: Adjust documentation.
* src/scan-code.l: Style change.
This commit is contained in:
Akim Demaille
2015-01-09 14:21:09 +01:00
parent ee028dceff
commit 671850a1c3
5 changed files with 13 additions and 23 deletions

View File

@@ -711,7 +711,7 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
"]b4_rhs_value(%d, %d, ", effective_rule_length, n);
obstack_quote (&obstack_for_string, type_name);
obstack_sgrow (&obstack_for_string, ")[");
if (n > 0)
if (0 < n)
symbol_list_n_get (effective_rule, n)->action_props.is_value_used =
true;
break;