From nobody Sun Feb 8 18:35:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1573578108; cv=none; d=zoho.com; s=zohoarc; b=WkvWQV16StSOj/Em2+B3pl66AmJMjIxOIqLpdaLe0AX7nJ98FeCkvIaB2n/3J+2OLSk+1bLSEVtzVWUvk0IUBDnhlOT/IxUeD6CKw3FznPfZTGTENPLQXasrThzsoNlKP35fcuhnb8TxgWitWxyoc0emDufPOyc+XRIMxmf18BU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573578108; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SZ+xKL79FRFv8pHE86kpsXynt/hQT+7NBse3L3rZKaI=; b=nnJ61rXSb85mS8hpnWp8/3ZAhOQKuSDg/1sea4Z6JuJETfkjdePvCX4Q35DdbL+vf/d527UagUE/LeGSf99Re8avtS4NhjXru5JsoDW8glvaYgAhMR7hZVXsp2WAjbNIR4PpRBFARR4EmyLwjM0j3+ER/EtsXSE+5YcssJ/WWlY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 15735781082331021.6764118424363; Tue, 12 Nov 2019 09:01:48 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-319-pixYYUqkOw2bsFplprlEKA-1; Tue, 12 Nov 2019 12:01:44 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B58B08E965B; Tue, 12 Nov 2019 17:01:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6B6405DE7C; Tue, 12 Nov 2019 17:01:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 048E14E572; Tue, 12 Nov 2019 17:01:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xACH1QCh012269 for ; Tue, 12 Nov 2019 12:01:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1075960174; Tue, 12 Nov 2019 17:01:26 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.43.2.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8EAEF60173 for ; Tue, 12 Nov 2019 17:01:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573578107; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=SZ+xKL79FRFv8pHE86kpsXynt/hQT+7NBse3L3rZKaI=; b=HnchRvTCJtbm1fYRUzFAhmECz17uxQwDB6bUe6zBUMQsvteYkzNuqli5kziEgbUAahspQq vNDpIYGPlZwP5lhzE9bj17rNYD6Z3qTe+n15xDADIlOfkvIT+/6vsuSFiqbkhvrAVdcpkX HFejWThmuQOnmsWT2PBqYSwTFcE+1OQ= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 12 Nov 2019 18:02:10 +0100 Message-Id: <6246562964bd0668a293ea63949390ac5d218675.1573578043.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/9] Remove VIR_STRNDUP usage that passes -1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: pixYYUqkOw2bsFplprlEKA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all the usage of VIR_STRNDUP(dest, b, p ? p - b : -1) with separate calls to g_strndup/g_strdup. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Daniel Henrique Barboza --- src/bhyve/bhyve_parse_command.c | 38 +++++++++++++++++++++------------ src/libxl/xen_common.c | 15 +++++++------ src/remote/remote_driver.c | 6 ++++-- 3 files changed, 37 insertions(+), 22 deletions(-) diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_comman= d.c index fa3b881f21..5c5dfae4a9 100644 --- a/src/bhyve/bhyve_parse_command.c +++ b/src/bhyve/bhyve_parse_command.c @@ -150,8 +150,10 @@ bhyveCommandLineToArgv(const char *nativeConfig, start =3D curr; next =3D strchr(curr, '\n'); =20 - if (VIR_STRNDUP(line, curr, next ? next - curr : -1) < 0) - goto error; + if (next) + line =3D g_strndup(curr, next - curr); + else + line =3D g_strdup(curr); =20 if (VIR_RESIZE_N(lines, lines_alloc, line_count, 2) < 0) { VIR_FREE(line); @@ -194,8 +196,10 @@ bhyveCommandLineToArgv(const char *nativeConfig, next =3D strchr(start, ' '); } =20 - if (VIR_STRNDUP(arg, curr, next ? next - curr : -1) < 0) - goto error; + if (next) + arg =3D g_strndup(curr, next - curr); + else + arg =3D g_strdup(curr); =20 if (next && (*next =3D=3D '\'' || *next =3D=3D '"')) next++; @@ -366,8 +370,10 @@ bhyveParsePCISlot(const char *slotdef, =20 next =3D strchr(curr, ':'); =20 - if (VIR_STRNDUP(val, curr, next? next - curr : -1) < 0) - goto error; + if (next) + val =3D g_strndup(curr, next - curr); + else + val =3D g_strdup(curr); =20 if (virStrToLong_ui(val, NULL, 10, &values[i]) < 0) goto error; @@ -441,9 +447,10 @@ bhyveParsePCIDisk(virDomainDefPtr def, goto error; =20 separator =3D strchr(config, ','); - if (VIR_STRNDUP(disk->src->path, config, - separator? separator - config : -1) < 0) - goto error; + if (separator) + disk->src->path =3D g_strndup(config, separator - config); + else + disk->src->path =3D g_strdup(config); =20 if (bus =3D=3D VIR_DOMAIN_DISK_BUS_VIRTIO) { idx =3D *nvirtiodisk; @@ -515,9 +522,10 @@ bhyveParsePCINet(virDomainDefPtr def, } =20 separator =3D strchr(config, ','); - if (VIR_STRNDUP(net->ifname, config, - separator? separator - config : -1) < 0) - goto error; + if (separator) + net->ifname =3D g_strndup(config, separator - config); + else + net->ifname =3D g_strdup(config); =20 if (!separator) goto cleanup; @@ -578,8 +586,10 @@ bhyveParseBhyvePCIArg(virDomainDefPtr def, if (conf) conf++; /* Skip initial comma */ =20 - if (VIR_STRNDUP(emulation, separator, conf? conf - separator - 1 : -1)= < 0) - goto error; + if (conf) + emulation =3D g_strndup(separator, conf - separator - 1); + else + emulation =3D g_strdup(separator); =20 if (bhyveParsePCISlot(slotdef, &pcislot, &bus, &function) < 0) goto error; diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index c31a5c952e..a4a9ec59bf 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -823,9 +823,11 @@ xenParseSxprChar(const char *value, =20 offset2 =3D strchr(offset, ','); offset++; - if (VIR_STRNDUP(def->source->data.tcp.service, offset, - offset2 ? offset2 - offset : -1) < 0) - goto error; + if (offset2) + def->source->data.tcp.service =3D g_strndup(offset, + offset2 - offset); + else + def->source->data.tcp.service =3D g_strdup(offset); =20 if (offset2 && strstr(offset2, ",server")) def->source->data.tcp.listen =3D true; @@ -875,9 +877,10 @@ xenParseSxprChar(const char *value, case VIR_DOMAIN_CHR_TYPE_UNIX: { const char *offset =3D strchr(value, ','); - if (VIR_STRNDUP(def->source->data.nix.path, value, - offset ? offset - value : -1) < 0) - goto error; + if (offset) + def->source->data.nix.path =3D g_strndup(value, offset - value= ); + else + def->source->data.nix.path =3D g_strdup(value); =20 if (offset !=3D NULL && strstr(offset, ",server") !=3D NULL) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 451a45f590..503f49a902 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -215,8 +215,10 @@ static int remoteSplitURIScheme(virURIPtr uri, =20 *driver =3D *transport =3D NULL; =20 - if (VIR_STRNDUP(*driver, uri->scheme, p ? p - uri->scheme : -1) < 0) - return -1; + if (p) + *driver =3D g_strndup(uri->scheme, p - uri->scheme); + else + *driver =3D g_strdup(uri->scheme); =20 if (p) { *transport =3D g_strdup(p + 1); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list