X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fconfigurator%2Fconfigurator.c;h=c0598509b8c0fa677ea426ab11e8b2a674f12838;hb=f9ac4f56c4a159a2ff531c9b9bae7854931bd038;hp=048b801d181636186a11fc99de0d003d68cff18f;hpb=42d7b648bd295e2204c5d064256fb1ad382b41c9;p=ccan diff --git a/tools/configurator/configurator.c b/tools/configurator/configurator.c index 048b801d..c0598509 100644 --- a/tools/configurator/configurator.c +++ b/tools/configurator/configurator.c @@ -142,6 +142,9 @@ static const struct test base_tests[] = { { "HAVE_ATTRIBUTE_NONNULL", "__attribute__((nonnull)) support", "DEFINES_FUNC", NULL, NULL, "static char *__attribute__((nonnull)) func(char *p) { return p; }" }, + { "HAVE_ATTRIBUTE_RETURNS_NONNULL", "__attribute__((returns_nonnull)) support", + "DEFINES_FUNC", NULL, NULL, + "static const char *__attribute__((returns_nonnull)) func(void) { return \"hi\"; }" }, { "HAVE_ATTRIBUTE_SENTINEL", "__attribute__((sentinel)) support", "DEFINES_FUNC", NULL, NULL, "static int __attribute__((sentinel)) func(int i, ...) { return i; }" }, @@ -411,7 +414,7 @@ static const struct test base_tests[] = { "int main(int argc, char *argv[]) {\n" " (void)argc;\n" " char pad[sizeof(int *) * 1];\n" - " strncpy(pad, argv[0], sizeof(pad));\n" + " memcpy(pad, argv[0], sizeof(pad));\n" " int *x = (int *)pad, *y = (int *)(pad + 1);\n" " return *x == *y;\n" "}\n" }, @@ -639,7 +642,7 @@ static struct test *find_test(const char *name) #define MAIN_BODY_BOILERPLATE "return 0;\n" #define MAIN_END_BOILERPLATE "}\n" -static bool run_test(const char *cmd, const char* wrapper, struct test *test) +static bool run_test(const char *cmd, const char *wrapper, struct test *test) { char *output, *newcmd; FILE *outf; @@ -757,21 +760,12 @@ static bool run_test(const char *cmd, const char* wrapper, struct test *test) /* We run INSIDE_MAIN tests for sanity checking. */ if (strstr(test->style, "EXECUTE") || strstr(test->style, "INSIDE_MAIN")) { - char* cmd = "." DIR_SEP OUTPUT_FILE; - if(wrapper) { - // string length and null terminator. - size_t size = strlen(wrapper) + strlen(" ") + strlen(cmd) + 1; - char* newcmd = malloc(size); - memset(newcmd, '\0', size); - strcat(newcmd, wrapper); - strcat(newcmd, " "); - strcat(newcmd, cmd); - cmd = newcmd; - } + char *cmd = malloc(strlen(wrapper) + strlen(" ." DIR_SEP OUTPUT_FILE) + 1); + + strcpy(cmd, wrapper); + strcat(cmd, " ." DIR_SEP OUTPUT_FILE); output = run(cmd, &status); - if (wrapper) { - free(cmd); - } + free(cmd); if (!strstr(test->style, "EXECUTE") && status != 0) c12r_errx(EXIT_BAD_TEST, "Test for %s failed with %i:\n%s", @@ -922,7 +916,7 @@ int main(int argc, const char *argv[]) = { "", DEFAULT_COMPILER, DEFAULT_FLAGS, NULL }; const char *outflag = DEFAULT_OUTPUT_EXE_FLAG; const char *configurator_cc = NULL; - const char *wrapper = NULL; + const char *wrapper = ""; const char *orig_cc; const char *varfile = NULL; const char *headerfile = NULL;