From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lu8g3-0004GE-O0 for qemu-devel@nongnu.org; Wed, 15 Apr 2009 13:13:35 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lu8fz-0004Ev-68 for qemu-devel@nongnu.org; Wed, 15 Apr 2009 13:13:35 -0400 Received: from [199.232.76.173] (port=36392 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lu8fz-0004Ep-0x for qemu-devel@nongnu.org; Wed, 15 Apr 2009 13:13:31 -0400 Received: from lizzard.sbs.de ([194.138.37.39]:19986) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lu8fy-0005Yb-ID for qemu-devel@nongnu.org; Wed, 15 Apr 2009 13:13:30 -0400 Message-ID: <49E615B8.6020203@siemens.com> Date: Wed, 15 Apr 2009 19:13:28 +0200 From: Jan Kiszka MIME-Version: 1.0 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> <1239812969-8320-6-git-send-email-markmc@redhat.com> In-Reply-To: <1239812969-8320-6-git-send-email-markmc@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [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: Mark McLoughlin Cc: Anthony Liguori , qemu-devel@nongnu.org Mark McLoughlin wrote: > 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); Maybe it would be a good idea to rename this function at this chance: qemu_get_vlan. For a while I was thinking that it only finds what is already there... > - 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)) Looks good. Jan -- Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux