Commit 8cf07dcbe7691dbe4f47563058659dba6ef66b05
Committed by
Anthony Liguori
1 parent
7696d1ec
Fix output of uninitialized strings
Commit ffad4116 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>
Showing
2 changed files
with
11 additions
and
22 deletions
net.c
... | ... | @@ -1792,8 +1792,7 @@ int net_client_init(const char *device, const char *p) |
1792 | 1792 | int idx = nic_get_free_idx(); |
1793 | 1793 | |
1794 | 1794 | if (check_params(nic_params, p) < 0) { |
1795 | - fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n", | |
1796 | - buf, p); | |
1795 | + fprintf(stderr, "qemu: invalid parameter in '%s'\n", p); | |
1797 | 1796 | return -1; |
1798 | 1797 | } |
1799 | 1798 | if (idx == -1 || nb_nics >= MAX_NICS) { |
... | ... | @@ -1843,8 +1842,7 @@ int net_client_init(const char *device, const char *p) |
1843 | 1842 | "vlan", "name", "hostname", "restrict", "ip", NULL |
1844 | 1843 | }; |
1845 | 1844 | if (check_params(slirp_params, p) < 0) { |
1846 | - fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n", | |
1847 | - buf, p); | |
1845 | + fprintf(stderr, "qemu: invalid parameter in '%s'\n", p); | |
1848 | 1846 | return -1; |
1849 | 1847 | } |
1850 | 1848 | if (get_param_value(buf, sizeof(buf), "hostname", p)) { |
... | ... | @@ -1894,8 +1892,7 @@ int net_client_init(const char *device, const char *p) |
1894 | 1892 | char ifname[64]; |
1895 | 1893 | |
1896 | 1894 | if (check_params(tap_params, p) < 0) { |
1897 | - fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n", | |
1898 | - buf, p); | |
1895 | + fprintf(stderr, "qemu: invalid parameter in '%s'\n", p); | |
1899 | 1896 | return -1; |
1900 | 1897 | } |
1901 | 1898 | if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) { |
... | ... | @@ -1915,8 +1912,7 @@ int net_client_init(const char *device, const char *p) |
1915 | 1912 | vlan->nb_host_devs++; |
1916 | 1913 | if (get_param_value(buf, sizeof(buf), "fd", p) > 0) { |
1917 | 1914 | if (check_params(fd_params, p) < 0) { |
1918 | - fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n", | |
1919 | - buf, p); | |
1915 | + fprintf(stderr, "qemu: invalid parameter in '%s'\n", p); | |
1920 | 1916 | return -1; |
1921 | 1917 | } |
1922 | 1918 | fd = strtol(buf, NULL, 0); |
... | ... | @@ -1928,8 +1924,7 @@ int net_client_init(const char *device, const char *p) |
1928 | 1924 | "vlan", "name", "ifname", "script", "downscript", NULL |
1929 | 1925 | }; |
1930 | 1926 | if (check_params(tap_params, p) < 0) { |
1931 | - fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n", | |
1932 | - buf, p); | |
1927 | + fprintf(stderr, "qemu: invalid parameter in '%s'\n", p); | |
1933 | 1928 | return -1; |
1934 | 1929 | } |
1935 | 1930 | if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) { |
... | ... | @@ -1949,8 +1944,7 @@ int net_client_init(const char *device, const char *p) |
1949 | 1944 | if (get_param_value(buf, sizeof(buf), "fd", p) > 0) { |
1950 | 1945 | int fd; |
1951 | 1946 | if (check_params(fd_params, p) < 0) { |
1952 | - fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n", | |
1953 | - buf, p); | |
1947 | + fprintf(stderr, "qemu: invalid parameter in '%s'\n", p); | |
1954 | 1948 | return -1; |
1955 | 1949 | } |
1956 | 1950 | fd = strtol(buf, NULL, 0); |
... | ... | @@ -1962,8 +1956,7 @@ int net_client_init(const char *device, const char *p) |
1962 | 1956 | "vlan", "name", "listen", NULL |
1963 | 1957 | }; |
1964 | 1958 | if (check_params(listen_params, p) < 0) { |
1965 | - fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n", | |
1966 | - buf, p); | |
1959 | + fprintf(stderr, "qemu: invalid parameter in '%s'\n", p); | |
1967 | 1960 | return -1; |
1968 | 1961 | } |
1969 | 1962 | ret = net_socket_listen_init(vlan, device, name, buf); |
... | ... | @@ -1972,8 +1965,7 @@ int net_client_init(const char *device, const char *p) |
1972 | 1965 | "vlan", "name", "connect", NULL |
1973 | 1966 | }; |
1974 | 1967 | if (check_params(connect_params, p) < 0) { |
1975 | - fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n", | |
1976 | - buf, p); | |
1968 | + fprintf(stderr, "qemu: invalid parameter in '%s'\n", p); | |
1977 | 1969 | return -1; |
1978 | 1970 | } |
1979 | 1971 | ret = net_socket_connect_init(vlan, device, name, buf); |
... | ... | @@ -1982,8 +1974,7 @@ int net_client_init(const char *device, const char *p) |
1982 | 1974 | "vlan", "name", "mcast", NULL |
1983 | 1975 | }; |
1984 | 1976 | if (check_params(mcast_params, p) < 0) { |
1985 | - fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n", | |
1986 | - buf, p); | |
1977 | + fprintf(stderr, "qemu: invalid parameter in '%s'\n", p); | |
1987 | 1978 | return -1; |
1988 | 1979 | } |
1989 | 1980 | ret = net_socket_mcast_init(vlan, device, name, buf); |
... | ... | @@ -2003,8 +1994,7 @@ int net_client_init(const char *device, const char *p) |
2003 | 1994 | int vde_port, vde_mode; |
2004 | 1995 | |
2005 | 1996 | if (check_params(vde_params, p) < 0) { |
2006 | - fprintf(stderr, "qemu: invalid parameter '%s' in '%s'\n", | |
2007 | - buf, p); | |
1997 | + fprintf(stderr, "qemu: invalid parameter in '%s'\n", p); | |
2008 | 1998 | return -1; |
2009 | 1999 | } |
2010 | 2000 | vlan->nb_host_devs++; | ... | ... |
vl.c
... | ... | @@ -2227,8 +2227,7 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque) |
2227 | 2227 | NULL }; |
2228 | 2228 | |
2229 | 2229 | if (check_params(params, str) < 0) { |
2230 | - fprintf(stderr, "qemu: unknown parameter '%s' in '%s'\n", | |
2231 | - buf, str); | |
2230 | + fprintf(stderr, "qemu: unknown parameter in '%s'\n", str); | |
2232 | 2231 | return -1; |
2233 | 2232 | } |
2234 | 2233 | ... | ... |