Fix output of uninitialized strings
Commit ffad4116b9
removed the "scratch buffer"
from check_params, but didn't care for the error messages which actually
included this string to tell the user which option was wrong. Now this string
is uninitialized, so this patch removes it from the message.
This means that the user is only told the whole parameter string and has to
pick the wrong option by himself as the callers of check_params can't know this
value any more. An alternative approach would be to revert that commit and do
whatever is needed to fix the original problem without changing check_params.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
7696d1ecd0
commit
8cf07dcbe7
30
net.c
30
net.c
@ -1792,8 +1792,7 @@ int net_client_init(const char *device, const char *p)
|
|||||||
int idx = nic_get_free_idx();
|
int idx = nic_get_free_idx();
|
||||||
|
|
||||||
if (check_params(nic_params, p) < 0) {
|
if (check_params(nic_params, p) < 0) {
|
||||||
fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n",
|
fprintf(stderr, "qemu: invalid parameter in '%s'\n", p);
|
||||||
buf, p);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (idx == -1 || nb_nics >= MAX_NICS) {
|
if (idx == -1 || nb_nics >= MAX_NICS) {
|
||||||
@ -1843,8 +1842,7 @@ int net_client_init(const char *device, const char *p)
|
|||||||
"vlan", "name", "hostname", "restrict", "ip", NULL
|
"vlan", "name", "hostname", "restrict", "ip", NULL
|
||||||
};
|
};
|
||||||
if (check_params(slirp_params, p) < 0) {
|
if (check_params(slirp_params, p) < 0) {
|
||||||
fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n",
|
fprintf(stderr, "qemu: invalid parameter in '%s'\n", p);
|
||||||
buf, p);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (get_param_value(buf, sizeof(buf), "hostname", p)) {
|
if (get_param_value(buf, sizeof(buf), "hostname", p)) {
|
||||||
@ -1894,8 +1892,7 @@ int net_client_init(const char *device, const char *p)
|
|||||||
char ifname[64];
|
char ifname[64];
|
||||||
|
|
||||||
if (check_params(tap_params, p) < 0) {
|
if (check_params(tap_params, p) < 0) {
|
||||||
fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n",
|
fprintf(stderr, "qemu: invalid parameter in '%s'\n", p);
|
||||||
buf, p);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) {
|
if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) {
|
||||||
@ -1915,8 +1912,7 @@ int net_client_init(const char *device, const char *p)
|
|||||||
vlan->nb_host_devs++;
|
vlan->nb_host_devs++;
|
||||||
if (get_param_value(buf, sizeof(buf), "fd", p) > 0) {
|
if (get_param_value(buf, sizeof(buf), "fd", p) > 0) {
|
||||||
if (check_params(fd_params, p) < 0) {
|
if (check_params(fd_params, p) < 0) {
|
||||||
fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n",
|
fprintf(stderr, "qemu: invalid parameter in '%s'\n", p);
|
||||||
buf, p);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fd = strtol(buf, NULL, 0);
|
fd = strtol(buf, NULL, 0);
|
||||||
@ -1928,8 +1924,7 @@ int net_client_init(const char *device, const char *p)
|
|||||||
"vlan", "name", "ifname", "script", "downscript", NULL
|
"vlan", "name", "ifname", "script", "downscript", NULL
|
||||||
};
|
};
|
||||||
if (check_params(tap_params, p) < 0) {
|
if (check_params(tap_params, p) < 0) {
|
||||||
fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n",
|
fprintf(stderr, "qemu: invalid parameter in '%s'\n", p);
|
||||||
buf, p);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) {
|
if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) {
|
||||||
@ -1949,8 +1944,7 @@ int net_client_init(const char *device, const char *p)
|
|||||||
if (get_param_value(buf, sizeof(buf), "fd", p) > 0) {
|
if (get_param_value(buf, sizeof(buf), "fd", p) > 0) {
|
||||||
int fd;
|
int fd;
|
||||||
if (check_params(fd_params, p) < 0) {
|
if (check_params(fd_params, p) < 0) {
|
||||||
fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n",
|
fprintf(stderr, "qemu: invalid parameter in '%s'\n", p);
|
||||||
buf, p);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fd = strtol(buf, NULL, 0);
|
fd = strtol(buf, NULL, 0);
|
||||||
@ -1962,8 +1956,7 @@ int net_client_init(const char *device, const char *p)
|
|||||||
"vlan", "name", "listen", NULL
|
"vlan", "name", "listen", NULL
|
||||||
};
|
};
|
||||||
if (check_params(listen_params, p) < 0) {
|
if (check_params(listen_params, p) < 0) {
|
||||||
fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n",
|
fprintf(stderr, "qemu: invalid parameter in '%s'\n", p);
|
||||||
buf, p);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ret = net_socket_listen_init(vlan, device, name, buf);
|
ret = net_socket_listen_init(vlan, device, name, buf);
|
||||||
@ -1972,8 +1965,7 @@ int net_client_init(const char *device, const char *p)
|
|||||||
"vlan", "name", "connect", NULL
|
"vlan", "name", "connect", NULL
|
||||||
};
|
};
|
||||||
if (check_params(connect_params, p) < 0) {
|
if (check_params(connect_params, p) < 0) {
|
||||||
fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n",
|
fprintf(stderr, "qemu: invalid parameter in '%s'\n", p);
|
||||||
buf, p);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ret = net_socket_connect_init(vlan, device, name, buf);
|
ret = net_socket_connect_init(vlan, device, name, buf);
|
||||||
@ -1982,8 +1974,7 @@ int net_client_init(const char *device, const char *p)
|
|||||||
"vlan", "name", "mcast", NULL
|
"vlan", "name", "mcast", NULL
|
||||||
};
|
};
|
||||||
if (check_params(mcast_params, p) < 0) {
|
if (check_params(mcast_params, p) < 0) {
|
||||||
fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n",
|
fprintf(stderr, "qemu: invalid parameter in '%s'\n", p);
|
||||||
buf, p);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ret = net_socket_mcast_init(vlan, device, name, buf);
|
ret = net_socket_mcast_init(vlan, device, name, buf);
|
||||||
@ -2003,8 +1994,7 @@ int net_client_init(const char *device, const char *p)
|
|||||||
int vde_port, vde_mode;
|
int vde_port, vde_mode;
|
||||||
|
|
||||||
if (check_params(vde_params, p) < 0) {
|
if (check_params(vde_params, p) < 0) {
|
||||||
fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n",
|
fprintf(stderr, "qemu: invalid parameter in '%s'\n", p);
|
||||||
buf, p);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
vlan->nb_host_devs++;
|
vlan->nb_host_devs++;
|
||||||
|
3
vl.c
3
vl.c
@ -2227,8 +2227,7 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque)
|
|||||||
NULL };
|
NULL };
|
||||||
|
|
||||||
if (check_params(params, str) < 0) {
|
if (check_params(params, str) < 0) {
|
||||||
fprintf(stderr, "qemu: unknown parameter '%s' in '%s'\n",
|
fprintf(stderr, "qemu: unknown parameter in '%s'\n", str);
|
||||||
buf, str);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user