From nobody Tue Nov 26 22:35:21 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=1704303442; cv=none; d=zohomail.com; s=zohoarc; b=PO0nsek5IEpph4IwiYEzDbTKd36rfiu1H+vrvsTFm1DGqgKKdSiSDPf6OCNyKt4vjawoz5ReZyCOffmKu+khHK7Eubek6xMX12e5x61hks+xFtggvZt39XJwv2tg5Xek2q6MN5rvzLaGDu8M85p+co6cGnjbehg7WHkwC94pMrM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704303442; 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=KW6WYoEDOqqzk7Ufbo4Y2ykN6XgKVhf2uvYb5HphstOqZLdtiEEq846Ybhk0cnovNt1DuTsrHeY6f+jjYwDp5KN1ong3Mu4GfmxSdmtH5Ue6/DPnBd9N6Rqsq+C0d6iJEEG9utZ1L1smpHB6tszPBDlz4rKbZ3Z8edkAl9b0FnA= 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 170430344245039.31833757051072; Wed, 3 Jan 2024 09:37:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rL58A-0003cz-D1; Wed, 03 Jan 2024 12:34:14 -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 1rL580-0003VI-JR for qemu-devel@nongnu.org; Wed, 03 Jan 2024 12:34:06 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rL57p-0002Nz-Ub for qemu-devel@nongnu.org; Wed, 03 Jan 2024 12:34:01 -0500 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-40d5ac76667so55663305e9.1 for ; Wed, 03 Jan 2024 09:33:53 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id fl27-20020a05600c0b9b00b0040d2dfb10e0sm2979265wmb.11.2024.01.03.09.33.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 09:33:50 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id AB9515F933; Wed, 3 Jan 2024 17:33:49 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704303231; x=1704908031; 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=j7R+G2pJWTMP9nz9N56OlOSgXJYdnt1QbdmbCheotup826UTwL7TO3/sUqhmPQ6eNG fSrZ2lIHg08wRb+613ubQ47Pu4cy743voWDbKgzXahU4ZSqIeQmMMCZcXoycVf7L8O4g ikIFEzJ5PXzlMSqj24sWKAtO/bX3DmaCKwajVfp5DmdBg7hNmaVzBBoRg+mdMOYH/t5l 7dwz4ECfIlCDFJ0qZP0+ydHpaRQYtqWgjEjWWjVeGy5DmEiJIJp7xJjbVK96yZxFK550 f6aWCJy3NJHYphH7mlDBE/wFKyfb7j/MLfW9B5ufYOliv91lTXo/gwP+Mclm+lPbKOry bNjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704303231; x=1704908031; 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=PX6VmDBOq+q/iVeA9WLPBWZfdbIMQT6BQAHKu1ffgd6gBTOT64kHHuVsQzQACQpkaW hDc2yqE2TPcNrfo1WjnLfE/n0m1ntgbkKPuY6OLfTFlegWNn+ldBmKfWVl0Z/gO7If/5 3NyhfhhMY/WA9NSm6OLGU7eHOUn0jDcVmJB4BP9avcbV5jWfE/DECFTzw4sxwsvDswWz S7EB/vYR13I4UIGF2awqbt//Ze/UeF3kOv1bSwLx8puWvPpIbFinBIbJlZBggK6zFbVq 8yT511Bskqe4/O1Im8tNta0k2kYpxzh2lIsqOBqPMhgV2DPnonakqqT0NOsZeyWxnlVe i1qg== X-Gm-Message-State: AOJu0Yzv0pK3EPnjTGR9idUa8ADVd3rHjwhlw1cWaJFiYbJ6ksmJOpc/ rijm3tHD9GHlE80Jxj+P51cKIqmL3v8kMA== X-Google-Smtp-Source: AGHT+IEhbukIbMJxe0XeRt2lHobV2JbuWL9JZcjldNC8OY0732Jbqq6ubAvn3PMQTDTFrXUf5ogLhA== X-Received: by 2002:a05:600c:a003:b0:404:4b6f:d70d with SMTP id jg3-20020a05600ca00300b004044b6fd70dmr11754074wmb.17.1704303231383; Wed, 03 Jan 2024 09:33:51 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, Richard Henderson , Song Gao , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Hildenbrand , Aurelien Jarno , Yoshinori Sato , Yanan Wang , Bin Meng , Laurent Vivier , Michael Rolnik , Alexandre Iooss , David Woodhouse , Laurent Vivier , Paolo Bonzini , Brian Cain , Daniel Henrique Barboza , Beraldo Leal , Paul Durrant , Mahmoud Mandour , Thomas Huth , Liu Zhiwei , Cleber Rosa , kvm@vger.kernel.org, Peter Maydell , Wainer dos Santos Moschetta , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-arm@nongnu.org, Weiwei Li , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Snow , Daniel Henrique Barboza , Nicholas Piggin , Palmer Dabbelt , Marcel Apfelbaum , Ilya Leoshkevich , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , "Edgar E. Iglesias" , Eduardo Habkost , Pierrick Bouvier , qemu-riscv@nongnu.org, Alistair Francis Subject: [PATCH v2 04/43] chardev: use bool for fe_is_open Date: Wed, 3 Jan 2024 17:33:10 +0000 Message-Id: <20240103173349.398526-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240103173349.398526-1-alex.bennee@linaro.org> References: <20240103173349.398526-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::32e; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32e.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: 1704303444234100003 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