1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

TestDriver: fix/silence clang-tidy warnings

This commit is contained in:
Daniel Pfeifer
2017-01-24 22:24:06 +01:00
parent 178c897374
commit eb86b4cec1

View File

@@ -1,7 +1,7 @@
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h> /* NOLINT */
#include <stdio.h> /* NOLINT */
#include <stdlib.h> /* NOLINT */
#include <string.h> /* NOLINT */
#if defined(_MSC_VER)
#pragma warning(disable : 4996) /* deprecation */
@@ -29,7 +29,7 @@ typedef struct
static functionMapEntry cmakeGeneratedFunctionMapEntries[] = {
@CMAKE_FUNCTION_TABLE_ENTIRES@
{ 0, 0 }
{ NULL, NULL } /* NOLINT */
};
static const int NumTests =
@@ -37,7 +37,6 @@ static const int NumTests =
/* Allocate and create a lowercased copy of string
(note that it has to be free'd manually) */
static char* lowercase(const char* string)
{
char *new_string, *p;
@@ -46,8 +45,8 @@ static char* lowercase(const char* string)
stringSize = CM_CAST(size_t, strlen(string) + 1);
new_string = CM_CAST(char*, malloc(sizeof(char) * stringSize));
if (!new_string) {
return 0;
if (new_string == NULL) { /* NOLINT */
return NULL; /* NOLINT */
}
strncpy(new_string, string, stringSize);
for (p = new_string; *p != 0; ++p) {
@@ -87,12 +86,12 @@ int main(int ac, char* av[])
av++;
}
partial_match = 0;
arg = 0;
arg = NULL; /* NOLINT */
/* If partial match is requested. */
if (testToRun == -1 && ac > 1) {
partial_match = (strcmp(av[1], "-R") == 0) ? 1 : 0;
}
if (partial_match && ac < 3) {
if (partial_match != 0 && ac < 3) {
printf("-R needs an additional parameter.\n");
return -1;
}
@@ -101,20 +100,18 @@ int main(int ac, char* av[])
}
for (i = 0; i < NumTests && testToRun == -1; ++i) {
test_name = lowercase(cmakeGeneratedFunctionMapEntries[i].name);
if (partial_match && strstr(test_name, arg) != NULL) {
if (partial_match != 0 && strstr(test_name, arg) != NULL) { /* NOLINT */
testToRun = i;
ac -= 2;
av += 2;
} else if (!partial_match && strcmp(test_name, arg) == 0) {
} else if (partial_match == 0 && strcmp(test_name, arg) == 0) {
testToRun = i;
ac--;
av++;
}
free(test_name);
}
if (arg) {
free(arg);
}
free(arg);
if (testToRun != -1) {
int result;
@CMAKE_TESTDRIVER_BEFORE_TESTMAIN@