From nobody Wed Nov 27 00:42:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1703155342; cv=none; d=zohomail.com; s=zohoarc; b=FEhxrexl36laZxGKScylDZ0fHxYfNtsE5k2Js05CmenZapkPKooq0+pMQOC3LPtXFb9DQ0mw/WvO/AQt5hly2xfttx2csFPCD/9DA9cDiSn6iLsockVCEN/kqaDZ8Bm9BXy9jDVMD45k+K3gfJoCLs313fDvxrLoWLOeQxQFJLQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703155342; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=rOpjk5Xc89URXPry+uTcPrYjjlL9ZRbEnDqtNUUFVo4=; b=PSMBoJwV0sZa9P/mDLR2+XR0TxGlTJzLYa2r9nE8OcKp78Kx6Rx1w4OiDNQ49qkmqTc0FrGl/MOQMxRhz5HIzTg40zT+d084AFwkskqLKLFX/ykkhitIZm4sDXUyuA7KgUTbs4efjuxtZChLdg61my54BnydJcTR85doD2VqafM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1703155342249279.24142914371566; Thu, 21 Dec 2023 02:42:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGGS6-0004Fz-AF; Thu, 21 Dec 2023 05:38:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rGGRs-0003nX-Dk for qemu-devel@nongnu.org; Thu, 21 Dec 2023 05:38:41 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rGGRh-0003yz-3B for qemu-devel@nongnu.org; Thu, 21 Dec 2023 05:38:39 -0500 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3365d38dce2so565944f8f.1 for ; Thu, 21 Dec 2023 02:38:26 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id l15-20020a5d560f000000b0033609584b9dsm1714193wrv.74.2023.12.21.02.38.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 02:38:22 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 557545F8C8; Thu, 21 Dec 2023 10:38:19 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703155105; x=1703759905; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rOpjk5Xc89URXPry+uTcPrYjjlL9ZRbEnDqtNUUFVo4=; b=A4LEzXgUNxc0QnmET8+ayCxvgeineXThZC13AoB8H9nVKShcqGLp7iePsLf7dFcFjL /xld/7pLhg5xgJgtH/DG6xFVwaNeeGLhLDzF7FM8uTPoj+4WhZ+beZIIOHC6f2bNhfHj 0/m1h0ZWLVB0VldPqLaniR8TYpWfYgc4Zf9qgcM3rlapwaIUCv0f1JCe1mqVLQSSCq1F So428RzsxVEvwv/OrrJe/t+sddgQ2G/YhGgKTSGWIfV/m+70OVLPKhCxY6NTzNmuNwCd 0S1ydg2+rAJUQy2oOoogfsvyyu5k9P5Bv2QJQ3Qa+5NpPJKNX1coTOtj67tyS09hZzsh k20Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703155105; x=1703759905; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rOpjk5Xc89URXPry+uTcPrYjjlL9ZRbEnDqtNUUFVo4=; b=PzYOyQ3lY3feUc+WhjlhHxAwt+TFLqgTsFE+GryWfd4SzE7WlnFAG3px4s27D6VmCJ nT2km+ny3JE1sFp+OI6ize/AL/OFWOHsDjldkDFhVYA4yTwBa0J7UuEKAmBOarvCamM8 OCbqPrUPw9pnnRYzunKWC2T2MFFys5TZjwAmEs8JdTRkbm4GsUe0IxF9AaiGQDNx7PQo YJ4LApIyHlXM5PN5xcVxZuw4mr/3nXLj/sl3q9/WSDLOetxeyLNaY3fagH2V2g3XsxVo PEAf6BnOEne1RMMm31SVoVKWDrzIUiZ+PkGOIZOl2eXjiBZ5PTXX2e2sY6mzH1Tq3M/i PwVw== X-Gm-Message-State: AOJu0Yyw0NOMb7pAAnxxDRrnN+69v3rZn8C5XWqT1ocIo1ioWDcc11J1 LrXxZcG7FE3evr1IHP2supGHhQ== X-Google-Smtp-Source: AGHT+IHlhYr5EXfT3dRGXsMcUV7DLzRG+3DIpxleIXcM/4GnHJs35pTv7FZjfYB9dcDkybTHNdnciA== X-Received: by 2002:a5d:6449:0:b0:332:e6ec:8306 with SMTP id d9-20020a5d6449000000b00332e6ec8306mr423448wrw.25.1703155105297; Thu, 21 Dec 2023 02:38:25 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Edgar E. Iglesias" , John Snow , Aurelien Jarno , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Eduardo Habkost , Brian Cain , Laurent Vivier , Palmer Dabbelt , Cleber Rosa , David Hildenbrand , Beraldo Leal , Pierrick Bouvier , Weiwei Li , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paul Durrant , qemu-s390x@nongnu.org, David Woodhouse , Liu Zhiwei , Ilya Leoshkevich , Wainer dos Santos Moschetta , Michael Rolnik , Alistair Francis , Daniel Henrique Barboza , Laurent Vivier , kvm@vger.kernel.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Alexandre Iooss , Thomas Huth , Peter Maydell , qemu-ppc@nongnu.org, Paolo Bonzini , Marcel Apfelbaum , Nicholas Piggin , qemu-riscv@nongnu.org, qemu-arm@nongnu.org, Song Gao , Yoshinori Sato , Richard Henderson , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Mahmoud Mandour , Bin Meng Subject: [PATCH 04/40] chardev: use bool for fe_is_open Date: Thu, 21 Dec 2023 10:37:42 +0000 Message-Id: <20231221103818.1633766-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221103818.1633766-1-alex.bennee@linaro.org> References: <20231221103818.1633766-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1703155342708100001 The function qemu_chr_fe_init already treats be->fe_open as a bool and if it acts like a bool it should be one. While we are at it make the variable name more descriptive and add kdoc decorations. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Alex Benn=C3=A9e Message-Id: <20231211145959.93759-1-alex.bennee@linaro.org> --- v2 - rename to fe_is_open at f4bug's request --- include/chardev/char-fe.h | 19 ++++++++++++------- chardev/char-fe.c | 16 ++++++++-------- chardev/char.c | 2 +- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/include/chardev/char-fe.h b/include/chardev/char-fe.h index 0ff6f875116..ecef1828355 100644 --- a/include/chardev/char-fe.h +++ b/include/chardev/char-fe.h @@ -7,8 +7,12 @@ typedef void IOEventHandler(void *opaque, QEMUChrEvent event); typedef int BackendChangeHandler(void *opaque); =20 -/* This is the backend as seen by frontend, the actual backend is - * Chardev */ +/** + * struct CharBackend - back end as seen by front end + * @fe_is_open: the front end is ready for IO + * + * The actual backend is Chardev + */ struct CharBackend { Chardev *chr; IOEventHandler *chr_event; @@ -17,7 +21,7 @@ struct CharBackend { BackendChangeHandler *chr_be_change; void *opaque; int tag; - int fe_open; + bool fe_is_open; }; =20 /** @@ -156,12 +160,13 @@ void qemu_chr_fe_set_echo(CharBackend *be, bool echo); =20 /** * qemu_chr_fe_set_open: + * @be: a CharBackend + * @is_open: the front end open status * - * Set character frontend open status. This is an indication that the - * front end is ready (or not) to begin doing I/O. - * Without associated Chardev, do nothing. + * This is an indication that the front end is ready (or not) to begin + * doing I/O. Without associated Chardev, do nothing. */ -void qemu_chr_fe_set_open(CharBackend *be, int fe_open); +void qemu_chr_fe_set_open(CharBackend *be, bool is_open); =20 /** * qemu_chr_fe_printf: diff --git a/chardev/char-fe.c b/chardev/char-fe.c index 7789f7be9c8..20222a4cad5 100644 --- a/chardev/char-fe.c +++ b/chardev/char-fe.c @@ -211,7 +211,7 @@ bool qemu_chr_fe_init(CharBackend *b, Chardev *s, Error= **errp) } } =20 - b->fe_open =3D false; + b->fe_is_open =3D false; b->tag =3D tag; b->chr =3D s; return true; @@ -257,7 +257,7 @@ void qemu_chr_fe_set_handlers_full(CharBackend *b, bool sync_state) { Chardev *s; - int fe_open; + bool fe_open; =20 s =3D b->chr; if (!s) { @@ -265,10 +265,10 @@ void qemu_chr_fe_set_handlers_full(CharBackend *b, } =20 if (!opaque && !fd_can_read && !fd_read && !fd_event) { - fe_open =3D 0; + fe_open =3D false; remove_fd_in_watch(s); } else { - fe_open =3D 1; + fe_open =3D true; } b->chr_can_read =3D fd_can_read; b->chr_read =3D fd_read; @@ -336,7 +336,7 @@ void qemu_chr_fe_set_echo(CharBackend *be, bool echo) } } =20 -void qemu_chr_fe_set_open(CharBackend *be, int fe_open) +void qemu_chr_fe_set_open(CharBackend *be, bool is_open) { Chardev *chr =3D be->chr; =20 @@ -344,12 +344,12 @@ void qemu_chr_fe_set_open(CharBackend *be, int fe_ope= n) return; } =20 - if (be->fe_open =3D=3D fe_open) { + if (be->fe_is_open =3D=3D is_open) { return; } - be->fe_open =3D fe_open; + be->fe_is_open =3D is_open; if (CHARDEV_GET_CLASS(chr)->chr_set_fe_open) { - CHARDEV_GET_CLASS(chr)->chr_set_fe_open(chr, fe_open); + CHARDEV_GET_CLASS(chr)->chr_set_fe_open(chr, is_open); } } =20 diff --git a/chardev/char.c b/chardev/char.c index 996a024c7a2..0653b112e92 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -750,7 +750,7 @@ static int qmp_query_chardev_foreach(Object *obj, void = *data) =20 value->label =3D g_strdup(chr->label); value->filename =3D g_strdup(chr->filename); - value->frontend_open =3D chr->be && chr->be->fe_open; + value->frontend_open =3D chr->be && chr->be->fe_is_open; =20 QAPI_LIST_PREPEND(*list, value); =20 --=20 2.39.2