diff options
Diffstat (limited to 'testutil')
-rw-r--r-- | testutil/get-datatype-description.c | 30 | ||||
-rw-r--r-- | testutil/get-error.c | 11 | ||||
-rw-r--r-- | testutil/get-section-fraction.c | 17 | ||||
-rw-r--r-- | testutil/get-signals.c | 20 | ||||
-rw-r--r-- | testutil/get-syscall-errors.c | 20 | ||||
-rw-r--r-- | testutil/get-syscall-range.c | 20 | ||||
-rw-r--r-- | testutil/is-datatype-struct.c | 23 | ||||
-rw-r--r-- | testutil/is-section-half.c | 20 | ||||
-rw-r--r-- | testutil/is-section-quarter.c | 20 | ||||
-rw-r--r-- | testutil/list-errors.c | 9 | ||||
-rw-r--r-- | testutil/perror-all.c | 11 | ||||
-rw-r--r-- | testutil/perror-bad.c | 11 | ||||
-rw-r--r-- | testutil/strerror-all.c | 9 | ||||
-rw-r--r-- | testutil/strerror-bad.c | 9 |
14 files changed, 171 insertions, 59 deletions
diff --git a/testutil/get-datatype-description.c b/testutil/get-datatype-description.c index 0bec618..9c26626 100644 --- a/testutil/get-datatype-description.c +++ b/testutil/get-datatype-description.c @@ -6,18 +6,30 @@ #include <stdio.h> #include <stdlib.h> +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wunsafe-buffer-usage" /* clang is just being silly */ +#endif + int -main(int argc, char *argv[]) +main(int argc, char **argv) { - enum libsyscalls_os os = (enum libsyscalls_os)atoi(argv[1]); - enum libsyscalls_arch arch = (enum libsyscalls_arch)atoi(argv[2]); - enum libsyscalls_datatype type = (enum libsyscalls_datatype)atoi(argv[3]); + int os, arch, type; struct libsyscalls_datatype_description desc; enum libsyscalls_error err; size_t i; - err = libsyscalls_get_datatype_description(os, arch, type, &desc); + if (argc != 7) { + fprintf(stderr, "usage error\n"); + return 3; + } + + os = atoi(argv[1]); + arch = atoi(argv[2]); + type = atoi(argv[3]); + + err = libsyscalls_get_datatype_description((enum libsyscalls_os)os, (enum libsyscalls_arch)arch, + (enum libsyscalls_datatype)type, &desc); if (err) { fprintf(stderr, "libsyscalls_get_datatype_description %s %s %s: ", argv[4], argv[5], argv[6]); libsyscalls_perror(NULL, err); @@ -28,10 +40,10 @@ main(int argc, char *argv[]) printf("array_size = %u\n", desc.array_size); printf("relative_position_of_array_size = %i\n", desc.relative_position_of_array_size); printf("absolute_position_of_array_size = %i\n", desc.absolute_position_of_array_size); - printf("fill_is_known = %u\n", desc.fill_is_known); - printf("is_signed = %u\n", desc.is_signed); - printf("is_unsigned = %u\n", desc.is_unsigned); - printf("min_is_minus_max = %u\n", desc.min_is_minus_max); + printf("fill_is_known = %u\n", (unsigned)desc.fill_is_known); + printf("is_signed = %u\n", (unsigned)desc.is_signed); + printf("is_unsigned = %u\n", (unsigned)desc.is_unsigned); + printf("min_is_minus_max = %u\n", (unsigned)desc.min_is_minus_max); printf("sign_representation = %lli\n", (long long int)desc.sign_representation); printf("annotation = %lli\n", (long long int)desc.annotation); printf("section = %lli\n", (long long int)desc.section); diff --git a/testutil/get-error.c b/testutil/get-error.c index 8f066d7..d390a60 100644 --- a/testutil/get-error.c +++ b/testutil/get-error.c @@ -5,12 +5,21 @@ #include <stdio.h> #include <string.h> +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wunsafe-buffer-usage" /* clang is just being silly */ +#endif + int -main(int argc, char *argv[]) +main(int argc, char **argv) { int i; + if (argc < 2) { + fprintf(stderr, "usage error\n"); + return 3; + } + for (i = 1; i < argc; i++) { #define X(N, S)\ if (!strcmp(argv[i], #N))\ diff --git a/testutil/get-section-fraction.c b/testutil/get-section-fraction.c index cdb1530..2b86206 100644 --- a/testutil/get-section-fraction.c +++ b/testutil/get-section-fraction.c @@ -5,16 +5,23 @@ #include <stdio.h> #include <stdlib.h> +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wunsafe-buffer-usage" /* clang is just being silly */ +#endif + int -main(int argc, char *argv[]) +main(int argc, char **argv) { - enum libsyscalls_datatype_section sec; + int sec; - (void) argc; + if (argc != 2) { + fprintf(stderr, "usage error\n"); + return 3; + } - sec = (enum libsyscalls_datatype_section)atoi(argv[1]); - printf("%u\n", LIBSYSCALLS_GET_SECTION_FRACTION(sec)); + sec = atoi(argv[1]); + printf("%u\n", LIBSYSCALLS_GET_SECTION_FRACTION((enum libsyscalls_datatype_section)sec)); if (fflush(stdout) || fclose(stdout)) { perror(NULL); diff --git a/testutil/get-signals.c b/testutil/get-signals.c index 846a0c1..f97484f 100644 --- a/testutil/get-signals.c +++ b/testutil/get-signals.c @@ -5,22 +5,28 @@ #include <stdio.h> #include <stdlib.h> +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wunsafe-buffer-usage" /* clang is just being silly */ +#endif + int -main(int argc, char *argv[]) +main(int argc, char **argv) { - enum libsyscalls_os os; - enum libsyscalls_arch arch; + int os, arch; const struct libsyscalls_named_number *signals; size_t i, nsignals; enum libsyscalls_error err; - (void) argc; + if (argc != 5) { + fprintf(stderr, "usage error\n"); + return 3; + } - os = (enum libsyscalls_os)atoi(argv[1]); - arch = (enum libsyscalls_arch)atoi(argv[2]); + os = atoi(argv[1]); + arch = atoi(argv[2]); - libsyscalls_get_signals(os, arch, &signals, &nsignals); + err = libsyscalls_get_signals((enum libsyscalls_os)os, (enum libsyscalls_arch)arch, &signals, &nsignals); if (err == LIBSYSCALLS_E_OSNOSUP || err == LIBSYSCALLS_E_ARCHNOSUP) { printf("x\n"); return 0; diff --git a/testutil/get-syscall-errors.c b/testutil/get-syscall-errors.c index c97e556..d1ddfd7 100644 --- a/testutil/get-syscall-errors.c +++ b/testutil/get-syscall-errors.c @@ -5,22 +5,28 @@ #include <stdio.h> #include <stdlib.h> +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wunsafe-buffer-usage" /* clang is just being silly */ +#endif + int -main(int argc, char *argv[]) +main(int argc, char **argv) { - enum libsyscalls_os os; - enum libsyscalls_arch arch; + int os, arch; const struct libsyscalls_named_number *errors; size_t i, nerrors; enum libsyscalls_error err; - (void) argc; + if (argc != 5) { + fprintf(stderr, "usage error\n"); + return 3; + } - os = (enum libsyscalls_os)atoi(argv[1]); - arch = (enum libsyscalls_arch)atoi(argv[2]); + os = atoi(argv[1]); + arch = atoi(argv[2]); - libsyscalls_get_syscall_errors(os, arch, &errors, &nerrors); + err = libsyscalls_get_syscall_errors((enum libsyscalls_os)os, (enum libsyscalls_arch)arch, &errors, &nerrors); if (err == LIBSYSCALLS_E_OSNOSUP || err == LIBSYSCALLS_E_ARCHNOSUP) { printf("x\n"); return 0; diff --git a/testutil/get-syscall-range.c b/testutil/get-syscall-range.c index 9f26b8e..2c40b71 100644 --- a/testutil/get-syscall-range.c +++ b/testutil/get-syscall-range.c @@ -5,21 +5,27 @@ #include <stdio.h> #include <stdlib.h> +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wunsafe-buffer-usage" /* clang is just being silly */ +#endif + int -main(int argc, char *argv[]) +main(int argc, char **argv) { - enum libsyscalls_os os; - enum libsyscalls_arch arch; + int os, arch; long long int min, max; enum libsyscalls_error err; - (void) argc; + if (argc != 5) { + fprintf(stderr, "usage error\n"); + return 3; + } - os = (enum libsyscalls_os)atoi(argv[1]); - arch = (enum libsyscalls_arch)atoi(argv[2]); + os = atoi(argv[1]); + arch = atoi(argv[2]); - err = libsyscalls_get_syscall_range(os, arch, &min, &max); + err = libsyscalls_get_syscall_range((enum libsyscalls_os)os, (enum libsyscalls_arch)arch, &min, &max); if (err == LIBSYSCALLS_E_OSNOSUP || err == LIBSYSCALLS_E_ARCHNOSUP) { printf("min: x\n"); printf("max: x\n"); diff --git a/testutil/is-datatype-struct.c b/testutil/is-datatype-struct.c index f1c7675..e9eb2ef 100644 --- a/testutil/is-datatype-struct.c +++ b/testutil/is-datatype-struct.c @@ -6,18 +6,29 @@ #include <stdio.h> #include <stdlib.h> +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wunsafe-buffer-usage" /* clang is just being silly */ +#endif + int -main(int argc, char *argv[]) +main(int argc, char **argv) { - enum libsyscalls_os os = (enum libsyscalls_os)atoi(argv[1]); - enum libsyscalls_arch arch = (enum libsyscalls_arch)atoi(argv[2]); - enum libsyscalls_datatype type = (enum libsyscalls_datatype)atoi(argv[3]); + int os, arch, type; struct libsyscalls_datatype_description desc; enum libsyscalls_error err; - size_t i; - err = libsyscalls_get_datatype_description(os, arch, type, &desc); + if (argc != 7) { + fprintf(stderr, "usage error\n"); + return 3; + } + + os = atoi(argv[1]); + arch = atoi(argv[2]); + type = atoi(argv[3]); + + err = libsyscalls_get_datatype_description((enum libsyscalls_os)os, (enum libsyscalls_arch)arch, + (enum libsyscalls_datatype)type, &desc); if (err == LIBSYSCALLS_E_ISSTRUCT) { return 0; } else if (err) { diff --git a/testutil/is-section-half.c b/testutil/is-section-half.c index ee6ef50..60de62a 100644 --- a/testutil/is-section-half.c +++ b/testutil/is-section-half.c @@ -1,14 +1,24 @@ /* See LICENSE file for copyright and license details. */ #include "../libsyscalls.h" +#include <stdio.h> #include <stdlib.h> +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wunsafe-buffer-usage" /* clang is just being silly */ +#endif + int -main(int argc, char *argv[]) +main(int argc, char **argv) { - enum libsyscalls_datatype_section sec; - (void) argc; - sec = (enum libsyscalls_datatype_section)atoi(argv[1]); - return !LIBSYSCALLS_IS_SECTION_HALF(sec); + int sec; + + if (argc != 2) { + fprintf(stderr, "usage error\n"); + return 3; + } + + sec = atoi(argv[1]); + return !LIBSYSCALLS_IS_SECTION_HALF((enum libsyscalls_datatype_section)sec); } diff --git a/testutil/is-section-quarter.c b/testutil/is-section-quarter.c index 1fe28d2..fd076f8 100644 --- a/testutil/is-section-quarter.c +++ b/testutil/is-section-quarter.c @@ -1,14 +1,24 @@ /* See LICENSE file for copyright and license details. */ #include "../libsyscalls.h" +#include <stdio.h> #include <stdlib.h> +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wunsafe-buffer-usage" /* clang is just being silly */ +#endif + int -main(int argc, char *argv[]) +main(int argc, char **argv) { - enum libsyscalls_datatype_section sec; - (void) argc; - sec = (enum libsyscalls_datatype_section)atoi(argv[1]); - return !LIBSYSCALLS_IS_SECTION_QUARTER(sec); + int sec; + + if (argc != 2) { + fprintf(stderr, "usage error\n"); + return 3; + } + + sec = atoi(argv[1]); + return !LIBSYSCALLS_IS_SECTION_QUARTER((enum libsyscalls_datatype_section)sec); } diff --git a/testutil/list-errors.c b/testutil/list-errors.c index 5738b06..365e091 100644 --- a/testutil/list-errors.c +++ b/testutil/list-errors.c @@ -6,8 +6,15 @@ int -main(void) +main(int argc, char **argv) { + (void) argv; + + if (argc != 1) { + fprintf(stderr, "usage error\n"); + return 3; + } + #define X(N, S)\ printf("%li %s %s\n", (long int)N, #N, S) LIBSYSCALLS_LIST_ERRORS(X, ;); diff --git a/testutil/perror-all.c b/testutil/perror-all.c index 2b37cff..d7ee45b 100644 --- a/testutil/perror-all.c +++ b/testutil/perror-all.c @@ -4,13 +4,20 @@ #include <stddef.h> #include <stdio.h> +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wunsafe-buffer-usage" /* clang is just being silly */ +#endif + int -main(int argc, char *argv[]) +main(int argc, char **argv) { size_t i, count; - (void) argc; + if (argc < 1 || argc > 2) { + fprintf(stderr, "usage error\n"); + return 3; + } #define X(...) 1 count = (LIBSYSCALLS_LIST_ERRORS(X, +)); diff --git a/testutil/perror-bad.c b/testutil/perror-bad.c index 55d36d3..338781b 100644 --- a/testutil/perror-bad.c +++ b/testutil/perror-bad.c @@ -4,13 +4,20 @@ #include <stddef.h> #include <stdio.h> +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wunsafe-buffer-usage" /* clang is just being silly */ +#endif + int -main(int argc, char *argv[]) +main(int argc, char **argv) { size_t count; - (void) argc; + if (argc < 1 || argc > 2) { + fprintf(stderr, "usage error\n"); + return 3; + } #define X(...) 1 count = (LIBSYSCALLS_LIST_ERRORS(X, +)); diff --git a/testutil/strerror-all.c b/testutil/strerror-all.c index b875392..75a3d77 100644 --- a/testutil/strerror-all.c +++ b/testutil/strerror-all.c @@ -6,10 +6,17 @@ int -main(void) +main(int argc, char **argv) { size_t i, count; + (void) argv; + + if (argc != 1) { + fprintf(stderr, "usage error\n"); + return 3; + } + #define X(...) 1 count = (LIBSYSCALLS_LIST_ERRORS(X, +)); #undef X diff --git a/testutil/strerror-bad.c b/testutil/strerror-bad.c index 23d8836..0436d29 100644 --- a/testutil/strerror-bad.c +++ b/testutil/strerror-bad.c @@ -6,10 +6,17 @@ int -main(void) +main(int argc, char **argv) { size_t count; + (void) argv; + + if (argc != 1) { + fprintf(stderr, "usage error\n"); + return 3; + } + #define X(...) 1 count = (LIBSYSCALLS_LIST_ERRORS(X, +)); #undef X |