summaryrefslogtreecommitdiff
path: root/src/stty.c
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-05-14 15:44:41 +0200
committerJim Meyering <meyering@redhat.com>2012-05-16 07:36:26 +0200
commit1ab163ec071130aef814c262f109b1ac4721d054 (patch)
tree7ebd7e23c8036d0b477e018903eaee2f88ec38d3 /src/stty.c
parent0863f018f0fe970ffdb9cc2267a50c018d3944c5 (diff)
downloadcoreutils-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/stty.c')
-rw-r--r--src/stty.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/stty.c b/src/stty.c
index eb07f853f..a3fc3dd39 100644
--- a/src/stty.c
+++ b/src/stty.c
@@ -52,6 +52,7 @@
#endif
#include <getopt.h>
#include <stdarg.h>
+#include <assert.h>
#include "system.h"
#include "error.h"
@@ -1538,6 +1539,12 @@ display_changed (struct termios *mode)
bitsp = mode_type_flag (mode_info[i].type, mode);
mask = mode_info[i].mask ? mode_info[i].mask : mode_info[i].bits;
+
+ /* bitsp would be NULL only for "combination" modes, yet those
+ are filtered out above via the OMIT flag. Tell static analysis
+ tools that it's ok to dereference bitsp here. */
+ assert (bitsp);
+
if ((*bitsp & mask) == mode_info[i].bits)
{
if (mode_info[i].flags & SANE_UNSET)
@@ -1615,6 +1622,7 @@ display_all (struct termios *mode, char const *device_name)
bitsp = mode_type_flag (mode_info[i].type, mode);
mask = mode_info[i].mask ? mode_info[i].mask : mode_info[i].bits;
+ assert (bitsp); /* See the identical assertion and comment above. */
if ((*bitsp & mask) == mode_info[i].bits)
wrapf ("%s", mode_info[i].name);
else if (mode_info[i].flags & REV)