[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Re: [PATCH 5/9] Remove some useless malloc() checking
From: |
Jan Kiszka |
Subject: |
[Qemu-devel] Re: [PATCH 5/9] Remove some useless malloc() checking |
Date: |
Wed, 15 Apr 2009 19:13:28 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 |
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 <address@hidden>
> ---
> 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
- [Qemu-devel] Re: [PATCH 9/9] Introduce VLANClientState::cleanup(), (continued)
- [Qemu-devel] Re: [PATCH 9/9] Introduce VLANClientState::cleanup(), Anthony Liguori, 2009/04/30
- [Qemu-devel] Re: [PATCH 9/9] Introduce VLANClientState::cleanup(), Blue Swirl, 2009/04/30
- [Qemu-devel] Re: [PATCH 9/9] Introduce VLANClientState::cleanup(), Jan Kiszka, 2009/04/30
- [Qemu-devel] Re: [PATCH 9/9] Introduce VLANClientState::cleanup(), Anthony Liguori, 2009/04/30
- [Qemu-devel] Re: [PATCH 9/9] Introduce VLANClientState::cleanup(), Blue Swirl, 2009/04/30
- [Qemu-devel] Re: [PATCH 9/9] Introduce VLANClientState::cleanup(), Jan Kiszka, 2009/04/30
- Re: [Qemu-devel] Re: [PATCH 9/9] Introduce VLANClientState::cleanup(), Markus Armbruster, 2009/04/29
- [Qemu-devel] Re: [PATCH 9/9] Introduce VLANClientState::cleanup(), Mark McLoughlin, 2009/04/16
- [Qemu-devel] Re: [PATCH 5/9] Remove some useless malloc() checking,
Jan Kiszka <=
- Re: [Qemu-devel] [PATCH 2/9] struct iovec is now universally available, Christoph Hellwig, 2009/04/15
- Re: [Qemu-devel] [PATCH 2/9] struct iovec is now universally available, Mark McLoughlin, 2009/04/15
- Re: [Qemu-devel] [PATCH 2/9] struct iovec is now universally available, Christoph Hellwig, 2009/04/15
- Re: [Qemu-devel] [PATCH 2/9] struct iovec is now universally available, François Revol, 2009/04/15
- Re: [Qemu-devel] [PATCH 2/9] struct iovec is now universally available, M. Warner Losh, 2009/04/15
- Re: [Qemu-devel] [PATCH 2/9] struct iovec is now universally available, M. Warner Losh, 2009/04/15
Re: [Qemu-devel] [PATCH 1/9] Remove stray GSO code from virtio_net, Anthony Liguori, 2009/04/17