From nobody Mon Dec 15 23:00:41 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 1528124367448642.2766752202106; Mon, 4 Jun 2018 07:59:27 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F18A31647B7; Mon, 4 Jun 2018 14:59:25 +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 1FF2B608EF; Mon, 4 Jun 2018 14:59:25 +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 8C22A4CA81; Mon, 4 Jun 2018 14:59:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w54EbCFB008532 for ; Mon, 4 Jun 2018 10:37:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1FF9F1802D; Mon, 4 Jun 2018 14:37:12 +0000 (UTC) Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 142245C8AA for ; Mon, 4 Jun 2018 14:37:09 +0000 (UTC) Received: from mail-pl0-f65.google.com (mail-pl0-f65.google.com [209.85.160.65]) (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 DA69230C036B for ; Mon, 4 Jun 2018 14:36:58 +0000 (UTC) Received: by mail-pl0-f65.google.com with SMTP id i5-v6so19842580plt.2 for ; Mon, 04 Jun 2018 07:36:58 -0700 (PDT) Received: from centos.localdomain ([42.106.2.208]) by smtp.gmail.com with ESMTPSA id f63-v6sm23448806pfe.143.2018.06.04.07.36.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jun 2018 07:36:57 -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=h3Tn8+lIZbbFnrCZjYWtAPnmIrmqBsp/hGdpw3ZIBRg=; b=r3OEyF+vyvX9iSu5OrVleNsCVtZive8yYUP0tl9joIWi4shFx5QnXXNWDnzPb8/ee6 sCPO8/X+fsQaToxTesZ518eyFLz3YKLm0sKO2+Yfsu+SCTR8hnBd0NsYwKQiNS3EFIqH Cn06W+vpHIDKdz/wYuY/CTk4YkSakDKhHCnQQnoRanrU50Ov4pBLsHdkRMX6qr/CR/NK WTqfYWMnZS3LkQ+ZRs3USXXIeMAiNf3Ege6d8nETOuHysjqfwu590AA+AqN1ZHmfQQqL QLb8R7lUXdWHIV7Jak9Q89mF98DyT3kdEJjGMJVZzx8P0abjJBIQ4SWhEBAdmGT3fjAu tmEg== 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=h3Tn8+lIZbbFnrCZjYWtAPnmIrmqBsp/hGdpw3ZIBRg=; b=TGIZYgWj0ITTh4kkoqf/TU6tfVrgneM1fYSxW8UJbKyD00kVf+88q2A9YMwyyK8IOE KNj+Xy2odKyK47uJeGCdVki08Q3PHIAGbt9pWFoA7CZZ134PvmjZme+tmerwAmu4niBc imBvh0j5xOoZGywRB8Um69Ydn/qMz1sQsrDcj+YkssvsCF+bnTaeCjqMaV3vN0rdKa5x YUEcfJH8XzOqAhQhfGdp7xE/yDu2MBl03LDcemHO6UCFPpueeB1f2+ZNuYxqd/zni6aM fUKtNHTgCkKucVEi5fl7v82WIY0q44uO4dI1yM1gHXxkvYXdlz1HbMSwo3RJViycq+lZ xGow== X-Gm-Message-State: ALKqPwdaMGN28RzzDb8/21e1trw25ZeM1DBktVjJGnapgx4XBLQHNAjg gN5wmm6/pE29sFNjThBOmyQke7No X-Google-Smtp-Source: ADUXVKKqQb0rWKs7oMS5U1zAE8+uvMwyPje0xNmxY8qQ7isgP0lEY8PWNPwE/TsWmCxQy2tJ2f82/g== X-Received: by 2002:a17:902:a714:: with SMTP id w20-v6mr21598191plq.374.1528123018025; Mon, 04 Jun 2018 07:36:58 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sun, 3 Jun 2018 13:42:14 +0530 Message-Id: <1528013536-22196-17-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528013536-22196-1-git-send-email-skrtbhtngr@gmail.com> References: <1528013536-22196-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.40]); Mon, 04 Jun 2018 14:36:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 04 Jun 2018 14:36:59 +0000 (UTC) for IP:'209.85.160.65' DOMAIN:'mail-pl0-f65.google.com' HELO:'mail-pl0-f65.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.766 * (DATE_IN_PAST_24_48, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS, T_DKIM_INVALID) 209.85.160.65 mail-pl0-f65.google.com 209.85.160.65 mail-pl0-f65.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.40 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 16/18] use VIR_AUTOFREE in src/util/virfilecache.c 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 04 Jun 2018 14:59:26 +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" Modify code to use VIR_AUTOFREE macro wherever required. Signed-off-by: Sukrit Bhatnagar --- src/util/virfilecache.c | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/src/util/virfilecache.c b/src/util/virfilecache.c index dab7216..49049b7 100644 --- a/src/util/virfilecache.c +++ b/src/util/virfilecache.c @@ -100,18 +100,17 @@ static char * virFileCacheGetFileName(virFileCachePtr cache, const char *name) { - char *file =3D NULL; - char *namehash =3D NULL; + VIR_AUTOFREE(char *) namehash =3D NULL; virBuffer buf =3D VIR_BUFFER_INITIALIZER; =20 if (virCryptoHashString(VIR_CRYPTO_HASH_SHA256, name, &namehash) < 0) - goto cleanup; + return NULL; =20 if (virFileMakePath(cache->dir) < 0) { virReportSystemError(errno, _("Unable to create directory '%s'"), cache->dir); - goto cleanup; + return NULL; } =20 virBufferAsprintf(&buf, "%s/%s", cache->dir, namehash); @@ -120,13 +119,9 @@ virFileCacheGetFileName(virFileCachePtr cache, virBufferAsprintf(&buf, ".%s", cache->suffix); =20 if (virBufferCheckError(&buf) < 0) - goto cleanup; - - file =3D virBufferContentAndReset(&buf); + return NULL; =20 - cleanup: - VIR_FREE(namehash); - return file; + return virBufferContentAndReset(&buf); } =20 =20 @@ -135,7 +130,7 @@ virFileCacheLoad(virFileCachePtr cache, const char *name, void **data) { - char *file =3D NULL; + VIR_AUTOFREE(char *) file =3D NULL; int ret =3D -1; void *loadData =3D NULL; =20 @@ -179,7 +174,6 @@ virFileCacheLoad(virFileCachePtr cache, =20 cleanup: virObjectUnref(loadData); - VIR_FREE(file); return ret; } =20 @@ -189,20 +183,15 @@ virFileCacheSave(virFileCachePtr cache, const char *name, void *data) { - char *file =3D NULL; - int ret =3D -1; + VIR_AUTOFREE(char *) file =3D NULL; =20 if (!(file =3D virFileCacheGetFileName(cache, name))) - return ret; + return -1; =20 if (cache->handlers.saveFile(data, file, cache->priv) < 0) - goto cleanup; - - ret =3D 0; + return -1; =20 - cleanup: - VIR_FREE(file); - return ret; + return 0; } =20 =20 @@ -347,7 +336,7 @@ virFileCacheLookupByFunc(virFileCachePtr cache, const void *iterData) { void *data =3D NULL; - char *name =3D NULL; + VIR_AUTOFREE(char *) name =3D NULL; =20 virObjectLock(cache); =20 @@ -357,8 +346,6 @@ virFileCacheLookupByFunc(virFileCachePtr cache, virObjectRef(data); virObjectUnlock(cache); =20 - VIR_FREE(name); - return data; } =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list