From nobody Fri Nov 14 20:59:33 2025 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=1761144653; cv=none; d=zohomail.com; s=zohoarc; b=IkF8sOEIeVWkVFdSZLEFrcX6+pn8FFnYUiP54UAFHH8M92GIquRTq/12E1uOpvnwIrIddt31/oPLb+e5RXPbWDCAy8YBS+cAO3ZWF6jKObLcYYJHKEm5ruvraxYEEIL9pc9wHMPOhxpUT9scRrIXRKyW4NeEjCH8xFyTiyL3oRE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761144653; 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=f3ngZPbaDwZJ3E3qgfPsLGR0H4y0FqCGiSlAmIJaKZo=; b=iaxDeH9My87/PvYoVBz1Exasgo7GGkYMkkBE2Pgz7Cz05pAcA+ciOXjy9GSqgQUb5eakIrqLQaqYfkLd08c9LGiAR4AGbl4YICad2j8j4Ju823OeajDMinmX4r4Q19+IFa3MCFuwjFMQ7KvYE20En1XGf70d2hCMUdKfCLZUdyI= 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 1761144653496759.6574182974359; Wed, 22 Oct 2025 07:50:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBaAp-0005f7-GB; Wed, 22 Oct 2025 10:50:47 -0400 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 1vBaAd-000553-VU for qemu-devel@nongnu.org; Wed, 22 Oct 2025 10:50:37 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vBaAb-0007eR-93 for qemu-devel@nongnu.org; Wed, 22 Oct 2025 10:50:35 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-47112edf9f7so34131825e9.0 for ; Wed, 22 Oct 2025 07:50:32 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-475c41ca845sm48831605e9.0.2025.10.22.07.50.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 22 Oct 2025 07:50:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761144629; x=1761749429; 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=f3ngZPbaDwZJ3E3qgfPsLGR0H4y0FqCGiSlAmIJaKZo=; b=uwl8nTJHg/Epkr6OCRIP2CIG8z2RWKhnoyQUN+I/48ujSNUJtTOfKve6/7PtGkcEBF JqjQAZXF4Kw2C1vCU0/jWOw13XNLo6K2IaAX4BjKVDcDeJtgwYABeDJsxlo/peqRSKsB ZqhsnGZsMBO75mHrf58hE/p+J459ybUcv+DX8rWKUHB32qq74p45ZoTjEm9R32vMwsRT LG5Oh8fkksONPS9A97nFmI7wO/MKj2kfDHYaETBQcagqzxJMsJTE+AbEOoiZegCptKuz F0dsacKkIfktfys0VSiVcKJXgxpbwVvGANCwC1wjg8TAnkR7YR2irXVhNSKkRxsjMeOZ +gXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761144629; x=1761749429; 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=f3ngZPbaDwZJ3E3qgfPsLGR0H4y0FqCGiSlAmIJaKZo=; b=VfJA6CJphyK7UYIAKCoH4x7b8mnX2b60UGXpbieYnFNvUAKqWrIaSFXPwHXA4mSoi1 oqTX+08cfj3hus6yFXgIGd/nq9nOG3AQAP/gVL27dxvvrjreb2bAq1Py0fNfvGw3WiDQ 8Ov+qn0VU2wfMKB47ybPOArySBvgMDNEnNsxG7xTLADQaHc6XG6WvNDSAEgmR7UqDUzo cYbOPdCC4rr+TLLUpQFksV9BAS2FR5MRHAEkJ1a8a0XwfHZP2QkUN4C3JUGBP9Vr2Bhc G7u1FOg4qnyUbVuR002Wduy3hRRoVzWkFaneNl4+952NG0+cv382dyk8ogRY3ckHLSuk 9Yog== X-Gm-Message-State: AOJu0YyD4DsuJkHb1prjuyfoT30UXY5iOsYX5lajgPK2KNbtnh3qYo4J sTDGII/1I7q1wJGUMo/h7pdF8EUqTNyCnbvrk6zvE/HUfluT8Oy/0sESfua3RZetr6CrhuxObBZ MjIGh90A= X-Gm-Gg: ASbGncvUA/FjsN6oN8C9pM8okEYMHjUopdZT9B2Qa0k74jCD48Zh8zMm0nyQrT5mGQJ i3YJsL0xO5fsLsn+t0bNIskRc7bGzeqvqyIXRt1tTh1s2RnBWBrXUAgTpI/ynVnkguztE9FauZu WEMafm9eeTcdtbbCeHuFvnc6wcc0bD5+6nwU1XylRZrne8iPq3IoxnK07x+2Zu1ENoGBjPn0enO RzD7ZcT17aXAnfXG82qOsHGBKVdwLkiykV0vFviibePmMUjaRqZt6sbYJiNr+WeCodyhkCeSszT 5T6tsD+EAqrO6sSPt+rnR75ZJW/VkA1OGzwsB7zqCj6x0ZzEnD7pE+lbJ5a65BgOK7IQNz+R2jp 6Cvaoc9GE/C94Kx/09X5BwgjdTkyq9ONy8cq2aQfgD9pNqbCRy3Me6SqpIIMfHUao7EFKJWosYr oclB2UfXIagwJXT5yP4KX6L3nnC3AeXAARJm0TrQEa1u5GmpsisQJEG+8z05yI X-Google-Smtp-Source: AGHT+IHtYL2UYZnW2Z2tb6CcX9id3CCNeh+XNNnh/f0uVVwIc1E/B1zC05C+HEU3RWM/cM2BEnrGAw== X-Received: by 2002:a05:600c:1907:b0:46e:206a:78cc with SMTP id 5b1f17b1804b1-4711791c3b0mr179311735e9.28.1761144629314; Wed, 22 Oct 2025 07:50:29 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , "Edgar E. Iglesias" , Alistair Francis , Palmer Dabbelt , qemu-arm@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH 7/7] hw/char: Simplify when qemu_chr_fe_write() could not write Date: Wed, 22 Oct 2025 16:49:02 +0200 Message-ID: <20251022144903.74612-8-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251022144903.74612-1-philmd@linaro.org> References: <20251022144903.74612-1-philmd@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::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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 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: 1761144653956158500 If no chars were written, avoid to access the FIFO. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/char/cadence_uart.c | 2 +- hw/char/ibex_uart.c | 2 +- hw/char/sifive_uart.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c index 0dfa356b6d0..8908ebbe34a 100644 --- a/hw/char/cadence_uart.c +++ b/hw/char/cadence_uart.c @@ -316,7 +316,7 @@ static gboolean cadence_uart_xmit(void *do_not_use, GIO= Condition cond, =20 ret =3D qemu_chr_fe_write(&s->chr, s->tx_fifo, s->tx_count); =20 - if (ret >=3D 0) { + if (ret > 0) { s->tx_count -=3D ret; memmove(s->tx_fifo, s->tx_fifo + ret, s->tx_count); } diff --git a/hw/char/ibex_uart.c b/hw/char/ibex_uart.c index d6f0d18c777..b7843c7a741 100644 --- a/hw/char/ibex_uart.c +++ b/hw/char/ibex_uart.c @@ -161,7 +161,7 @@ static gboolean ibex_uart_xmit(void *do_not_use, GIOCon= dition cond, =20 ret =3D qemu_chr_fe_write(&s->chr, s->tx_fifo, s->tx_level); =20 - if (ret >=3D 0) { + if (ret > 0) { s->tx_level -=3D ret; memmove(s->tx_fifo, s->tx_fifo + ret, s->tx_level); } diff --git a/hw/char/sifive_uart.c b/hw/char/sifive_uart.c index e7357d585a1..e5b381425a9 100644 --- a/hw/char/sifive_uart.c +++ b/hw/char/sifive_uart.c @@ -83,7 +83,7 @@ static gboolean sifive_uart_xmit(void *do_not_use, GIOCon= dition cond, fifo8_num_used(&s->tx_fifo), &numptr); ret =3D qemu_chr_fe_write(&s->chr, characters, numptr); =20 - if (ret >=3D 0) { + if (ret > 0) { /* We wrote the data, actually pop the fifo */ fifo8_pop_bufptr(&s->tx_fifo, ret, NULL); } --=20 2.51.0