On Fri, Dec 06, 2019 at 06:49:52PM +0100, Klemens Nanni wrote:
> 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?
Ping.


Index: main.c
===================================================================
RCS file: /cvs/src/usr.sbin/vmctl/main.c,v
retrieving revision 1.59
diff -u -p -r1.59 main.c
--- main.c      27 Oct 2019 08:59:48 -0000      1.59
+++ main.c      16 Dec 2019 22:41:18 -0000
@@ -407,8 +407,10 @@ parse_network(struct parse_result *res, 
 }
 
 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
                                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 
                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':
Index: vmctl.h
===================================================================
RCS file: /cvs/src/usr.sbin/vmctl/vmctl.h,v
retrieving revision 1.32
diff -u -p -r1.32 vmctl.h
--- vmctl.h     11 May 2019 23:07:46 -0000      1.32
+++ vmctl.h     16 Dec 2019 22:41:18 -0000
@@ -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);

Reply via email to