From patchwork Mon Dec 11 14:59:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 752520 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c83:0:b0:333:3a04:f257 with SMTP id z3csp1348539wrs; Mon, 11 Dec 2023 07:01:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFNpry522vIyw7MUXdpCcWeQQrBsvfMKkyjjWHLtaQCw6kzlbnl1zc1c2+UsvSdMNg8MYk1 X-Received: by 2002:a05:6e02:174c:b0:35d:59a2:a325 with SMTP id y12-20020a056e02174c00b0035d59a2a325mr4620793ill.39.1702306886178; Mon, 11 Dec 2023 07:01:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702306886; cv=none; d=google.com; s=arc-20160816; b=K/qDNoouTD1TXeIIjNUYwr1PO5UFONRAneEa0iPWnKMXTKh4KGZubSLj+JODHH0XZ5 4NlqD5DBPvZXbp4+SYvcUF5Yq2bP0fsTW0/sCMWi5G0nvJN9iNFwvWoYqHjyQ4NSqHJk fpd6mZWohKcsgnnDQFFByInTL5KVBVNsiSPRTDFH6e3jD2qhhxQHNuLYrG04o27LKWBq 6tkM7tPV2a7nLJCxdoyBTEq5S7raGtI+MK31HPYyNILUlrDsjTAatyODGw5jHOXqe652 vbmyYc0NRscBR2WABpKms/feTsUh25zlZGh+rOtcTzLX8GV7RPrj3+b3+FKdNZWVrifd H1cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=gRGCxW6C87fW7k1z6BNfM3iwOvIKvLjOJp9SZ6n603I=; fh=RymT9NWGm6BI7WsnqYrfXcSeJF/Sim9QPcA2Iiik3qE=; b=pi6GCS+ErWRM9NJSCt79xgNH2yUm7ZoJvMtHn2Wm6GARfYQVQhT5Xv3L+KZ0NJzJK6 ThJPNIhp3bbp9j+eu+w9A/dZ8LFOy0kdHi1vpClZssXd5M0EzKw1gYufrIqWoLZGFZy8 D8taMPftCfbWadgkShRJi94MPk7GGPZCBDWTS/vvlIK8ppD29dTVgERs4PkZSf4bjyoL MhVYwq3GW0JgFCqxtNgh1QXDzkD13+7cM3Z05JsaezGCEsK0yhMtTlw7xsDE6t5a3WLV SxZ7IRbxzHBozVfVZh+r0sGxBVJXcZrcj+uYggC3GRb1KLMPdLkBsAFHRpeHBOjcqSUQ Qk/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=psTn2sKA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b25-20020a67fe99000000b00466025f4f1bsi1033824vsr.354.2023.12.11.07.01.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Dec 2023 07:01:26 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=psTn2sKA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rChlo-0006wR-Kt; Mon, 11 Dec 2023 10:00:32 -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 1rChlf-0006qe-Rm for qemu-devel@nongnu.org; Mon, 11 Dec 2023 10:00:29 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rChlQ-0005Ld-7l for qemu-devel@nongnu.org; Mon, 11 Dec 2023 10:00:19 -0500 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-333630e9e43so4722769f8f.2 for ; Mon, 11 Dec 2023 07:00:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702306805; x=1702911605; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=gRGCxW6C87fW7k1z6BNfM3iwOvIKvLjOJp9SZ6n603I=; b=psTn2sKAZ8io0Ja3mHR80E3EPHhO3i80JWb/riq/lgAiwNthgZCxzEDDvtBv1G6yVa +VJ0zXbnM2XGDduf5XJtRUQyC0+Zjdi+lSK1dlP/3clmxGjB4oTE/Au7saC/8bfF32f3 HEGIv1B91Loti69JYTzDF0/uMH3Fd4LtH3B5+ohDXVwmsVMYWXH1sXOO9QdHXpMrn0jU 9LsZJ8lpQL95H/L+PUip0wqMn13CKDyMg6+vJp2Dy3ImJrE4ppjqGff0qtrx1TsCLukt Vs8fb/si2uV5Yaw2qyNr2eAWdE4VaZ55j89m13XejX0RcMgexYPpcg82fIY6uw/CFpRR 9Jrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702306805; x=1702911605; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gRGCxW6C87fW7k1z6BNfM3iwOvIKvLjOJp9SZ6n603I=; b=DoApP5amifYrM8+lkHSiZGQtQ3BFBJWmWsfbOWp3tTDA1AQr+PA/rH0WVaRM6k7qyH xCM7/XjiwlAH9NAZL6e6RijGCm8cOVyVMRNY/i7MqA8pHX3m254ucQenIGaL7ylZvahB sKWwygeRET0B/35xer9uNxoya8CUfVHvJAfkoEmbPQUtqSUeKKxT5erJwSh03MPnuAku CJT1TUKe2IWAXi6R/MgxMi9+bvG3+fFKwOShPFieOhq0vwrQlN2889g1b3VoSxkZ9swW Rx6tKStJAJV76ZcNJ5F4vC82ZddYTSZgNNXF7P+5U+CptfyJ2NmFwT6SXR6F5wHYikqG Utbg== X-Gm-Message-State: AOJu0YwKlLRCurIONJEy6VHh3sI7ipwRRHX6j7PfSq73MskiNLiXU4vi BRvbI5esOM6QCjdgM/0pFj0XAw== X-Received: by 2002:adf:fe04:0:b0:333:2fc4:457 with SMTP id n4-20020adffe04000000b003332fc40457mr1403498wrr.80.1702306805001; Mon, 11 Dec 2023 07:00:05 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id w13-20020a5d404d000000b003333f9200d8sm8789562wrp.84.2023.12.11.07.00.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 07:00:04 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 1A3C35FBC6; Mon, 11 Dec 2023 15:00:04 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Marc-An?= =?utf-8?q?dr=C3=A9_Lureau?= , Paolo Bonzini Subject: [RFC PATCH] chardev: use bool for fe_open Date: Mon, 11 Dec 2023 14:59:59 +0000 Message-Id: <20231211145959.93759-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42b.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=ham 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 add some kdoc decorations. Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé --- include/chardev/char-fe.h | 19 ++++++++++++------- chardev/char-fe.c | 8 ++++---- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/include/chardev/char-fe.h b/include/chardev/char-fe.h index 0ff6f87511..87b63f8bc8 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); -/* This is the backend as seen by frontend, the actual backend is - * Chardev */ +/** + * struct CharBackend - back end as seen by front end + * @fe_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_open; }; /** @@ -156,12 +160,13 @@ void qemu_chr_fe_set_echo(CharBackend *be, bool echo); /** * qemu_chr_fe_set_open: + * @be: a CharBackend + * @fe_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 fe_open); /** * qemu_chr_fe_printf: diff --git a/chardev/char-fe.c b/chardev/char-fe.c index 7789f7be9c..5a09ef4da7 100644 --- a/chardev/char-fe.c +++ b/chardev/char-fe.c @@ -257,7 +257,7 @@ void qemu_chr_fe_set_handlers_full(CharBackend *b, bool sync_state) { Chardev *s; - int fe_open; + bool fe_open; s = b->chr; if (!s) { @@ -265,10 +265,10 @@ void qemu_chr_fe_set_handlers_full(CharBackend *b, } if (!opaque && !fd_can_read && !fd_read && !fd_event) { - fe_open = 0; + fe_open = false; remove_fd_in_watch(s); } else { - fe_open = 1; + fe_open = true; } b->chr_can_read = fd_can_read; b->chr_read = fd_read; @@ -336,7 +336,7 @@ void qemu_chr_fe_set_echo(CharBackend *be, bool echo) } } -void qemu_chr_fe_set_open(CharBackend *be, int fe_open) +void qemu_chr_fe_set_open(CharBackend *be, bool fe_open) { Chardev *chr = be->chr;