diff options
author | Jim Meyering <meyering@redhat.com> | 2012-05-14 15:44:41 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2012-05-16 07:36:26 +0200 |
commit | 1ab163ec071130aef814c262f109b1ac4721d054 (patch) | |
tree | 7ebd7e23c8036d0b477e018903eaee2f88ec38d3 /src/fmt.c | |
parent | 0863f018f0fe970ffdb9cc2267a50c018d3944c5 (diff) | |
download | coreutils-1ab163ec071130aef814c262f109b1ac4721d054.tar.xz |
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 <assert.h>.
(display_changed): Add an assertion to placate parfait.
(display_all): Likewise.
* src/sort.c: Include <assert.h>.
(main): Add an assertion to placate parfait.
* src/fmt.c: Include <assert.h>.
(get_paragraph): Add an assertion to placate parfait.
Diffstat (limited to 'src/fmt.c')
-rw-r--r-- | src/fmt.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -20,6 +20,7 @@ #include <stdio.h> #include <sys/types.h> #include <getopt.h> +#include <assert.h> /* 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; |