From 4d526097775c75d0f544600fab4936683832269b Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Thu, 7 Aug 2014 09:53:37 -0400
Subject: [PATCH] Add assert() to quiet Clang scan-build warnings

In ProcessUNIX.c, testProcess.c, and testCommandLineArguments1.cxx, add
assert() calls to tell Clang scan-build that we do not expect certain
pointers to be NULL.

Change-Id: I4a2b035cf58198606b4698c9d0e2048a66f15fd0
---
 ProcessUNIX.c                 | 2 ++
 testCommandLineArguments1.cxx | 2 ++
 testProcess.c                 | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/ProcessUNIX.c b/ProcessUNIX.c
index 241e295..ca9d424 100644
--- a/ProcessUNIX.c
+++ b/ProcessUNIX.c
@@ -68,6 +68,7 @@ do.
 #include <signal.h>    /* sigaction */
 #include <dirent.h>    /* DIR, dirent */
 #include <ctype.h>     /* isspace */
+#include <assert.h>    /* assert */
 
 #if defined(__VMS)
 # define KWSYSPE_VMS_NONBLOCK , O_NONBLOCK
@@ -450,6 +451,7 @@ int kwsysProcess_AddCommand(kwsysProcess* cp, char const* const* command)
       }
     for(i=0; i < n; ++i)
       {
+      assert(command[i]); /* Quiet Clang scan-build. */
       newCommands[cp->NumberOfCommands][i] = strdup(command[i]);
       if(!newCommands[cp->NumberOfCommands][i])
         {
diff --git a/testCommandLineArguments1.cxx b/testCommandLineArguments1.cxx
index 3b84c38..b65c37f 100644
--- a/testCommandLineArguments1.cxx
+++ b/testCommandLineArguments1.cxx
@@ -21,6 +21,7 @@
 # include "kwsys_ios_iostream.h.in"
 #endif
 
+#include <assert.h> /* assert */
 #include <string.h> /* strcmp */
 
 int testCommandLineArguments1(int argc, char* argv[])
@@ -83,6 +84,7 @@ int testCommandLineArguments1(int argc, char* argv[])
     }
   for ( cc = 0; cc < newArgc; ++ cc )
     {
+    assert(newArgv[cc]); /* Quiet Clang scan-build. */
     kwsys_ios::cout << "Unused argument[" << cc << "] = [" << newArgv[cc] << "]"
       << kwsys_ios::endl;
     if ( cc >= 9 )
diff --git a/testProcess.c b/testProcess.c
index 3d62822..47c3fb0 100644
--- a/testProcess.c
+++ b/testProcess.c
@@ -20,6 +20,7 @@
 # include "Encoding.h.in"
 #endif
 
+#include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -104,6 +105,7 @@ static int test4(int argc, const char* argv[])
   fprintf(stderr, "Output before crash on stderr from crash test.\n");  
   fflush(stdout);
   fflush(stderr);
+  assert(invalidAddress); /* Quiet Clang scan-build. */
   /* Provoke deliberate crash by writing to the invalid address. */
   *invalidAddress = 0;
   fprintf(stdout, "Output after crash on stdout from crash test.\n");
-- 
GitLab