summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-08-03 14:02:04 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-08-03 22:02:32 -0400
commitde292aa1dd1942e151ff034fcb88504a86742f97 (patch)
treef3219829fac7ef893bbc5a772ca7e853899c28a0 /src
parent7263f72499e962b3fd54cdb7c79d49ca72121ede (diff)
resolve-host: make arg_type an int
We are using it also to store _DNS_TYPE_INVALID, so it should be signed.
Diffstat (limited to 'src')
-rw-r--r--src/resolve-host/resolve-host.c8
-rw-r--r--src/resolve/dns-type.c8
-rw-r--r--src/resolve/dns-type.h6
3 files changed, 10 insertions, 12 deletions
diff --git a/src/resolve-host/resolve-host.c b/src/resolve-host/resolve-host.c
index 987b43a0cb..4b46cdfa16 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;
@@ -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);
@@ -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;
}
+ assert(arg_type > 0 && (uint16_t) arg_type == arg_type);
break;
diff --git a/src/resolve/dns-type.c b/src/resolve/dns-type.c
index 271a7e176b..a3e740896f 100644
--- a/src/resolve/dns-type.c
+++ b/src/resolve/dns-type.c
@@ -32,16 +32,14 @@ lookup_dns_type (register const char *str, register unsigned int len);
#include "dns_type-from-name.h"
#include "dns_type-to-name.h"
-int dns_type_from_string(const char *s, uint16_t *type) {
+int dns_type_from_string(const char *s) {
const struct dns_type_name *sc;
assert(s);
- assert(type);
sc = lookup_dns_type(s, strlen(s));
if (!sc)
- return -EINVAL;
+ return _DNS_TYPE_INVALID;
- *type = sc->id;
- return 0;
+ return sc->id;
}
diff --git a/src/resolve/dns-type.h b/src/resolve/dns-type.h
index 66063153a0..86951d233a 100644
--- a/src/resolve/dns-type.h
+++ b/src/resolve/dns-type.h
@@ -21,12 +21,10 @@
#pragma once
-#include <inttypes.h>
-
#include "macro.h"
-const char *dns_type_to_string(uint16_t type);
-int dns_type_from_string(const char *s, uint16_t *type);
+const char *dns_type_to_string(int type);
+int dns_type_from_string(const char *s);
/* DNS record types, taken from
* http://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml.