Commit 9036de1a8ad6c565a4e5d8cd124ad8dd05e7d4d4

Authored by aliguori
1 parent eefb4091

Remove some useless malloc() checking (Mark McLoughlin)

Now that we abort() on malloc, neither qemu_find_vlan() nor
net_tap_fd_init() can fail.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7146 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 3 additions and 13 deletions
@@ -1015,8 +1015,6 @@ static int net_tap_init(VLANState *vlan, const char *model, @@ -1015,8 +1015,6 @@ static int net_tap_init(VLANState *vlan, const char *model,
1015 return -1; 1015 return -1;
1016 } 1016 }
1017 s = net_tap_fd_init(vlan, model, name, fd); 1017 s = net_tap_fd_init(vlan, model, name, fd);
1018 - if (!s)  
1019 - return -1;  
1020 snprintf(s->vc->info_str, sizeof(s->vc->info_str), 1018 snprintf(s->vc->info_str, sizeof(s->vc->info_str),
1021 "ifname=%s,script=%s,downscript=%s", 1019 "ifname=%s,script=%s,downscript=%s",
1022 ifname, setup_script, down_script); 1020 ifname, setup_script, down_script);
@@ -1596,10 +1594,7 @@ int net_client_init(const char *device, const char *p) @@ -1596,10 +1594,7 @@ int net_client_init(const char *device, const char *p)
1596 vlan_id = strtol(buf, NULL, 0); 1594 vlan_id = strtol(buf, NULL, 0);
1597 } 1595 }
1598 vlan = qemu_find_vlan(vlan_id); 1596 vlan = qemu_find_vlan(vlan_id);
1599 - if (!vlan) {  
1600 - fprintf(stderr, "Could not create vlan %d\n", vlan_id);  
1601 - return -1;  
1602 - } 1597 +
1603 if (get_param_value(buf, sizeof(buf), "name", p)) { 1598 if (get_param_value(buf, sizeof(buf), "name", p)) {
1604 name = strdup(buf); 1599 name = strdup(buf);
1605 } 1600 }
@@ -1707,9 +1702,8 @@ int net_client_init(const char *device, const char *p) @@ -1707,9 +1702,8 @@ int net_client_init(const char *device, const char *p)
1707 if (get_param_value(buf, sizeof(buf), "fd", p) > 0) { 1702 if (get_param_value(buf, sizeof(buf), "fd", p) > 0) {
1708 fd = strtol(buf, NULL, 0); 1703 fd = strtol(buf, NULL, 0);
1709 fcntl(fd, F_SETFL, O_NONBLOCK); 1704 fcntl(fd, F_SETFL, O_NONBLOCK);
1710 - ret = -1;  
1711 - if (net_tap_fd_init(vlan, device, name, fd))  
1712 - ret = 0; 1705 + net_tap_fd_init(vlan, device, name, fd);
  1706 + ret = 0;
1713 } else { 1707 } else {
1714 if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) { 1708 if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) {
1715 ifname[0] = '\0'; 1709 ifname[0] = '\0';
@@ -1825,10 +1819,6 @@ void net_host_device_remove(Monitor *mon, int vlan_id, const char *device) @@ -1825,10 +1819,6 @@ void net_host_device_remove(Monitor *mon, int vlan_id, const char *device)
1825 VLANClientState *vc; 1819 VLANClientState *vc;
1826 1820
1827 vlan = qemu_find_vlan(vlan_id); 1821 vlan = qemu_find_vlan(vlan_id);
1828 - if (!vlan) {  
1829 - monitor_printf(mon, "can't find vlan %d\n", vlan_id);  
1830 - return;  
1831 - }  
1832 1822
1833 for(vc = vlan->first_client; vc != NULL; vc = vc->next) 1823 for(vc = vlan->first_client; vc != NULL; vc = vc->next)
1834 if (!strcmp(vc->name, device)) 1824 if (!strcmp(vc->name, device))