From nobody Tue Feb 10 16:22:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1611937063; cv=none; d=zohomail.com; s=zohoarc; b=A8kG7tPCuLk6SYAgqtH+fbOHZ76eRNATfZJgCEhLYM5wFCxGK0EIL1xVTIzm1RxycWdc5bUThlknzg2FZYp+kPgqLMoGk9Lk/QXJ/7ENpEleQ2+2OjXXccE+jKrxZw02pxnJsuUmzMBb00DZju4ELZZZGQAjgvXwsXkZUTAka7c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611937063; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZxccirO/ZRQ415K4SY0vC9Cr735QVxM1xis9LeZlD5E=; b=N4EAmj9DF8lpOmNF0Wahf+QinY3Zsr+8DyjtP5G6pjn/qQyCffy2kxJAg4fzpLKgZv/YcBhzr6Mq02Ix5O+viqL5WzUka5HiMYblmEto1Im0Y6izf9m3elurcEnCQzf8mx4R5XeD/GsgPFqqe0oG8NLAArO3HfLtgHDHPPedsLg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1611937063081617.7781156489708; Fri, 29 Jan 2021 08:17:43 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-470-xn7yn16JM6CqW0Af7HyNHw-1; Fri, 29 Jan 2021 11:17:40 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 39196107ACF5; Fri, 29 Jan 2021 16:17:32 +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 16D059CA0; Fri, 29 Jan 2021 16:17:32 +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 D7F8F1809CA2; Fri, 29 Jan 2021 16:17:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 10TGHRPi010690 for ; Fri, 29 Jan 2021 11:17:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4D64960CD2; Fri, 29 Jan 2021 16:17:27 +0000 (UTC) Received: from work.redhat.com (ovpn-113-143.ams2.redhat.com [10.36.113.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DFE260871; Fri, 29 Jan 2021 16:17:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611937062; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ZxccirO/ZRQ415K4SY0vC9Cr735QVxM1xis9LeZlD5E=; b=dTs2qWa8rlI5hHlxzsWpsjjrLaiwXFwXSyHcDhsTS8g0dXpw0AkunSLAg+AVwYtaEMPtBq OsyzgtF7ffu5nlD74N5Ik2Ix7/hXpZOsyHS8wLfi4B9M5vq7jqgXDKt6lc5pfwTY8fQuQt /3OPNq2OyCBXngVPj2p9sxUEQD/bl4w= X-MC-Unique: xn7yn16JM6CqW0Af7HyNHw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 16/19] commandhelper: Convert parseArguments to g_auto* Date: Fri, 29 Jan 2021 17:16:26 +0100 Message-Id: <20210129161629.604823-17-twiederh@redhat.com> In-Reply-To: <20210129161629.604823-1-twiederh@redhat.com> References: <20210129161629.604823-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake --- tests/commandhelper.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/tests/commandhelper.c b/tests/commandhelper.c index 6d5fe04042..e616f92987 100644 --- a/tests/commandhelper.c +++ b/tests/commandhelper.c @@ -35,24 +35,32 @@ extern char **environ; =20 # define VIR_FROM_THIS VIR_FROM_NONE =20 -struct Arguments { +typedef struct Arguments { int *readfds; int numreadfds; bool daemonize_check; bool close_stdin; -}; +} Arguments; + +static void cleanupArguments(struct Arguments* args) { + if (args) + free(args->readfds); + + free(args); +} + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(Arguments, cleanupArguments); =20 static struct Arguments *parseArguments(int argc, char** argv) { - struct Arguments* args =3D NULL; - int ret =3D -1; + g_autoptr(Arguments) args =3D NULL; size_t i; =20 if (!(args =3D calloc(1, sizeof(*args)))) - goto cleanup; + return NULL; =20 if (!(args->readfds =3D calloc(1, sizeof(*args->readfds)))) - goto cleanup; + return NULL; =20 args->numreadfds =3D 1; args->readfds[0] =3D STDIN_FILENO; @@ -65,12 +73,12 @@ static struct Arguments *parseArguments(int argc, char*= * argv) (args->numreadfds + 1) * sizeof(*args->readfds)); if (!args->readfds) - goto cleanup; + return NULL; =20 if (1 !=3D sscanf(argv[i], "%u%c", &args->readfds[args->numreadfds++], &c)) { printf("Could not parse fd %s\n", argv[i]); - goto cleanup; + return NULL; } } else if (STREQ(argv[i], "--check-daemonize")) { args->daemonize_check =3D true; @@ -79,19 +87,7 @@ static struct Arguments *parseArguments(int argc, char**= argv) } } =20 - ret =3D 0; - - cleanup: - if (ret =3D=3D 0) - return args; - - if (args) { - if (args->readfds) - free(args->readfds); - free(args); - } - - return NULL; + return g_steal_pointer(&args); } =20 static void printArguments(FILE *log, int argc, char** argv) --=20 2.26.2