Commit eb86b4ce authored by Daniel Pfeifer's avatar Daniel Pfeifer

TestDriver: fix/silence clang-tidy warnings

parent 178c8973
Pipeline #44091 passed with stage
#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@
......
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