Skip to content
Snippets Groups Projects
Commit 4d526097 authored by Brad King's avatar Brad King
Browse files

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
parent 4791701a
No related branches found
No related tags found
No related merge requests found
......@@ -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])
{
......
......@@ -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 )
......
......@@ -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");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment