From nobody Tue May 13 11:27:46 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 1532639137044914.5983651221646; Thu, 26 Jul 2018 14:05:37 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D0C30300176B; Thu, 26 Jul 2018 21:05:34 +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 99918308BDB7; Thu, 26 Jul 2018 21:05:34 +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 50EC1264D3; Thu, 26 Jul 2018 21:05:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6QL5QKN024891 for ; Thu, 26 Jul 2018 17:05:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 46EB92010CC5; Thu, 26 Jul 2018 21:05:26 +0000 (UTC) Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3AD902010CC4 for ; Thu, 26 Jul 2018 21:05:26 +0000 (UTC) Received: from mail-pl0-f66.google.com (mail-pl0-f66.google.com [209.85.160.66]) (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 7FCE330832E2 for ; Thu, 26 Jul 2018 21:05:25 +0000 (UTC) Received: by mail-pl0-f66.google.com with SMTP id b1-v6so1341815pls.5 for ; Thu, 26 Jul 2018 14:05:25 -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.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jul 2018 14:05:24 -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=Sk276CJnd3n+QfrPt00DZYJL+3r81qdlNK2xPS63umg=; b=eGzmrUiGKRWhvyJddAo4RUBsImYAI5jP4l2Qv5joxD9cHYV4IOOjTZ2xCZ98q0wBZb j5Py00IFVd1fZyzp81aPjPJ3Xs2Th8uejcbZMCSOl0oFpit51eJDI6L8iW9+I4rSzhKn tIC0548Hs8h1qPI6zYvgRdRUiGxQQLVVH/pmOORSmP4I8p5hzEahWSHsEPdcsitx8/mN PHXhfBGNh1V20nsuqBnRHO/Lc+B1jkObGkzHeqRvY3VURq0V5QVLVBRebXMLSooO3JnE M+cds6bqEsTITyTTthssYh8YSRF6PcSFpCLFfAOtOexF1thHF4WY2kd1vpY8XNov6XmJ pDuw== 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=Sk276CJnd3n+QfrPt00DZYJL+3r81qdlNK2xPS63umg=; b=anDpN7sgXIBDcExktX5KHbM+5sOXqvqNQJ1ermCuHquNriw6yvi+lRzbYBm2+yBSdt RFvSwEQcWkUHHgyEPCZmVv5huvtZbokkTXDvDJ1/jfFMjnBFMuf058g4f+sG51kSDq46 AZSIhdKzCqyF3OLhwjBhVwPyugiTbOTcbLqYSLmExq8CrmPAbtOnax7hfyA+vl8WnQd/ qTGTj69BH1jZzzduAUNklpT6z4XGI+PUJrs9EZTBigH4S4pYpPFHVmvSNBXMWw0bpv20 DPsqgLQfPU9Jp1/HYzVDZoWgx1e0URLjTmSBs7l+Q1CdzjejlCxFo6uD34nTqO5TU9zC Xnrw== X-Gm-Message-State: AOUpUlFKgMwyfOQYJ4RriXc8ztq+dgqFYOA0edHWLJxFgvEo4qk+kMJG lGl66b9ZToDW1jvtrNlIbMQXXTHf X-Google-Smtp-Source: AAOMgpelZJ3ufMMbtoikCdHuX6Pq89fJcdiNsSyIkz/WBk+BJHtG6Ik5Ebag2RTtzVr38+i3vXJuDw== X-Received: by 2002:a17:902:7c8e:: with SMTP id y14-v6mr3418091pll.265.1532639124794; Thu, 26 Jul 2018 14:05:24 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Tue, 24 Jul 2018 21:22:25 +0530 Message-Id: <1532447562-24010-25-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.44]); Thu, 26 Jul 2018 21:05:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 26 Jul 2018 21:05:25 +0000 (UTC) for IP:'209.85.160.66' DOMAIN:'mail-pl0-f66.google.com' HELO:'mail-pl0-f66.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.66 mail-pl0-f66.google.com 209.85.160.66 mail-pl0-f66.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.44 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 24/41] 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.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 26 Jul 2018 21:05:35 +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 90f947b..47b407b 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