summaryrefslogtreecommitdiffstats
path: root/usr.sbin/vmctl
diff options
context:
space:
mode:
authorkn <kn@openbsd.org>2019-12-17 09:43:00 +0000
committerkn <kn@openbsd.org>2019-12-17 09:43:00 +0000
commit4a2cfa82427b28530c63909a5d7acfe524aae473 (patch)
tree4ce0be357fc8d6cba2c961bf8a767337d4abd7ac /usr.sbin/vmctl
parentAdd code to parse DDR4 and LPDDR3/4 SPD memories. (diff)
downloadwireguard-openbsd-4a2cfa82427b28530c63909a5d7acfe524aae473.tar.xz
wireguard-openbsd-4a2cfa82427b28530c63909a5d7acfe524aae473.zip
Use local variable isntead of function parameter
The parse_size() wrapper around scan_scaled(3) writes its intermediate result to the function argument which is always passed as literal zero. This seems odd, the function parameter has no meaning but merely serves as storage, so let's use a proper function scoped variable instead. OK pd
Diffstat (limited to 'usr.sbin/vmctl')
-rw-r--r--usr.sbin/vmctl/main.c10
-rw-r--r--usr.sbin/vmctl/vmctl.h4
2 files changed, 8 insertions, 6 deletions
diff --git a/usr.sbin/vmctl/main.c b/usr.sbin/vmctl/main.c
index 1a5264b84fd..59f0c3af5e4 100644
--- a/usr.sbin/vmctl/main.c
+++ b/usr.sbin/vmctl/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.59 2019/10/27 08:59:48 kn Exp $ */
+/* $OpenBSD: main.c,v 1.60 2019/12/17 09:43:00 kn Exp $ */
/*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
@@ -407,8 +407,10 @@ parse_network(struct parse_result *res, char *word)
}
int
-parse_size(struct parse_result *res, char *word, long long val)
+parse_size(struct parse_result *res, char *word)
{
+ long long val = 0;
+
if (word != NULL) {
if (scan_scaled(word, &val) != 0) {
warn("invalid size: %s", word);
@@ -576,7 +578,7 @@ ctl_create(struct parse_result *res, int argc, char *argv[])
err(1, "unveil");
break;
case 's':
- if (parse_size(res, optarg, 0) != 0)
+ if (parse_size(res, optarg) != 0)
errx(1, "invalid size: %s", optarg);
break;
default:
@@ -872,7 +874,7 @@ ctl_start(struct parse_result *res, int argc, char *argv[])
case 'm':
if (res->size)
errx(1, "memory specified multiple times");
- if (parse_size(res, optarg, 0) != 0)
+ if (parse_size(res, optarg) != 0)
errx(1, "invalid memory size: %s", optarg);
break;
case 'n':
diff --git a/usr.sbin/vmctl/vmctl.h b/usr.sbin/vmctl/vmctl.h
index e20ce1a43d4..beb65eae6d8 100644
--- a/usr.sbin/vmctl/vmctl.h
+++ b/usr.sbin/vmctl/vmctl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmctl.h,v 1.32 2019/05/11 23:07:46 jasper Exp $ */
+/* $OpenBSD: vmctl.h,v 1.33 2019/12/17 09:43:00 kn Exp $ */
/*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
@@ -77,7 +77,7 @@ struct imsgbuf *ibuf;
int vmmaction(struct parse_result *);
int parse_ifs(struct parse_result *, char *, int);
int parse_network(struct parse_result *, char *);
-int parse_size(struct parse_result *, char *, long long);
+int parse_size(struct parse_result *, char *);
int parse_disktype(const char *, const char **);
int parse_disk(struct parse_result *, char *, int);
int parse_vmid(struct parse_result *, char *, int);