From nobody Mon Dec 15 01:36:51 2025 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 1532639201171503.28324916744293; Thu, 26 Jul 2018 14:06:41 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6669C30B8FA5; Thu, 26 Jul 2018 21:06:36 +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 23A1060F9B; Thu, 26 Jul 2018 21:06:28 +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 C7310239; Thu, 26 Jul 2018 21:06:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6QL5uS8025111 for ; Thu, 26 Jul 2018 17:05:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id D1A40607A5; Thu, 26 Jul 2018 21:05:56 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C55E55E7D9 for ; Thu, 26 Jul 2018 21:05:52 +0000 (UTC) Received: from mail-pl0-f51.google.com (mail-pl0-f51.google.com [209.85.160.51]) (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 D1046B2BC for ; Thu, 26 Jul 2018 21:05:48 +0000 (UTC) Received: by mail-pl0-f51.google.com with SMTP id f6-v6so1351124plo.1 for ; Thu, 26 Jul 2018 14:05:48 -0700 (PDT) Received: from centos.localdomain ([42.106.3.93]) by smtp.gmail.com with ESMTPSA id z10-v6sm3279182pfh.83.2018.07.26.14.05.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jul 2018 14:05:47 -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=bHQoUq+sqRxfTJMk1+J9fBRvkoCfBSJj6YO9IlSUFvQ=; b=pOSqdBneFxFFVwCeFLNzeYWtaju+oAuv14lEULIM9ldI+SghD/rrAg4s8FVddoMfyi h+jST2+6quFx2HffFinWdjY359VMjXDh0897z2WHi/WCHESseRHrinZaudAD7COBklgx hRfvMvxrasvvNS+gCexhS7zZSl1JwrDXOq03kXfITz96hOl2LOVWBo3eNR/ZyBpDcfQv 5FsmK2jlZqMepfnkrBaThyZEWc4zF42U+1DJjH04D5kFtjMsugHbd1R9FZGADgvRHKxS HtOqYYB1hFjNnqMkwKuQAds8jSHevG2tHzVByvy9yp8mpMwJhqXYrznK0czDLp2qzYcU B8Og== 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=bHQoUq+sqRxfTJMk1+J9fBRvkoCfBSJj6YO9IlSUFvQ=; b=h57IOqXSfRO1jXD0gWSJ7n6z2GvdrPNJgokiOhbjlbHtRpRc0dsrMB2iI24lRLxmM/ l71u/yTjyjRBnhu5UiagP3n9/BAyExYVzDpW+lQX0PY3Lt8x4VQ6BDMnJ0S5R/UUO5c5 h+oyveTlpaOSxh066t+JY00pmvArKXZhxnyxQnJdxfrWuKFZQXuhEALmpjyNloC7YmHt n0G3h+WlJLwOBurTibZr3O4MQynGDAYZZUuvps4bWWo0T8JVWDmY8vLLjH1akBEyD/bT Y3RV1ygwBuRKoeHQW5kK7EasOps79hNxYwYUFkesx75Mp8603IlXb0bHGMRqrSgF+eec GK0g== X-Gm-Message-State: AOUpUlGfqieGz2RkNa6A1q6Je3wI6EZLw82jEbYR/Hid1ql2Q21pMWnl 8jhX9MVyO5lPDnNLmQsmM2BowdeH X-Google-Smtp-Source: AAOMgpcmazSSKMpzYuGkdgCUFMAHgNtzmjbBwXqaNBKyHcopnqBnz7aCc96hEaiXLNIXfPWxvlyExQ== X-Received: by 2002:a17:902:8210:: with SMTP id x16-v6mr3334111pln.307.1532639148007; Thu, 26 Jul 2018 14:05:48 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Tue, 24 Jul 2018 21:22:37 +0530 Message-Id: <1532447562-24010-37-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1532447562-24010-1-git-send-email-skrtbhtngr@gmail.com> References: <1532447562-24010-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.26]); Thu, 26 Jul 2018 21:05:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 26 Jul 2018 21:05:51 +0000 (UTC) for IP:'209.85.160.51' DOMAIN:'mail-pl0-f51.google.com' HELO:'mail-pl0-f51.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.37 * (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_WEB, SPF_PASS) 209.85.160.51 mail-pl0-f51.google.com 209.85.160.51 mail-pl0-f51.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 36/41] 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.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 26 Jul 2018 21:06:38 +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 | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/util/viriscsi.c b/src/util/viriscsi.c index d4c745a..13fd02c 100644 --- a/src/util/viriscsi.c +++ b/src/util/viriscsi.c @@ -80,7 +80,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", @@ -101,7 +101,6 @@ virISCSIGetSession(const char *devpath, NULLSTR(error)); =20 cleanup: - VIR_FREE(error); virCommandFree(cmd); return cbdata.session; } @@ -120,7 +119,10 @@ virStorageBackendIQNFound(const char *initiatoriqn, int ret =3D IQN_MISSING, fd =3D -1; char ebuf[64]; FILE *fp =3D NULL; - char *line =3D NULL, *newline =3D NULL, *iqn =3D NULL, *token =3D NULL; + VIR_AUTOFREE(char *) line =3D NULL; + char *newline =3D NULL; + char *iqn =3D NULL; + char *token =3D NULL; virCommandPtr cmd =3D virCommandNewArgList(ISCSIADM, "--mode", "iface", NULL); =20 @@ -192,7 +194,6 @@ virStorageBackendIQNFound(const char *initiatoriqn, if (ret =3D=3D IQN_MISSING) VIR_DEBUG("Could not find interface with IQN '%s'", iqn); =20 - VIR_FREE(line); VIR_FORCE_FCLOSE(fp); VIR_FORCE_CLOSE(fd); virCommandFree(cmd); @@ -206,7 +207,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, @@ -267,7 +268,6 @@ virStorageBackendCreateIfaceIQN(const char *initiatoriq= n, =20 cleanup: virCommandFree(cmd); - VIR_FREE(temp_ifacename); if (ret !=3D 0) VIR_FREE(*ifacename); return ret; @@ -289,7 +289,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); @@ -326,7 +326,6 @@ virISCSIConnection(const char *portal, =20 cleanup: virCommandFree(cmd); - VIR_FREE(ifacename); =20 return ret; } @@ -377,15 +376,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; } --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list