diff options
author | Linus Nordberg <linus@nordberg.se> | 2019-04-09 09:55:05 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordberg.se> | 2019-04-09 09:55:05 +0200 |
commit | 8a42e9c5796ef963b599d51b931367b6e22be4a1 (patch) | |
tree | 8f5ca1c36d70b4f5c22a5dac76f7f3c6d8ea2b4d | |
parent | Help with running the server under gdb (diff) | |
download | wg-dynamic-8a42e9c5796ef963b599d51b931367b6e22be4a1.tar.xz wg-dynamic-8a42e9c5796ef963b599d51b931367b6e22be4a1.zip |
Collapse the three uint32 cases into one
-rw-r--r-- | common.c | 17 |
1 files changed, 2 insertions, 15 deletions
@@ -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); |