From nobody Sun Feb 8 19:59:58 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 1532175127698113.94358694288314; Sat, 21 Jul 2018 05:12:07 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 857713082A4B; Sat, 21 Jul 2018 12:12:01 +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 538305D9CB; Sat, 21 Jul 2018 12:12:00 +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 0A9181841C5A; Sat, 21 Jul 2018 12:12:00 +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 w6LC8ZBb016490 for ; Sat, 21 Jul 2018 08:08:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id DB83F5D9CC; Sat, 21 Jul 2018 12:08:35 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D080A5D9CB for ; Sat, 21 Jul 2018 12:08:35 +0000 (UTC) Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) (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 57065356D6 for ; Sat, 21 Jul 2018 12:08:24 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id n7-v6so8961186pgq.4 for ; Sat, 21 Jul 2018 05:08:24 -0700 (PDT) Received: from centos.localdomain ([42.106.1.69]) by smtp.gmail.com with ESMTPSA id s16-v6sm5861694pfm.114.2018.07.21.05.08.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Jul 2018 05:08:23 -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=WgQE8YlFwKO8HXIzMD8rDG5RdRhCUcYIpz+Ud9qf/U0=; b=U/W0gcM22VteNL+IY0FSX9h91GedtY1VUsDI1SqY807Mx6upx6FqRUKfEXKvxzRzIj vbJlFVfJ3ycUg6PXkT8LysHv3A8eOsBkmNX5Ya9g7/OQM57PWWkNeoBgYmBsvzo7/xmp rRNvLDga9jjmqEpJVMKTsDZKXMJpG77qLfpDi3sS1Jqf6s9OEbPLdXEtSxQsRRDgy7r6 yECZA3Ksia+drwEiewz9T9/KP5FHnzPlm3NjgqZWJnrDeZBwYPTSCRecZXRcW/kAdn9J q2PCu8JUk5uxDzhF4C06s8fsuqsnrC77ultioV3SlPi8IvoM1LKCa8vTeXDPm0xbPT9L HsPg== 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=WgQE8YlFwKO8HXIzMD8rDG5RdRhCUcYIpz+Ud9qf/U0=; b=bJaPiwrwz0yOVDpLxdTqudyHjOdI+21pcYeJt70KakXpONXNDOw//t3kLEjCBENPb6 dx5hjB6ouC4Yda/qlmrlfGuFRG5I1p+dri2lbjbzFcxhuXPxINYO6HjgmifjYvHTBRsZ tRpdzYorXhZ5g7/KcDslS+4D9Z5TZKNnKVSzuqorjV6pHWBPSaw74tZwLW8QdDdjN8gI es0q7nQhI9r2TwMn8dVYWuvaElgM69R8fpQwD1LN58xdTvYtej8QeDyUTvwCfNF1DSEA UEWvOXjJm3NH32Zs7EtWsW1T42dUSbEOo5SPRoxgj8sU2H4XNGQjKWxUtAS0w6m9/l+G 7uRQ== X-Gm-Message-State: AOUpUlGzH9Gx3G1ahHh62DWTMhF3c6BupRvkxZx18BZ8u9C3Sc4S1mmY IBfCmAJsCaMun0FGs7THv0mmi4GX X-Google-Smtp-Source: AAOMgpfEpcQzK2fKnaSDadE4eKBDDm9Gl8K8EgK1ubCKSdnTJ0BfxKJVmurHjxj3aQcvQfYjKR3uDw== X-Received: by 2002:a62:748:: with SMTP id b69-v6mr5827151pfd.177.1532174903607; Sat, 21 Jul 2018 05:08:23 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 21 Jul 2018 17:36:56 +0530 Message-Id: <1532174832-21644-25-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1532174832-21644-1-git-send-email-skrtbhtngr@gmail.com> References: <1532174832-21644-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.30]); Sat, 21 Jul 2018 12:08:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sat, 21 Jul 2018 12:08:24 +0000 (UTC) for IP:'209.85.215.196' DOMAIN:'mail-pg1-f196.google.com' HELO:'mail-pg1-f196.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.281 * (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.215.196 mail-pg1-f196.google.com 209.85.215.196 mail-pg1-f196.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 24/40] util: usb: 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Sat, 21 Jul 2018 12:12:07 +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/virusb.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/util/virusb.c b/src/util/virusb.c index 0a8dd0d..c14683f 100644 --- a/src/util/virusb.c +++ b/src/util/virusb.c @@ -90,29 +90,25 @@ VIR_ONCE_GLOBAL_INIT(virUSB) static int virUSBSysReadFile(const char *f_name, const char *d_name, int base, unsigned int *value) { - int ret =3D -1, tmp; - char *buf =3D NULL; - char *filename =3D NULL; + int tmp; + VIR_AUTOFREE(char *) buf =3D NULL; + VIR_AUTOFREE(char *) filename =3D NULL; char *ignore =3D NULL; =20 tmp =3D virAsprintf(&filename, USB_SYSFS "/devices/%s/%s", d_name, f_n= ame); if (tmp < 0) - goto cleanup; + return -1; =20 if (virFileReadAll(filename, 1024, &buf) < 0) - goto cleanup; + return -1; =20 if (virStrToLong_ui(buf, &ignore, base, value) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not parse usb file %s"), filename); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - VIR_FREE(filename); - VIR_FREE(buf); - return ret; + return 0; } =20 static virUSBDeviceListPtr --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list