[libvirt] [PATCH v3 16/34] Adapt to VIR_STRDUP and VIR_STRNDUP in src/phyp/*
Eric Blake
eblake at redhat.com
Thu May 9 03:03:27 UTC 2013
On 05/03/2013 08:53 AM, Michal Privoznik wrote:
> ---
> src/phyp/phyp_driver.c | 50 ++++++++++----------------------------------------
> 1 file changed, 10 insertions(+), 40 deletions(-)
>
> diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
> @@ -1141,15 +1137,9 @@ phypConnectOpen(virConnectPtr conn,
>
> if (conn->uri->path) {
> /* need to shift one byte in order to remove the first "/" of URI component */
> - if (conn->uri->path[0] == '/')
> - managed_system = strdup(conn->uri->path + 1);
> - else
> - managed_system = strdup(conn->uri->path);
> -
> - if (!managed_system) {
> - virReportOOMError();
> + if (VIR_STRDUP(managed_system, conn->uri->path[0] == '/' ?
> + conn->uri->path + 1 : conn->uri->path) < 0)
Simpler to write:
VIR_STRDUP(managed_system,
conn->uri->path + (conn->uri->path[0] == '/'))
ACK.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130508/44be1c0e/attachment-0001.sig>
More information about the libvir-list
mailing list