diff options
author | Rob Austein <sra@hactrn.net> | 2015-07-05 18:10:54 -0400 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2015-07-05 18:10:54 -0400 |
commit | 48565020c549105baed47ef4fcb7630cccd7ffa1 (patch) | |
tree | 2d2e1551dd63e91b2e3d5f85294ea8436ed41b3b /utils | |
parent | 526e451fe43a8e3de4f7d35bc7beb833f5bd6ac1 (diff) |
Use C99 variadic macro as safety wrapper around variadic function.
Are we having fun yet?
Diffstat (limited to 'utils')
-rw-r--r-- | utils/eim_peek_poke.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/utils/eim_peek_poke.c b/utils/eim_peek_poke.c index a6316fe..2511483 100644 --- a/utils/eim_peek_poke.c +++ b/utils/eim_peek_poke.c @@ -40,7 +40,10 @@ #include "novena-eim.h" -static int string_match(const char *s1, ...) +#define string_match(...) \ + _string_match(__VA_ARGS__, NULL) + +static int _string_match(const char *s1, ...) { const char *s2; @@ -91,7 +94,7 @@ int main(int argc, char *argv[]) off_t offset = 0; uint32_t value; - if (argc == 1 || string_match(argv[1], "-?", "-h", "--help", NULL)) + if (argc == 1 || string_match(argv[1], "-?", "-h", "--help")) usage(EXIT_SUCCESS, argv[0]); if (eim_setup() != 0) { @@ -99,14 +102,14 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } - if (string_match(argv[1], "r", "-r", "--read", "--peek", NULL)) { + if (string_match(argv[1], "r", "-r", "--read", "--peek")) { if (argc != 3 || !parse_offset(argv[2], &offset)) usage(EXIT_FAILURE, argv[0]); eim_read_32(offset, &value); printf("%08x\n", value); } - else if (string_match(argv[1], "w", "-w", "--write", "--poke", NULL)) { + else if (string_match(argv[1], "w", "-w", "--write", "--poke")) { if (argc != 4 || !parse_offset(argv[2], &offset) || !parse_value(argv[3], &value)) usage(EXIT_FAILURE, argv[0]); eim_write_32(offset, &value); |