From 1ab163ec071130aef814c262f109b1ac4721d054 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 14 May 2012 15:44:41 +0200 Subject: maint: add assertions to placate static analysis tools A static analysis tool (http://labs.oracle.com/projects/parfait/) produced some false positive diagnostics. Add assertions to help it understand that the code is correct. * src/stty.c: Include . (display_changed): Add an assertion to placate parfait. (display_all): Likewise. * src/sort.c: Include . (main): Add an assertion to placate parfait. * src/fmt.c: Include . (get_paragraph): Add an assertion to placate parfait. --- src/fmt.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/fmt.c') diff --git a/src/fmt.c b/src/fmt.c index 308b64555..3da198e16 100644 --- a/src/fmt.c +++ b/src/fmt.c @@ -20,6 +20,7 @@ #include #include #include +#include /* Redefine. Otherwise, systems (Unicos for one) with headers that define it to be a type get syntax errors for the variable declaration below. */ @@ -610,6 +611,11 @@ get_paragraph (FILE *f) while (same_para (c) && in_column == other_indent) c = get_line (f, c); } + + /* Tell static analysis tools that using word_limit[-1] is ok. + word_limit is guaranteed to have been incremented by get_line. */ + assert (word < word_limit); + (word_limit - 1)->period = (word_limit - 1)->final = true; next_char = c; return true; -- cgit v1.2.3-54-g00ecf