mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-12 01:09:47 -06:00
TestDriver: fix/silence clang-tidy warnings
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h> /* NOLINT */
|
||||||
#include <stdio.h>
|
#include <stdio.h> /* NOLINT */
|
||||||
#include <stdlib.h>
|
#include <stdlib.h> /* NOLINT */
|
||||||
#include <string.h>
|
#include <string.h> /* NOLINT */
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#pragma warning(disable : 4996) /* deprecation */
|
#pragma warning(disable : 4996) /* deprecation */
|
||||||
@@ -29,7 +29,7 @@ typedef struct
|
|||||||
|
|
||||||
static functionMapEntry cmakeGeneratedFunctionMapEntries[] = {
|
static functionMapEntry cmakeGeneratedFunctionMapEntries[] = {
|
||||||
@CMAKE_FUNCTION_TABLE_ENTIRES@
|
@CMAKE_FUNCTION_TABLE_ENTIRES@
|
||||||
{ 0, 0 }
|
{ NULL, NULL } /* NOLINT */
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int NumTests =
|
static const int NumTests =
|
||||||
@@ -37,7 +37,6 @@ static const int NumTests =
|
|||||||
|
|
||||||
/* Allocate and create a lowercased copy of string
|
/* Allocate and create a lowercased copy of string
|
||||||
(note that it has to be free'd manually) */
|
(note that it has to be free'd manually) */
|
||||||
|
|
||||||
static char* lowercase(const char* string)
|
static char* lowercase(const char* string)
|
||||||
{
|
{
|
||||||
char *new_string, *p;
|
char *new_string, *p;
|
||||||
@@ -46,8 +45,8 @@ static char* lowercase(const char* string)
|
|||||||
stringSize = CM_CAST(size_t, strlen(string) + 1);
|
stringSize = CM_CAST(size_t, strlen(string) + 1);
|
||||||
new_string = CM_CAST(char*, malloc(sizeof(char) * stringSize));
|
new_string = CM_CAST(char*, malloc(sizeof(char) * stringSize));
|
||||||
|
|
||||||
if (!new_string) {
|
if (new_string == NULL) { /* NOLINT */
|
||||||
return 0;
|
return NULL; /* NOLINT */
|
||||||
}
|
}
|
||||||
strncpy(new_string, string, stringSize);
|
strncpy(new_string, string, stringSize);
|
||||||
for (p = new_string; *p != 0; ++p) {
|
for (p = new_string; *p != 0; ++p) {
|
||||||
@@ -87,12 +86,12 @@ int main(int ac, char* av[])
|
|||||||
av++;
|
av++;
|
||||||
}
|
}
|
||||||
partial_match = 0;
|
partial_match = 0;
|
||||||
arg = 0;
|
arg = NULL; /* NOLINT */
|
||||||
/* If partial match is requested. */
|
/* If partial match is requested. */
|
||||||
if (testToRun == -1 && ac > 1) {
|
if (testToRun == -1 && ac > 1) {
|
||||||
partial_match = (strcmp(av[1], "-R") == 0) ? 1 : 0;
|
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");
|
printf("-R needs an additional parameter.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -101,20 +100,18 @@ int main(int ac, char* av[])
|
|||||||
}
|
}
|
||||||
for (i = 0; i < NumTests && testToRun == -1; ++i) {
|
for (i = 0; i < NumTests && testToRun == -1; ++i) {
|
||||||
test_name = lowercase(cmakeGeneratedFunctionMapEntries[i].name);
|
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;
|
testToRun = i;
|
||||||
ac -= 2;
|
ac -= 2;
|
||||||
av += 2;
|
av += 2;
|
||||||
} else if (!partial_match && strcmp(test_name, arg) == 0) {
|
} else if (partial_match == 0 && strcmp(test_name, arg) == 0) {
|
||||||
testToRun = i;
|
testToRun = i;
|
||||||
ac--;
|
ac--;
|
||||||
av++;
|
av++;
|
||||||
}
|
}
|
||||||
free(test_name);
|
free(test_name);
|
||||||
}
|
}
|
||||||
if (arg) {
|
free(arg);
|
||||||
free(arg);
|
|
||||||
}
|
|
||||||
if (testToRun != -1) {
|
if (testToRun != -1) {
|
||||||
int result;
|
int result;
|
||||||
@CMAKE_TESTDRIVER_BEFORE_TESTMAIN@
|
@CMAKE_TESTDRIVER_BEFORE_TESTMAIN@
|
||||||
|
|||||||
Reference in New Issue
Block a user