From patchwork Fri Jan 12 11:04:17 2024 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: 762192 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2843292wrz; Fri, 12 Jan 2024 03:05:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IF6LMsDqsOJFiYVl8rIHwz/7hhcO6rkvg1VbEYYZb/pX/nlYi+H6r6Qr9CTZ3yGP4mYq2eM X-Received: by 2002:a05:620a:495a:b0:783:1dda:f09 with SMTP id vz26-20020a05620a495a00b007831dda0f09mr2759239qkn.44.1705057526122; Fri, 12 Jan 2024 03:05:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705057526; cv=none; d=google.com; s=arc-20160816; b=danCdrXPGvKCgCeBRPTSHroSVKaQLI0oBXv14vakc8LymRWHNPoJuXBlX5BW7iCSoe /Teio3RDAVJ3TtHzvbnlK78kN6pAbIylueY7ICOCGp5Yr/KK9/LZZZXJmJ+g2byBhe4P J73bGW2+xa8KCjs9gQwRdjeX/8Prhs2BLbOgayN5Wtl85dkM6YrYeLve55Dn+c/sWthd eheGerNyhYe1rbMC+FyfuRLS23dsQNcxtoz7ddhDL47fLHDlOm0YfelgKaDWsSxy1B8f HT22RP3BH+o9COJ50T7rvZqtFqDh7B+Mz6lXOSo9GElyW60q+WB6FhnGKdatoeLiG79/ ODNg== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qAOf3/LPWt74QD5A3PJ62dj3myJnP4kwpfZCa4Hum5o=; fh=sPwrxG6cjHCxOBzF/IwiVazafz3DKBZkCIDRGj3ugas=; b=DHatJtpwWEQCIISTkV2bP98tIyzfDVCtdWX+6/hIc6AAwI1ZqVbV15m1lrDsW6murt T09UjI6UZbkEIYIVlIeKwi3QoHFPKipBRkacd3bChRmIvnZAne5C3Fk6nOjIKkrriEah BuFJuNPvAnIu70yjh8hwZUXXdfcb6azmVch+joGepcYRbc39a9leyX0jXwQE+++t/9p7 y6AdA/5urvYldwzB/xKn1hgfdKO3MF94bDwcWeb2m4tIEAJs9MWDtBK9dhjFCRpLQcf/ evo9LRldtEDA1m+O81Qryx1Nb3UKm6QZuVHnT2XZGH5DuQvdxDgZVhAlkoDsczvp47G6 yPwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e8g2NsEz; 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 y1-20020a05620a44c100b0078346abb16fsi2053133qkp.27.2024.01.12.03.05.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Jan 2024 03:05: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=e8g2NsEz; 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 1rOFLU-0005jH-Ps; Fri, 12 Jan 2024 06:05:08 -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 1rOFLB-0005Z4-Fp for qemu-devel@nongnu.org; Fri, 12 Jan 2024 06:04:45 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rOFL7-0008U1-EE for qemu-devel@nongnu.org; Fri, 12 Jan 2024 06:04:44 -0500 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-3368d1c7b23so5445089f8f.0 for ; Fri, 12 Jan 2024 03:04:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705057479; x=1705662279; 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=qAOf3/LPWt74QD5A3PJ62dj3myJnP4kwpfZCa4Hum5o=; b=e8g2NsEzMw7U8D6Il1/MyKsg9aLvtTY+V7QkvZhqK9yc6dvAG+hjaBBQD6WwylUemh pzwHTBOGornJbYwQAfgAWtXr/izurVsO6iFG6QEnyQG7E8A24+7j1j/MuKf2o7/oMKVr krWlLS0YhEWWdNjSKQl+fIr7L1XA67GJ2H2YUsCz/z9D0mxg/sLO06EmS+N6sPIyRj1G olEoFOCkXm2wGkgvut1I+i8AbFYAouVTYcjKWUfRHw7ZDhZvmxvcpWIVYfcOTMy8eYBI 9Mp4DCes+Edk3YFPbxBpDwPR58myPQkE5vS+/tkIHTiRD3d677GqCMDNz7555QHiCJXd SbOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705057479; x=1705662279; 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=qAOf3/LPWt74QD5A3PJ62dj3myJnP4kwpfZCa4Hum5o=; b=cTnPXQknezm92Hk4LYFlJvm7iPQtZXpmrG1ONnp59wRY0V0KlDMKh5KtGxD+i+E+79 /+zCYvcu8QCgE5n3ADX2+6wZ8nyz39VQJ+FwZ+/G5+ruv0Q9TXt5ELBhmfM5WutU5Co2 CeeBe6i4kCql2o7TUNx7eV0fcymZKBeeSbCBN9HZQ0kjhr2Xjjcb9LmfKWYpnFeOuru1 3d00qDSnDScAXjNSdEbU/bPS6e6IV8gnkgYfHCbE1mxQ19idcsanlOcPJt6CptN7YLvh AX0zmPU4+3BSoWJHy2eLpRi9IxMX2070yC7xJuG66tHf64XYImjv0783CoMklSFZyJtS NWsA== X-Gm-Message-State: AOJu0Yy9Ai3DCbzGFS8fIoYKuukZzXgemvqReW//XLtCbSqT2fWil7KL Wc0rDnoS9sb4YhrK4NQxAD8YwAQ7+ENsoNpwggocaxrOmW0= X-Received: by 2002:adf:e44b:0:b0:336:782d:b943 with SMTP id t11-20020adfe44b000000b00336782db943mr521893wrm.114.1705057478955; Fri, 12 Jan 2024 03:04:38 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id i6-20020adfb646000000b003378d89737fsm3229111wre.46.2024.01.12.03.04.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 03:04:36 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 64DE85F946; Fri, 12 Jan 2024 11:04:35 +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?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Paolo Bonzini Subject: [PULL 04/22] chardev: use bool for fe_is_open Date: Fri, 12 Jan 2024 11:04:17 +0000 Message-Id: <20240112110435.3801068-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112110435.3801068-1-alex.bennee@linaro.org> References: <20240112110435.3801068-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42e.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 make the variable name more descriptive and add kdoc decorations. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Alex Bennée Message-Id: <20231211145959.93759-1-alex.bennee@linaro.org> 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); -/* 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; }; /** @@ -156,12 +160,13 @@ void qemu_chr_fe_set_echo(CharBackend *be, bool echo); /** * 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); /** * 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) } } - b->fe_open = false; + b->fe_is_open = false; b->tag = tag; b->chr = 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; 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 is_open) { Chardev *chr = be->chr; @@ -344,12 +344,12 @@ void qemu_chr_fe_set_open(CharBackend *be, int fe_open) return; } - if (be->fe_open == fe_open) { + if (be->fe_is_open == is_open) { return; } - be->fe_open = fe_open; + be->fe_is_open = 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); } } diff --git a/chardev/char.c b/chardev/char.c index 185b5ea2556..3c43fb1278f 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -762,7 +762,7 @@ static int qmp_query_chardev_foreach(Object *obj, void *data) value->label = g_strdup(chr->label); value->filename = g_strdup(chr->filename); - value->frontend_open = chr->be && chr->be->fe_open; + value->frontend_open = chr->be && chr->be->fe_is_open; QAPI_LIST_PREPEND(*list, value);