From nobody Sun Feb 8 18:30:05 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 1532174912114617.170484427173; Sat, 21 Jul 2018 05:08:32 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CFEBC308FB96; Sat, 21 Jul 2018 12:08:25 +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 91485C4A64; Sat, 21 Jul 2018 12:08:24 +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 4A79D1841C5B; Sat, 21 Jul 2018 12:08:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6LC7nsb016228 for ; Sat, 21 Jul 2018 08:07:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id DE4BCCC107; Sat, 21 Jul 2018 12:07:49 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D4B36CC105 for ; Sat, 21 Jul 2018 12:07:46 +0000 (UTC) Received: from mail-pl0-f67.google.com (mail-pl0-f67.google.com [209.85.160.67]) (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 540283DE33 for ; Sat, 21 Jul 2018 12:07:35 +0000 (UTC) Received: by mail-pl0-f67.google.com with SMTP id o7-v6so6297638plk.10 for ; Sat, 21 Jul 2018 05:07:35 -0700 (PDT) Received: from centos.localdomain ([42.106.1.69]) by smtp.gmail.com with ESMTPSA id s16-v6sm5861694pfm.114.2018.07.21.05.07.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Jul 2018 05:07:34 -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=RLdsn2/LzsUg73QWCsZsf7XsMUe9k6q02ynPV3VQ9fA=; b=YkVKsOuv8bjBOKArjkz6yk2LiydjKw2vlL8U5xGQMK/udVEEsDtukM8FTtuU0/hSlL IsQOZV4/lsuEnpOmuqZpA9n16Y65qDTKfPZ/3ecbEZA2n2WeXbgWZAIO5/jnUWFjwdyF CzOGRfmZg9I/1qvY2nlYHEZxnOxS3BPeI5J4K5lhVE7ih3+L8Fi+0MB9bWi2bGpWwmLW hsiRh1naLndQ5wirmgtID4+M3VEzpa/HBETHyHSuLkmeWlyxx6sWzLTzoyq+M/wsTO4I DP43CRehO/xPCcM2JGteauXn3IM6EW340GRYLbqFiT0MXGOIfdh2R0DZIIy1XVv3Tv7y +MoA== 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=RLdsn2/LzsUg73QWCsZsf7XsMUe9k6q02ynPV3VQ9fA=; b=hjlZAXUBlb+D/TviiteE8o5SlteRQuuS/PH6XW4PcZg5zz3Hs1nvDM/KfOaQXee+Rn 59GGAtD0Ji6aNZ6ZXLsp+/8rklS55A1YbpBtFp68VLn0GERoB9GK4FK/eS8nvfKbAiTw 575lvJAi5hqmVvxQmu6CuxJB2SxSaljl0jSaCqjHadMHlPDKZvtSWPARTHgm64z8TEVk eOvDLPsHgn28Nx3LmSgc8YT2Om14XKefao2tHR+r7sPBr41vK9GUcoRAp90qdX2TcW66 +hX45mNGod7yi+Genh7pWlXC0VoH9HF36IU+l1fC2RH1bxNjejcnZl5S10FL5sqvsTTT VTkA== X-Gm-Message-State: AOUpUlEWF9MlMHzLKj8VgMdLHRrxe1mC2JUNF7d1KteeUQ3VEFm7IYqx qKLgLymTmzSO0ffPvIpaza60V6db X-Google-Smtp-Source: AAOMgpesKLIfC9Jlry6sk90mq/yWMvkPp8V+9hmP8MBWqZEtUdmfMSX2XIt0lUZybl1asqKMKHElJw== X-Received: by 2002:a17:902:7b96:: with SMTP id w22-v6mr5674890pll.24.1532174854622; Sat, 21 Jul 2018 05:07:34 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 21 Jul 2018 17:36:37 +0530 Message-Id: <1532174832-21644-6-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.29]); Sat, 21 Jul 2018 12:07:35 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Sat, 21 Jul 2018 12:07:35 +0000 (UTC) for IP:'209.85.160.67' DOMAIN:'mail-pl0-f67.google.com' HELO:'mail-pl0-f67.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.160.67 mail-pl0-f67.google.com 209.85.160.67 mail-pl0-f67.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 05/40] util: buffer: 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.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Sat, 21 Jul 2018 12:08:31 +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/virbuffer.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/util/virbuffer.c b/src/util/virbuffer.c index 65f4a08..a35feb6 100644 --- a/src/util/virbuffer.c +++ b/src/util/virbuffer.c @@ -455,7 +455,8 @@ void virBufferEscapeString(virBufferPtr buf, const char *format, const char *st= r) { int len; - char *escaped, *out; + VIR_AUTOFREE(char *) escaped =3D NULL; + char *out; const char *cur; const char forbidden_characters[] =3D { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, @@ -532,7 +533,6 @@ virBufferEscapeString(virBufferPtr buf, const char *for= mat, const char *str) *out =3D 0; =20 virBufferAsprintf(buf, format, escaped); - VIR_FREE(escaped); } =20 /** @@ -611,7 +611,8 @@ virBufferEscape(virBufferPtr buf, char escape, const ch= ar *toescape, const char *format, const char *str) { int len; - char *escaped, *out; + VIR_AUTOFREE(char *) escaped =3D NULL; + char *out; const char *cur; =20 if ((format =3D=3D NULL) || (buf =3D=3D NULL) || (str =3D=3D NULL)) @@ -643,7 +644,6 @@ virBufferEscape(virBufferPtr buf, char escape, const ch= ar *toescape, *out =3D 0; =20 virBufferAsprintf(buf, format, escaped); - VIR_FREE(escaped); } =20 =20 @@ -687,7 +687,7 @@ virBufferEscapeN(virBufferPtr buf, { int len; size_t i; - char *escaped =3D NULL; + VIR_AUTOFREE(char *) escaped =3D NULL; char *out; const char *cur; virBufferEscapePair escapeItem; @@ -750,7 +750,6 @@ virBufferEscapeN(virBufferPtr buf, cleanup: va_end(ap); VIR_FREE(escapeList); - VIR_FREE(escaped); } =20 =20 @@ -815,7 +814,8 @@ void virBufferEscapeShell(virBufferPtr buf, const char *str) { int len; - char *escaped, *out; + VIR_AUTOFREE(char *) escaped =3D NULL; + char *out; const char *cur; =20 if ((buf =3D=3D NULL) || (str =3D=3D NULL)) @@ -859,7 +859,6 @@ virBufferEscapeShell(virBufferPtr buf, const char *str) *out =3D 0; =20 virBufferAdd(buf, escaped, -1); - VIR_FREE(escaped); } =20 /** --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list