From 8a42e9c5796ef963b599d51b931367b6e22be4a1 Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Tue, 9 Apr 2019 09:55:05 +0200 Subject: Collapse the three uint32 cases into one --- common.c | 17 ++--------------- 1 file 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); -- cgit v1.2.3-59-g8ed1b