[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH v3 13/34] Adapt to VIR_STRDUP and VIR_STRNDUP in src/nwfilter/*



On 05/03/2013 08:53 AM, Michal Privoznik wrote:
> ---
>  src/nwfilter/nwfilter_dhcpsnoop.c         | 22 +++++++++++-----------
>  src/nwfilter/nwfilter_driver.c            |  7 +++----
>  src/nwfilter/nwfilter_ebiptables_driver.c |  2 +-
>  src/nwfilter/nwfilter_gentech_driver.c    |  5 ++---
>  src/nwfilter/nwfilter_learnipaddr.c       |  5 +----
>  5 files changed, 18 insertions(+), 23 deletions(-)
> 
> diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c
> @@ -1631,15 +1629,17 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver,
>      req->driver = driver;
>      req->techdriver = techdriver;
>      tmp = virNetDevGetIndex(ifname, &req->ifindex);
> -    req->linkdev = linkdev ? strdup(linkdev) : NULL;
>      req->nettype = nettype;
> -    req->ifname = strdup(ifname);
>      virMacAddrSet(&req->macaddr, macaddr);
> -    req->filtername = strdup(filtername);
>      req->vars = virNWFilterHashTableCreate(0);
> +    req->linkdev = NULL;
> +
> +    if (VIR_STRDUP(req->ifname, ifname) < 0 ||
> +        VIR_STRDUP(req->filtername, filtername) < 0 ||
> +        (linkdev && VIR_STRDUP(req->linkdev, linkdev) < 0))
> +        goto exit_snoopreqput;

Can be simplified by passing NULL source.

> +++ b/src/nwfilter/nwfilter_ebiptables_driver.c
> @@ -2982,7 +2982,7 @@ ebtablesCreateTmpSubChain(ebiptablesRuleInstPtr *inst,
>  
>      switch (protoidx) {
>      case L2_PROTO_MAC_IDX:
> -        protostr = strdup("");
> +        ignore_value(VIR_STRDUP_QUIET(protostr, ""));

You could use VIR_STRDUP here; it will be a double oom report (since the
code is just reporting OOM error a few lines later), but it will avoid
churn when you touch this function again for the virAsprintf/oom cleanup
pass.  But I can also live with this patch as-is.

ACK.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]