From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lu7zW-0008Ig-5x for qemu-devel@nongnu.org; Wed, 15 Apr 2009 12:29:38 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lu7zR-0008Fl-U7 for qemu-devel@nongnu.org; Wed, 15 Apr 2009 12:29:37 -0400 Received: from [199.232.76.173] (port=54430 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lu7zR-0008FS-8r for qemu-devel@nongnu.org; Wed, 15 Apr 2009 12:29:33 -0400 Received: from mail07.svc.cra.dublin.eircom.net ([159.134.118.23]:37115) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1Lu7zQ-00062Q-KD for qemu-devel@nongnu.org; Wed, 15 Apr 2009 12:29:32 -0400 From: Mark McLoughlin Date: Wed, 15 Apr 2009 17:29:25 +0100 Message-Id: <1239812969-8320-6-git-send-email-markmc@redhat.com> In-Reply-To: <1239812969-8320-5-git-send-email-markmc@redhat.com> References: <1239812969-8320-1-git-send-email-markmc@redhat.com> <1239812969-8320-2-git-send-email-markmc@redhat.com> <1239812969-8320-3-git-send-email-markmc@redhat.com> <1239812969-8320-4-git-send-email-markmc@redhat.com> <1239812969-8320-5-git-send-email-markmc@redhat.com> Subject: [Qemu-devel] [PATCH 5/9] Remove some useless malloc() checking Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Jan Kiszka , qemu-devel@nongnu.org, Mark McLoughlin Now that we abort() on malloc, neither qemu_find_vlan() nor net_tap_fd_init() can fail. Signed-off-by: Mark McLoughlin --- net.c | 16 +++------------- 1 files changed, 3 insertions(+), 13 deletions(-) diff --git a/net.c b/net.c index 2383b10..34ec4c8 100644 --- a/net.c +++ b/net.c @@ -1015,8 +1015,6 @@ static int net_tap_init(VLANState *vlan, const char *model, return -1; } s = net_tap_fd_init(vlan, model, name, fd); - if (!s) - return -1; snprintf(s->vc->info_str, sizeof(s->vc->info_str), "ifname=%s,script=%s,downscript=%s", ifname, setup_script, down_script); @@ -1596,10 +1594,7 @@ int net_client_init(const char *device, const char *p) vlan_id = strtol(buf, NULL, 0); } vlan = qemu_find_vlan(vlan_id); - if (!vlan) { - fprintf(stderr, "Could not create vlan %d\n", vlan_id); - return -1; - } + if (get_param_value(buf, sizeof(buf), "name", p)) { name = strdup(buf); } @@ -1707,9 +1702,8 @@ int net_client_init(const char *device, const char *p) if (get_param_value(buf, sizeof(buf), "fd", p) > 0) { fd = strtol(buf, NULL, 0); fcntl(fd, F_SETFL, O_NONBLOCK); - ret = -1; - if (net_tap_fd_init(vlan, device, name, fd)) - ret = 0; + net_tap_fd_init(vlan, device, name, fd); + ret = 0; } else { if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) { ifname[0] = '\0'; @@ -1825,10 +1819,6 @@ void net_host_device_remove(Monitor *mon, int vlan_id, const char *device) VLANClientState *vc; vlan = qemu_find_vlan(vlan_id); - if (!vlan) { - monitor_printf(mon, "can't find vlan %d\n", vlan_id); - return; - } for(vc = vlan->first_client; vc != NULL; vc = vc->next) if (!strcmp(vc->name, device)) -- 1.6.0.6