Commit acc916ed authored by Hans Johnson's avatar Hans Johnson
Browse files

COMP: Prefer const pointer when value does not change

The check finds function parameters of a pointer type that could be changed to
point to a constant type instead.

When const is used properly, many mistakes can be avoided. Advantages when
using const properly:
 - prevent unintentional modification of data;
 - get additional warnings such as using uninitialized data;
 - make it easier for developers to see possible side effects.

This check is not strict about constness, it only warns when the constness will
make the function interface safer.
parent 7be4043f
......@@ -180,8 +180,8 @@ kwsysEXPORT void kwsysProcess_SetPipeShared(kwsysProcess* cp, int pipe,
* write end of the pipe will be closed in the parent process and the
* read end will be closed in the child process.
*/
kwsysEXPORT void kwsysProcess_SetPipeNative(kwsysProcess* cp, int pipe,
kwsysProcess_Pipe_Handle p[2]);
kwsysEXPORT void kwsysProcess_SetPipeNative(
kwsysProcess* cp, int pipe, const kwsysProcess_Pipe_Handle p[2]);
/**
* Get/Set a possibly platform-specific option. Possible options are:
......
......@@ -152,10 +152,11 @@ static int kwsysProcessCreate(kwsysProcess* cp, int prIndex,
static void kwsysProcessDestroy(kwsysProcess* cp);
static int kwsysProcessSetupOutputPipeFile(int* p, const char* name);
static int kwsysProcessSetupOutputPipeNative(int* p, int des[2]);
static int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout,
static int kwsysProcessGetTimeoutTime(kwsysProcess* cp,
const double* userTimeout,
kwsysProcessTime* timeoutTime);
static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
double* userTimeout,
const double* userTimeout,
kwsysProcessTimeNative* timeoutLength,
int zeroIsExpired);
static kwsysProcessTime kwsysProcessTimeGetCurrent(void);
......@@ -571,7 +572,7 @@ void kwsysProcess_SetPipeShared(kwsysProcess* cp, int prPipe, int shared)
}
}
void kwsysProcess_SetPipeNative(kwsysProcess* cp, int prPipe, int p[2])
void kwsysProcess_SetPipeNative(kwsysProcess* cp, int prPipe, const int p[2])
{
int* pPipeNative = 0;
......@@ -1959,7 +1960,8 @@ static int kwsysProcessSetupOutputPipeNative(int* p, int des[2])
/* Get the time at which either the process or user timeout will
expire. Returns 1 if the user timeout is first, and 0 otherwise. */
static int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout,
static int kwsysProcessGetTimeoutTime(kwsysProcess* cp,
const double* userTimeout,
kwsysProcessTime* timeoutTime)
{
/* The first time this is called, we need to calculate the time at
......@@ -1991,7 +1993,7 @@ static int kwsysProcessGetTimeoutTime(kwsysProcess* cp, double* userTimeout,
/* Get the length of time before the given timeout time arrives.
Returns 1 if the time has already arrived, and 0 otherwise. */
static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
double* userTimeout,
const double* userTimeout,
kwsysProcessTimeNative* timeoutLength,
int zeroIsExpired)
{
......
......@@ -761,7 +761,7 @@ void kwsysProcess_SetPipeShared(kwsysProcess* cp, int pipe, int shared)
}
}
void kwsysProcess_SetPipeNative(kwsysProcess* cp, int pipe, HANDLE p[2])
void kwsysProcess_SetPipeNative(kwsysProcess* cp, int pipe, const HANDLE p[2])
{
HANDLE* pPipeNative = 0;
......
......@@ -22,7 +22,7 @@ typedef ptrdiff_t kwsysSystem_ptrdiff_t;
typedef int kwsysSystem_ptrdiff_t;
#endif
static int kwsysSystem__AppendByte(char* local, char** begin, char** end,
static int kwsysSystem__AppendByte(const char* local, char** begin, char** end,
int* size, char c)
{
/* Allocate space for the character. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment