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/sort.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/sort.c')
-rw-r--r-- | src/sort.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/sort.c b/src/sort.c index 493e7f173..2593a2a6e 100644 --- a/src/sort.c +++ b/src/sort.c @@ -28,6 +28,7 @@ #include <sys/types.h> #include <sys/wait.h> #include <signal.h> +#include <assert.h> #include "system.h" #include "argmatch.h" #include "error.h" @@ -4243,6 +4244,10 @@ main (int argc, char **argv) char const *optarg1 = argv[optind++]; s = parse_field_count (optarg1 + 1, &key->eword, N_("invalid number after '-'")); + /* When called with a non-NULL message ID, + parse_field_count cannot return NULL. Tell static + analysis tools that dereferencing S is safe. */ + assert (s); if (*s == '.') s = parse_field_count (s + 1, &key->echar, N_("invalid number after '.'")); |