From nobody Sun Feb 8 02:22:16 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1532806865234448.07207530365054; Sat, 28 Jul 2018 12:41:05 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 03D0C369D0; Sat, 28 Jul 2018 19:41:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AF4862010CC1; Sat, 28 Jul 2018 19:41:02 +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 2004F18037F5; Sat, 28 Jul 2018 19:41:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6SJea8l020362 for ; Sat, 28 Jul 2018 15:40:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id DB3E945B4; Sat, 28 Jul 2018 19:40:36 +0000 (UTC) Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D18EC89DFA for ; Sat, 28 Jul 2018 19:40:35 +0000 (UTC) Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 17E37307D850 for ; Sat, 28 Jul 2018 19:40:34 +0000 (UTC) Received: by mail-pg1-f180.google.com with SMTP id d17-v6so638424pgv.10 for ; Sat, 28 Jul 2018 12:40:34 -0700 (PDT) Received: from centos.localdomain ([49.32.98.239]) by smtp.gmail.com with ESMTPSA id m26-v6sm20270426pfi.102.2018.07.28.12.40.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Jul 2018 12:40:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=PBInPM3/CZhYbCsC3uTXcIDlFRFSEI7areO8hNhLSQ0=; b=lXKizzq+kq8XeJ4szdEaRMfeR9Pa7hZrk8A+iGSt8DK2Ew6z2y7e7dW3Ur8v7bLnr9 mEnyyqjYvD36w+u/t9k2XBqcPrbV2nlezLG611GYHULIHTSkhNtSqtp5o4sIwO4+gbDV JoV4hDXhftmz5gZSc2MwHTBlsSmIO0pr1iNpKgE0a8Hg9mszjfL7m0PiHye7XlP5RPCz yZHHWbq8nFYDhr0OJE9ATOBPh6WAkvhLMoaAndzJk3Ix4Ju5euhgJO0DCc2QU8CA78UG lwDPSZkk6hn5GRecMnjIJD4r0JtDwChCmSauZPkteFXtP9Bz6+j9llXvLQ9f8EqwmzWa sYnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=PBInPM3/CZhYbCsC3uTXcIDlFRFSEI7areO8hNhLSQ0=; b=aDEkojnJu6XhucZ3YxLdQqgbF07Ls64Exah6n7iaI89Txwm3gji6WBi9JpAZB8SFVd 8MGTxvIoL7M40kvHHKY2VBPq+Hh5fIK143UVznQYF/wepqv0btwujEuosDhQj/WIdmKE R2FPlcrQYPB0jB02rB74tSywPxRxViRSlj5FF9Vn8M54+gOTNbCzRocERAsLu38+bGPN bYBxC8/jLoOLJi9fo0Atq8jj++a5fUjhqYuuL4MFmD9ZMiIzCotOZVyNFidiyFEIJQUY Mhp+nIHEcBkyvOATEdxTXIXvMzchZdLjisDw3Ql2nxup2r4q2FHtouWUrMOHEaKTWOxE ZXnA== X-Gm-Message-State: AOUpUlGJ+2Z4hQzurlfcij+qL6CcXFuLIwhVAk3jc7w3VlRLKv70qP4m ludn9VnpKSfGOJrHaXVaRYf1j2Hw X-Google-Smtp-Source: AAOMgpc5vqNKcBiY4NNY2qrUyvLiijpwnTcXBmE1g6QDUj9ziIiDIPhbhaUljSW8V58Q7mWx/l4omw== X-Received: by 2002:a62:9849:: with SMTP id q70-v6mr11685509pfd.178.1532806833383; Sat, 28 Jul 2018 12:40:33 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 28 Jul 2018 23:31:16 +0530 Message-Id: <1532800907-29115-2-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1532800907-29115-1-git-send-email-skrtbhtngr@gmail.com> References: <1532800907-29115-1-git-send-email-skrtbhtngr@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Sat, 28 Jul 2018 19:40:34 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Sat, 28 Jul 2018 19:40:34 +0000 (UTC) for IP:'209.85.215.180' DOMAIN:'mail-pg1-f180.google.com' HELO:'mail-pg1-f180.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.11 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.215.180 mail-pg1-f180.google.com 209.85.215.180 mail-pg1-f180.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.48 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 01/32] util: iscsi: use VIR_AUTOFREE instead of VIR_FREE for scalar types 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sat, 28 Jul 2018 19:41:03 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" By making use of GNU C's cleanup attribute handled by the VIR_AUTOFREE macro for declaring scalar variables, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/viriscsi.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/src/util/viriscsi.c b/src/util/viriscsi.c index 653b4fd..48f4106 100644 --- a/src/util/viriscsi.c +++ b/src/util/viriscsi.c @@ -88,7 +88,7 @@ virISCSIGetSession(const char *devpath, .session =3D NULL, .devpath =3D devpath, }; - char *error =3D NULL; + VIR_AUTOFREE(char *) error =3D NULL; int exitstatus =3D 0; =20 virCommandPtr cmd =3D virCommandNewArgList(ISCSIADM, "--mode", @@ -109,7 +109,6 @@ virISCSIGetSession(const char *devpath, NULLSTR(error)); =20 cleanup: - VIR_FREE(error); virCommandFree(cmd); return cbdata.session; } @@ -125,10 +124,10 @@ virStorageBackendIQNFound(const char *initiatoriqn, char **ifacename) { int ret =3D IQN_ERROR; - char *outbuf =3D NULL; char *line =3D NULL; - char *iface =3D NULL; - char *iqn =3D NULL; + VIR_AUTOFREE(char *) outbuf =3D NULL; + VIR_AUTOFREE(char *) iface =3D NULL; + VIR_AUTOFREE(char *) iqn =3D NULL; virCommandPtr cmd =3D virCommandNewArgList(ISCSIADM, "--mode", "iface", NULL); =20 @@ -197,9 +196,6 @@ virStorageBackendIQNFound(const char *initiatoriqn, if (ret =3D=3D IQN_MISSING) VIR_DEBUG("Could not find interface with IQN '%s'", iqn); =20 - VIR_FREE(iqn); - VIR_FREE(iface); - VIR_FREE(outbuf); virCommandFree(cmd); return ret; =20 @@ -216,7 +212,7 @@ virStorageBackendCreateIfaceIQN(const char *initiatoriq= n, char **ifacename) { int ret =3D -1, exitstatus =3D -1; - char *temp_ifacename; + VIR_AUTOFREE(char *) temp_ifacename =3D NULL; virCommandPtr cmd =3D NULL; =20 if (virAsprintf(&temp_ifacename, @@ -277,7 +273,6 @@ virStorageBackendCreateIfaceIQN(const char *initiatoriq= n, =20 cleanup: virCommandFree(cmd); - VIR_FREE(temp_ifacename); if (ret !=3D 0) VIR_FREE(*ifacename); return ret; @@ -299,7 +294,7 @@ virISCSIConnection(const char *portal, NULL }; virCommandPtr cmd; - char *ifacename =3D NULL; + VIR_AUTOFREE(char *) ifacename =3D NULL; =20 cmd =3D virCommandNewArgs(baseargv); virCommandAddArgSet(cmd, extraargv); @@ -339,7 +334,6 @@ virISCSIConnection(const char *portal, =20 cleanup: virCommandFree(cmd); - VIR_FREE(ifacename); =20 return ret; } @@ -390,15 +384,13 @@ virISCSIGetTargets(char **const groups, void *data) { struct virISCSITargetList *list =3D data; - char *target; + VIR_AUTOFREE(char *) target =3D NULL; =20 if (VIR_STRDUP(target, groups[1]) < 0) return -1; =20 - if (VIR_APPEND_ELEMENT(list->targets, list->ntargets, target) < 0) { - VIR_FREE(target); + if (VIR_APPEND_ELEMENT(list->targets, list->ntargets, target) < 0) return -1; - } =20 return 0; } @@ -498,8 +490,7 @@ virISCSIScanTargets(const char *portal, size_t *ntargets, char ***targets) { - char *ifacename =3D NULL; - int ret =3D -1; + VIR_AUTOFREE(char *) ifacename =3D NULL; =20 if (ntargets) *ntargets =3D 0; @@ -522,10 +513,8 @@ virISCSIScanTargets(const char *portal, } } =20 - ret =3D virISCSIScanTargetsInternal(portal, ifacename, + return virISCSIScanTargetsInternal(portal, ifacename, persist, ntargets, targets); - VIR_FREE(ifacename); - return ret; } =20 =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list