X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fresolve-host%2Fresolve-host.c;h=43c8a229eb09deddd57709ff39ee9565693c1cc6;hb=590baf91f3fc9f0edd7986c66da00be10e48a25d;hp=1063790640f2827990ba09038a2e630a79025e43;hpb=b93312f5960b276bae915906ccde36f545bae3e0;p=elogind.git diff --git a/src/resolve-host/resolve-host.c b/src/resolve-host/resolve-host.c index 106379064..43c8a229e 100644 --- a/src/resolve-host/resolve-host.c +++ b/src/resolve-host/resolve-host.c @@ -37,7 +37,7 @@ static int arg_family = AF_UNSPEC; static int arg_ifindex = 0; -static uint16_t arg_type = 0; +static int arg_type = 0; static uint16_t arg_class = 0; static bool arg_legend = true; @@ -105,7 +105,7 @@ static int resolve_host(sd_bus *bus, const char *name) { return bus_log_parse_error(r); if (!IN_SET(family, AF_INET, AF_INET6)) { - log_debug("%s: skipping entry with family %hu (%s)", name, family, af_to_name(family) ?: "unknown"); + log_debug("%s: skipping entry with family %d (%s)", name, family, af_to_name(family) ?: "unknown"); continue; } @@ -316,6 +316,7 @@ static int resolve_record(sd_bus *bus, const char *name) { if (r < 0) return bus_log_create_error(r); + assert((uint16_t) arg_type == arg_type); r = sd_bus_message_append(req, "sqq", name, arg_class, arg_type); if (r < 0) return bus_log_create_error(r); @@ -448,7 +449,7 @@ static int parse_argv(int argc, char *argv[]) { assert(argc >= 0); assert(argv); - while ((c = getopt_long(argc, argv, "h46i:t:c:", options, NULL)) >= 0) { + while ((c = getopt_long(argc, argv, "h46i:t:c:", options, NULL)) >= 0) switch(c) { case 'h': @@ -482,11 +483,12 @@ static int parse_argv(int argc, char *argv[]) { return 0; } - r = dns_type_from_string(optarg, &arg_type); - if (r < 0) { + arg_type = dns_type_from_string(optarg); + if (arg_type < 0) { log_error("Failed to parse RR record type %s", optarg); - return r; + return arg_type; } + assert(arg_type > 0 && (uint16_t) arg_type == arg_type); break; @@ -514,7 +516,6 @@ static int parse_argv(int argc, char *argv[]) { default: assert_not_reached("Unhandled option"); } - } if (arg_type == 0 && arg_class != 0) { log_error("--class= may only be used in conjunction with --type=");