aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2019-04-09 09:55:05 +0200
committerLinus Nordberg <linus@nordberg.se>2019-04-09 09:55:05 +0200
commit8a42e9c5796ef963b599d51b931367b6e22be4a1 (patch)
tree8f5ca1c36d70b4f5c22a5dac76f7f3c6d8ea2b4d
parentHelp with running the server under gdb (diff)
downloadwg-dynamic-8a42e9c5796ef963b599d51b931367b6e22be4a1.tar.xz
wg-dynamic-8a42e9c5796ef963b599d51b931367b6e22be4a1.zip
Collapse the three uint32 cases into one
-rw-r--r--common.c17
1 files changed, 2 insertions, 15 deletions
diff --git a/common.c b/common.c
index 5b5bb41..6426ce9 100644
--- a/common.c
+++ b/common.c
@@ -71,33 +71,20 @@ static struct wg_dynamic_attr *parse_value(enum wg_dynamic_key key, char *value)
break;
case WGKEY_LEASESTART:
- len = sizeof data.uint32;
- uresult = strtoumax(value, &endptr, 10);
- if (uresult > UINT32_MAX || *endptr != '\0')
- return NULL;
-
- data.uint32 = (uint32_t)uresult;
- break;
case WGKEY_LEASETIME:
- len = sizeof data.uint32;
- uresult = strtoumax(value, &endptr, 10);
- if (uresult > UINT32_MAX || *endptr != '\0')
- return NULL;
-
- data.uint32 = (uint32_t)uresult;
- break;
case WGKEY_ERRNO:
len = sizeof data.uint32;
uresult = strtoumax(value, &endptr, 10);
if (uresult > UINT32_MAX || *endptr != '\0')
return NULL;
-
data.uint32 = (uint32_t)uresult;
+
break;
case WGKEY_ERRMSG:
strncpy(data.errmsg, value, sizeof data.errmsg);
len = MIN(sizeof data.errmsg,
strlen(value) + 1); /* Copying the NUL byte too. */
+
break;
default:
debug("Invalid key %d, aborting\n", key);