From nobody Thu Nov 14 06:51:11 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=1705057526; cv=none; d=zohomail.com; s=zohoarc; b=NupuqJEbUbBwRoxzzzwnCe0U01KuMGbMWa9qpAwC+vHtnLJ9l+gfYqyXz0sJnoZ3TcZlSTkeJ75+aaDsaB0EA8BPRpVM1N6AKE7YKIzRynqEgVEy/uXNl6Jkxyr/DCDB+dDiKPz9nKEDyXPMaEv29tTzsEZDJ2gzihdD5dNe+gg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705057526; 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=qAOf3/LPWt74QD5A3PJ62dj3myJnP4kwpfZCa4Hum5o=; b=YR0/hT3HBPZCbcrhbQI2H/qOlTY68DW16jNz+/bHXe6l30MVDH5ToLujEjcRYP3N+D38TPwN67Za/T+FPA05FbOsQ4Ibogjxq9pe2kVVQ6iuF5S0zqO2e0V6VJoYLPi3emVsqc4uK7PAMB2oJDiO5p7Qo13Rm0nBFBYwR0/Zdz4= 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 1705057526503584.3623000241075; Fri, 12 Jan 2024 03:05:26 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IE/zvanupKi3WDAZaWr7WNurjVM6tTJzzzq9t5hSv1vj75zYICP3FjG9LDN8MKxAslhq2J9jw== 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) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , 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 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::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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1705057528339100009 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> 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 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) =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