From patchwork Mon Jul 22 16:07:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813725 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp1940924wro; Mon, 22 Jul 2024 09:08:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVbalpuRo37VHqqPjVqfuK67ajTxhap96Xb5b7f1CeWuMzFs+bLElYhsMsyzW7eDXVUFZmuZDabwLeIxuyll/EV X-Google-Smtp-Source: AGHT+IG7OvGdUq1xnZA+ZOcqKc+fbhX0z/CrEqW47zFa+RVucZW11zIyd/uz4hKVFhZrHqbKk7wf X-Received: by 2002:a05:622a:13d0:b0:447:dfe4:5d26 with SMTP id d75a77b69052e-44fa5345e24mr127800611cf.43.1721664512053; Mon, 22 Jul 2024 09:08:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721664512; cv=none; d=google.com; s=arc-20160816; b=CTg4W6RkUvFiqBCq7iz1qb5NMy9EbCT68Tnl/hJtNCL10s48x4eXlYXP2JoripILlx ZniEDPRnQOoxAjDVP8iPBsZXGfvq8YwsEirf7o1YlOlqeSNCJV9kxOyjg4baTBRJyFnY Up7ba3HXens1EaJQQ1+Ue5SDSnZoI9wYzyz0bjpWZbMaGgce0BrkVGW15nqxthPeQL70 qVAdcoT/WR8eP+YsoSI3DIUgNjvAQVrJrLRkhVAn6Q9GVk6u+K0GRaR3FMQCSqsG6mrO /dn/hGz4oCvNEwt7elzajpAYn9e20QeMtlqyWJ6TPEmZ2BOC3g3LqXDuGeVGjHgeNzSv V1/g== 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=Qcm1dWrebznI1t8ebTrFn2d5NidY82tKkmYUS0FD2gQ=; fh=pA26/TpFHAj3dhwie1wJOLhR+LuI9XikNoV1W9RAiFw=; b=TSR/5MFQQcSr4yj0VyQyayOB4SvyvtYtGDtFxPkRFY3PSKs6XWDKtwiTTPteOQ2YlR E2wmARGpVRbEQi+WGgV6Pa/MN/gIpbpWLmijPImCW6KICWC34AqBoWulslvEBg0V0YKo Zwk1YP1+HwuOKeDxjL2gP5gTe2RS/3Jlojfg7uHJFV0U+heXS5+reXCt+cthVcUDEHts bSoKazz8sTIgo2nr06afztkv5k8rXvGeM8Ja+Wrk7fkcvy+CuAeUy6EOXKl5x/Lv7M4S lZRAGv/TvTmS6SIZL17JaCqdy5Oa3ADPudapr8BzFIkEdVXGIHZXnTfrjRNN/q4mQszn FVrg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NLV8eCeE; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44f9ccfae4csi78726351cf.63.2024.07.22.09.08.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2024 09:08:32 -0700 (PDT) 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=NLV8eCeE; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVvZx-0005Z3-Rl; Mon, 22 Jul 2024 12:08:02 -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 1sVvZu-0005NJ-N3 for qemu-devel@nongnu.org; Mon, 22 Jul 2024 12:07:59 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sVvZs-0007gS-P9 for qemu-devel@nongnu.org; Mon, 22 Jul 2024 12:07:58 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-367990aaef3so2359060f8f.0 for ; Mon, 22 Jul 2024 09:07:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721664474; x=1722269274; 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=Qcm1dWrebznI1t8ebTrFn2d5NidY82tKkmYUS0FD2gQ=; b=NLV8eCeEiYdnLs8qvOnojSPbb3yEkQyxJY7ossDISd215Lb+4C4m9MnbsOvrR/OEkF njJw9aazeaFsET3BcQqW3VQ965dXapeQQzT4U6rdV7lnxdhOG3amI7IIqfqsox4OKCcK Po/E0iJkai2HDfh/NZJvDCFQH4ZjdfINvy/KHf2KQuCQeC5MUG08Vre37g0OxvmZfUI0 eEjyEUGrsmqskI+bRH+JSNfY/Lk/gbzO6/EdR/FqguNRdKBLzBCJKUFl9ZNW65u1NmPm k2hNKG51CztPX4+lc2S4VDF/kFArQEofD84bssQP2JlQz6hltol73gZwAvAJOM8HhWZJ f9yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721664474; x=1722269274; 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=Qcm1dWrebznI1t8ebTrFn2d5NidY82tKkmYUS0FD2gQ=; b=ecRYQKlRq1764sy8VWQ5PGnQw8tvdCto7or0v7cok5kXrcplOoWo/oJ+8XTQNEK3D5 AR7ecRzPjg0YNtuBWcCmgxdxk1KiNvyzrgO3JG2vIgGUWKBUCq7C29bpR+LsjZ2V0ejP k9KVWgKQpMuEaKJcQZXixpLLFoNl3NAnhsViNzoD2ogO0zf7/EczkF3tQ2xSw73pr7HG pp0TN9UKjcCK9Kh7tEa2rE2k6YllGQ2YHienbzJn0eVmLLAU7QHVJjlAAis4Q+xxjmXY FLmU92WI5hCbrc3crpgxRJxAjMOc4d72cGMycW6skeT5ovdAPCMs72Ur0hEsvPVCxirl vyZw== X-Gm-Message-State: AOJu0YyANUqmKnX6EqIoh3FGG15GxRd3Eb1ALquC1GxWIiGhweDUWzxW Bx1wA/0vhP0czcDtwD8k8PH8sc5BfnWE6M0ti6x4gupQfzRyZN5Ljoa47gcMcVDxdcFmHZj2WD8 w X-Received: by 2002:a5d:6b02:0:b0:368:420e:b790 with SMTP id ffacd0b85a97d-369debf8ba2mr218506f8f.14.1721664474403; Mon, 22 Jul 2024 09:07:54 -0700 (PDT) Received: from localhost.localdomain (gen92-h02-176-184-20-254.dsl.sta.abo.bbox.fr. [176.184.20.254]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-368787cec6bsm8920870f8f.71.2024.07.22.09.07.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 Jul 2024 09:07:54 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell , qemu-arm@nongnu.org, =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 1/7] chardev/char-fe: Document returned value on error Date: Mon, 22 Jul 2024 18:07:39 +0200 Message-ID: <20240722160745.67904-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240722160745.67904-1-philmd@linaro.org> References: <20240722160745.67904-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=philmd@linaro.org; helo=mail-wr1-x42c.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=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 qemu_chr_fe_add_watch() and qemu_chr_fe_write[_all]() return -1 on error. Mention it in the documentation. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Mark Cave-Ayland Reviewed-by: Pierrick Bouvier --- include/chardev/char-fe.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/chardev/char-fe.h b/include/chardev/char-fe.h index ecef182835..3310449eaf 100644 --- a/include/chardev/char-fe.h +++ b/include/chardev/char-fe.h @@ -228,6 +228,7 @@ guint qemu_chr_fe_add_watch(CharBackend *be, GIOCondition cond, * is thread-safe. * * Returns: the number of bytes consumed (0 if no associated Chardev) + * or -1 on error. */ int qemu_chr_fe_write(CharBackend *be, const uint8_t *buf, int len); @@ -242,6 +243,7 @@ int qemu_chr_fe_write(CharBackend *be, const uint8_t *buf, int len); * attempted to be written. This function is thread-safe. * * Returns: the number of bytes consumed (0 if no associated Chardev) + * or -1 on error. */ int qemu_chr_fe_write_all(CharBackend *be, const uint8_t *buf, int len); @@ -253,6 +255,7 @@ int qemu_chr_fe_write_all(CharBackend *be, const uint8_t *buf, int len); * Read data to a buffer from the back end. * * Returns: the number of bytes read (0 if no associated Chardev) + * or -1 on error. */ int qemu_chr_fe_read_all(CharBackend *be, uint8_t *buf, int len); From patchwork Mon Jul 22 16:07:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813729 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp1941191wro; Mon, 22 Jul 2024 09:09:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUf+RMiFn7VDgn4wMTMmG8RtnhmU+qjcrhGF1JWO6OpsnST0qUGiQ8j4qIHNq+zsH5hhq5dt2FthXgqG/+OlGi+ X-Google-Smtp-Source: AGHT+IEv5gfeqPquhkIpiWhQKkMUCj/64jBs++phs3hxJlUUxcDXhLvb2YyoRO3ite4KQ0lNHgJN X-Received: by 2002:a05:6808:bc1:b0:3da:a0e5:5afe with SMTP id 5614622812f47-3dae62c4be4mr11020956b6e.13.1721664542669; Mon, 22 Jul 2024 09:09:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721664542; cv=none; d=google.com; s=arc-20160816; b=NvpC8NtGBqLCXESIesXnDMToZBZH6sKyJT0AbwOtrpJcu8cMqd8cliZrnm/rNFM0sA nuAtc9d39Qg88ooqhDTf7qDYklnbakPizheCV/bStPvp1V2mAHldvzxlnlMEAnisCu4K INQAfFX8T+rsUTAj0nHAD7ueZdbKpirMDUT8+QuvLNF9YXWXEC/auUIxKIKcMKKDsbNV /R64JyHvsZje0yxM1mABGacUQ/uUM+G8dEkbjVBjU4fGGQlHBPOz9i4AHeKkN/W00aXX tOWVnbu10rTXTJqEGuIgcvDWUx9p1w3REccm7SLY4ccJzaUpk01nKgrK+Lo5B2pquG2O FfMw== 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=7xJItyCJvAqsvrHU7PZNhwclTP7/Jt4LLoVoT2duvA4=; fh=pA26/TpFHAj3dhwie1wJOLhR+LuI9XikNoV1W9RAiFw=; b=n46z3UxKuLLLIR0bwuLSOC9g3L5cxM+QTozXDlH5qwqGxtZssOtM8lRHOaK8gETCK6 hdtPdM0tWgMFs6lJE9nuHnrBUePD4NoKnYkyGg8yGNV8TGiNSEoStdtS9aEUSauWQz6v 6BRsg3z6ntMhjGBR74v9V33TGiXOIMf10riUUFit9GI9xTFXTtXlp7jJH175Det92AWo p3YQvw048b596BcbFjSnTGDkYtqgcAhCVyq/FZPb5llJ0e8Kfi31ZzKKajQ4Z8fDsLP4 2ASBGr1Ri91VqqxnsoF4X7DwKc+P6rWSBjqbvPkE4zZpWWahk4hvLSs3EM/uGWLgfkJO M1nQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FVn1Wsq3; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a1e0cc1a2514c-826dbf988bcsi1038401241.38.2024.07.22.09.09.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2024 09:09:02 -0700 (PDT) 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=FVn1Wsq3; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVva4-0005ym-W7; Mon, 22 Jul 2024 12:08:09 -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 1sVva2-0005sO-62 for qemu-devel@nongnu.org; Mon, 22 Jul 2024 12:08:06 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sVvZz-0007hE-Ej for qemu-devel@nongnu.org; Mon, 22 Jul 2024 12:08:05 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4266edee10cso29846205e9.2 for ; Mon, 22 Jul 2024 09:08:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721664480; x=1722269280; 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=7xJItyCJvAqsvrHU7PZNhwclTP7/Jt4LLoVoT2duvA4=; b=FVn1Wsq3Md3trySmqkfE6FomzYGZFvBMtvOHBrKyfhNr/9Ec6mhBiVQn529Bq8Ufv1 /TxSEnbyITh1B0ivq8mKT26o6wHA9I1Dhrkxv1zfWjX80+bP+hhoUSB9q3COq++BBj0x bzQ+YaxYpzwa9dHlVSgtCk94dPVjxYDf/8lJz+r5tizHlFTKw8UWdzlWVeos2rjfOmWA vz2ziZhmmIFZ+2ID9aQc6TD/JG5zxhp0JJiy2xHrcJ1m8OAFGm/Wq/kI4sjI65w7iMHs RtsM3WZKBd7VfxqaekDPnUKMF/wdLmhOOiepWpbHSPXw2ibtxyl1VSCeyDVX50pSyDhV QQLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721664480; x=1722269280; 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=7xJItyCJvAqsvrHU7PZNhwclTP7/Jt4LLoVoT2duvA4=; b=tXSCm2CwhE/UdRmeA7RJdUqkMpv3cCrS4/rVsC8mUl9t1wn/I49FVfKzEf7Qaee1JD j3oH+6mUKqvpMAf45bni/KDnrcAo9B06rM+6d7bliAbKBqfZw1IjTvauWKJnC8mQ/i9h Z6ANP+tWXk4IIC+Ukccw63rMo/W0c8KZ7l//hAUq04BbCw0DCnTgVzfvB1x9R364/CEr 9NbR94GHeVMzvJPs2m8L/yJSS9r5reN3Oy9o7Vpke8FOfVuIpbzGGjCpjQjT3bW9ANkV Du808ALcjFXx2njkhkKiUtcdWnfS477O5M2Gl6M4FfTnArHJpXMDlS2B9GrymoL5lvhH 1IUA== X-Gm-Message-State: AOJu0YyDO4SeKXLLrzZGubgV+TCRbbm63Nszv5+9PXIm9Atg5O150y9W QxHkbPQKUDwpORlQvJ1oat3nfnVthJDCwS6JzWLOh+1PY9XfItKVM+RGHl7IRyRPxwp8XCZafOX Y X-Received: by 2002:a05:600c:3c9d:b0:426:6099:6eaa with SMTP id 5b1f17b1804b1-427daa61cddmr54009415e9.26.1721664480241; Mon, 22 Jul 2024 09:08:00 -0700 (PDT) Received: from localhost.localdomain (gen92-h02-176-184-20-254.dsl.sta.abo.bbox.fr. [176.184.20.254]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d68fa394sm132786425e9.3.2024.07.22.09.07.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 Jul 2024 09:07:59 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell , qemu-arm@nongnu.org, =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 2/7] util/fifo8: Fix style Date: Mon, 22 Jul 2024 18:07:40 +0200 Message-ID: <20240722160745.67904-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240722160745.67904-1-philmd@linaro.org> References: <20240722160745.67904-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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=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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Pierrick Bouvier Reviewed-by: Mark Cave-Ayland --- include/qemu/fifo8.h | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h index c6295c6ff0..2692d6bfda 100644 --- a/include/qemu/fifo8.h +++ b/include/qemu/fifo8.h @@ -15,10 +15,9 @@ typedef struct { * @fifo: struct Fifo8 to initialise with new FIFO * @capacity: capacity of the newly created FIFO * - * Create a FIFO of the specified size. Clients should call fifo8_destroy() + * Create a FIFO of the specified capacity. Clients should call fifo8_destroy() * when finished using the fifo. The FIFO is initially empty. */ - void fifo8_create(Fifo8 *fifo, uint32_t capacity); /** @@ -26,9 +25,8 @@ void fifo8_create(Fifo8 *fifo, uint32_t capacity); * @fifo: FIFO to cleanup * * Cleanup a FIFO created with fifo8_create(). Frees memory created for FIFO - *storage. The FIFO is no longer usable after this has been called. + * storage. The FIFO is no longer usable after this has been called. */ - void fifo8_destroy(Fifo8 *fifo); /** @@ -39,7 +37,6 @@ void fifo8_destroy(Fifo8 *fifo); * Push a data byte to the FIFO. Behaviour is undefined if the FIFO is full. * Clients are responsible for checking for fullness using fifo8_is_full(). */ - void fifo8_push(Fifo8 *fifo, uint8_t data); /** @@ -52,7 +49,6 @@ void fifo8_push(Fifo8 *fifo, uint8_t data); * Clients are responsible for checking the space left in the FIFO using * fifo8_num_free(). */ - void fifo8_push_all(Fifo8 *fifo, const uint8_t *data, uint32_t num); /** @@ -64,7 +60,6 @@ void fifo8_push_all(Fifo8 *fifo, const uint8_t *data, uint32_t num); * * Returns: The popped data byte. */ - uint8_t fifo8_pop(Fifo8 *fifo); /** @@ -73,7 +68,7 @@ uint8_t fifo8_pop(Fifo8 *fifo); * @max: maximum number of bytes to pop * @numptr: pointer filled with number of bytes returned (can be NULL) * - * Pop a number of elements from the FIFO up to a maximum of max. The buffer + * Pop a number of elements from the FIFO up to a maximum of @max. The buffer * containing the popped data is returned. This buffer points directly into * the FIFO backing store and data is invalidated once any of the fifo8_* APIs * are called on the FIFO. @@ -82,7 +77,7 @@ uint8_t fifo8_pop(Fifo8 *fifo); * around in the ring buffer; in this case only a contiguous part of the data * is returned. * - * The number of valid bytes returned is populated in *numptr; will always + * The number of valid bytes returned is populated in *@numptr; will always * return at least 1 byte. max must not be 0 or greater than the number of * bytes in the FIFO. * @@ -99,7 +94,7 @@ const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr); * @max: maximum number of bytes to peek * @numptr: pointer filled with number of bytes returned (can be NULL) * - * Peek into a number of elements from the FIFO up to a maximum of max. + * Peek into a number of elements from the FIFO up to a maximum of @max. * The buffer containing the data peeked into is returned. This buffer points * directly into the FIFO backing store. Since data is invalidated once any * of the fifo8_* APIs are called on the FIFO, it is the caller responsibility @@ -109,7 +104,7 @@ const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr); * around in the ring buffer; in this case only a contiguous part of the data * is returned. * - * The number of valid bytes returned is populated in *numptr; will always + * The number of valid bytes returned is populated in *@numptr; will always * return at least 1 byte. max must not be 0 or greater than the number of * bytes in the FIFO. * @@ -126,7 +121,6 @@ const uint8_t *fifo8_peek_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr); * * Reset a FIFO. All data is discarded and the FIFO is emptied. */ - void fifo8_reset(Fifo8 *fifo); /** @@ -137,7 +131,6 @@ void fifo8_reset(Fifo8 *fifo); * * Returns: True if the fifo is empty, false otherwise. */ - bool fifo8_is_empty(Fifo8 *fifo); /** @@ -148,7 +141,6 @@ bool fifo8_is_empty(Fifo8 *fifo); * * Returns: True if the fifo is full, false otherwise. */ - bool fifo8_is_full(Fifo8 *fifo); /** @@ -159,7 +151,6 @@ bool fifo8_is_full(Fifo8 *fifo); * * Returns: Number of free bytes. */ - uint32_t fifo8_num_free(Fifo8 *fifo); /** @@ -170,7 +161,6 @@ uint32_t fifo8_num_free(Fifo8 *fifo); * * Returns: Number of used bytes. */ - uint32_t fifo8_num_used(Fifo8 *fifo); extern const VMStateDescription vmstate_fifo8; From patchwork Mon Jul 22 16:07:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813730 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp1941200wro; Mon, 22 Jul 2024 09:09:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWlI6+7tFxfFNbo28K/lmAAxjJOy5x3+IAKT6sNspmIq8MXsbqO+TStz0sPiFX7YfT9R194t2+NiTqKsjwe36wU X-Google-Smtp-Source: AGHT+IFcP8rnO/gFlP5z9nMbtwPLNDi1KmgT6VeMaYjbHYNFurHl45thv0xBiOsNJTvvPBkngVM+ X-Received: by 2002:a05:6122:4104:b0:4ed:26:790a with SMTP id 71dfb90a1353d-4f50667e598mr8187265e0c.4.1721664543744; Mon, 22 Jul 2024 09:09:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721664543; cv=none; d=google.com; s=arc-20160816; b=eem1LsKugLLOma9Ocwse6XFIraslERlXlwp517IyjIGA/mrDE/DFCy4PlYuenXSc82 fF98yByIVRnuTJRezeHKdvs0dSP0VEjq+QJWu4BC9DeIgfCPmjFKoG8bfAaX8Etdg9Kc Se9JTHqhzUsN8nFzOahtET6BhNpVTHGa2dgYMBxRMAw4lnvg6D3DHwVARpkcC3VJc09B E3oWP//mAIhSfMKFvGCxHYLyNZKfR/1L3YVvSWXm9thtk6KcTwG1SkB+L4EFml/6ggLy 6r1ayMf0PReKI/tFvjICVe9SbztqNHzEV0TMsMf6bSWB12hzWac4jOqC5gELoxXv9gEO qH4A== 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=dS9AnThSzSBrSy+tonVpTP7pqJETnOM97XqDCYC+F+8=; fh=pA26/TpFHAj3dhwie1wJOLhR+LuI9XikNoV1W9RAiFw=; b=b7Sy5Pm5hIm0/1C4lUIOlcfhaXTsE+AcXFadYdkeKC7oF6B6el4OVICXu6SMj/fdi6 Mp1mk3D1BSHQ8sNC36PAQwWVNUD7SIh6QdzkTJsiM7f+21Zt3QbZHf5xptyjQRv9lFzn wB5oHL22C9LwmvijFJL+jucQLTzqbSbpGmNoAyWrDHo6A6I6npnmVa6VBbLjmbKhFEsI byxOJOUzAwwnrBuAMP3WoGbIQJu42ETuPZTydWnuLXvQLq4BrUNDlvIchn48MBNrvk/k h7sJukmf5YUB+l80rxG/7Zm91LdPr8zRl3MF4+xxN+up6o7O1tHTNqXzexNz13oY9dn6 6xoA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d+aJKlWV; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 71dfb90a1353d-4f5171562c6si613134e0c.204.2024.07.22.09.09.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2024 09:09:03 -0700 (PDT) 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=d+aJKlWV; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVvaH-0006cX-AB; Mon, 22 Jul 2024 12:08:21 -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 1sVvaE-0006RF-ED for qemu-devel@nongnu.org; Mon, 22 Jul 2024 12:08:18 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sVva4-0007iF-RD for qemu-devel@nongnu.org; Mon, 22 Jul 2024 12:08:16 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-42797bcfc77so33679895e9.2 for ; Mon, 22 Jul 2024 09:08:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721664486; x=1722269286; 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=dS9AnThSzSBrSy+tonVpTP7pqJETnOM97XqDCYC+F+8=; b=d+aJKlWVVfxjDQ5KwyJPd2PqXzzi9o68EsqdlYlFnYcC/vR9M6V11ZWj0XEBODaWYB Wyy3dZW2C4k2Dc9grwxBQqIlu2w4glu5oBn1YwwyuLxM+e6zQQ9UmEbUFq8XakAwXQd6 LWWG018vaeFuuWJk/deOfkv/rz4eJp+ddJu99yG4PT386bq9W9hYSzfSK1aDIhlXMF06 dLyLgIjk8IZqA6/Nsq6/wtlP/kYF3AVz337DpARbXhxih4lItk+DGEqNCt9r3ourLFSr gmM4YfZ3yHIKlJWsTt+k72Zqu+2LIm3VXbfGK5bOyuRQHGlrj8msbPmChAkTB6cBeEFK +byA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721664486; x=1722269286; 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=dS9AnThSzSBrSy+tonVpTP7pqJETnOM97XqDCYC+F+8=; b=VztEMmNgUpI0hJqBhorOt9jZhSi8TnhFncTfDdCpW8L2TGdhreP7gY1N6e1XaiR3e0 I+Zaxx0uGnbbILZ43oh9md3Ld9W+PNuf6WIaPkiaXDkqwUKqnrp0deudF6BAVwHVvzoc kOj0sFRWLzLQlU29XbZ0fwhPRfwPps2KJc9rPEApfc4YF3xiVL9D+ODLj9WxKlVEU7jD s++kCd5YN2hcNd4oQWiWRbv3S6DSiuWlf18HWwfdJSvlvTYUDlhfUpxNlCaLEuHtl4Zw YgP2P/LyTUCF69pM282h6qYKUYGqQtzrCsESSGECdCkCHwD4BG6dnh58i0/+1qUTRrk3 QkMA== X-Gm-Message-State: AOJu0YzEfNG2c8r8rkXBAllwR1kR7l3YDJgNfA3rgJ867buIBxUChtWW pUK2TI+MHYn0IDdsFsKzsyVfHSKTLol+QLTKFb9MFDcMz4WOdUCrYED4Hg81CHE0GaEOxz8PLlq T X-Received: by 2002:a05:600c:45d3:b0:425:649b:60e8 with SMTP id 5b1f17b1804b1-427df7b6d07mr45973825e9.18.1721664485987; Mon, 22 Jul 2024 09:08:05 -0700 (PDT) Received: from localhost.localdomain (gen92-h02-176-184-20-254.dsl.sta.abo.bbox.fr. [176.184.20.254]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e2a1sm159685935e9.31.2024.07.22.09.08.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 Jul 2024 09:08:05 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell , qemu-arm@nongnu.org, =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 3/7] util/fifo8: Use fifo8_reset() in fifo8_create() Date: Mon, 22 Jul 2024 18:07:41 +0200 Message-ID: <20240722160745.67904-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240722160745.67904-1-philmd@linaro.org> References: <20240722160745.67904-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Avoid open-coding fifo8_reset() in fifo8_create(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Mark Cave-Ayland Reviewed-by: Pierrick Bouvier --- util/fifo8.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/util/fifo8.c b/util/fifo8.c index 4e01b532d9..2925fe5611 100644 --- a/util/fifo8.c +++ b/util/fifo8.c @@ -16,12 +16,17 @@ #include "migration/vmstate.h" #include "qemu/fifo8.h" +void fifo8_reset(Fifo8 *fifo) +{ + fifo->num = 0; + fifo->head = 0; +} + void fifo8_create(Fifo8 *fifo, uint32_t capacity) { fifo->data = g_new(uint8_t, capacity); fifo->capacity = capacity; - fifo->head = 0; - fifo->num = 0; + fifo8_reset(fifo); } void fifo8_destroy(Fifo8 *fifo) @@ -97,12 +102,6 @@ const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr) return fifo8_peekpop_buf(fifo, max, numptr, true); } -void fifo8_reset(Fifo8 *fifo) -{ - fifo->num = 0; - fifo->head = 0; -} - bool fifo8_is_empty(Fifo8 *fifo) { return (fifo->num == 0); From patchwork Mon Jul 22 16:07:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813731 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp1941304wro; Mon, 22 Jul 2024 09:09:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXuTReTxuHMtjLkZoSHeSBlGvkofjcHqbXrU8IWwPLlu1Y1yydn21/WjrRJtCRf3iRHs/T5Ojs6EmoKkgKL3pMU X-Google-Smtp-Source: AGHT+IHAyCMiNs9GBA/yB1S1rPQ4kmYLK8zE43ix/lZMCXUuk3onV7Zsvus1kEf7NSb8z6mbw5lx X-Received: by 2002:a05:620a:4092:b0:79c:130:452b with SMTP id af79cd13be357-7a1a65f01d9mr1020288985a.47.1721664557071; Mon, 22 Jul 2024 09:09:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721664557; cv=none; d=google.com; s=arc-20160816; b=U+jnmf9kLAGaxxJthg6Odmlm41Tb550bnn/OvSoVd50XxircCrwVHzY7/rNtgki6mU oun1EG1M7umFppDRvdgIlox9govPBS++9ySzKTfvxt/MIipauye/OORqWkgrKYLYm7t8 dPnSgEEjaPrezVdxr/agcHlAZlvp2DTp8bv+xZWxf97ONrkJkpIqIpWjgsn40m/m/KQg 1X7X45GtU1iEICAtbha5Lrv69HMZSxBdU340vZh06P0My0omMkxPQaoYSiPR70lowtQM xHEZeRbuxBAN33syXOSohSBzh/M+BiDsDAkPIEn33vjI0qEk5MYKBRFaIclSO1ukldoo pYmA== 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=g5IVJQKs0mRewT92ekkS2OE3V+7eufImd7ZnhLfAtiw=; fh=pA26/TpFHAj3dhwie1wJOLhR+LuI9XikNoV1W9RAiFw=; b=gIjRgIwwls7pmbT+LZYFMpCToC/3UFexlcOeQYs/ubhZtnL5EKig15CBQBlOwQP0Qj 5ukIIk0w7febWxD8VnCwoRAWZNOoYfvgeIgcwM1mB4WIi76q+DArN3mB13DPwBrrQO2n WWyw1kkZSDsBK3jVpU9kGGcyaLEMNm9VteSRUTJY7MUOS6daMsa8hONdlStQpYAyn55a 5GS3riaA4DluTfutHeGMol0HMkZAOQOIWgPvEofLprpxN1OhhfpRNWkLXEMzkCzsBvPk K53qi+Q4M/zJL1LLjDvsannw0uRIPMvS9rdg4e2mxmwSXsMFLP/uJXreJTkHxuCL23Sw ZtjA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QTXgPtLC; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44f9ccf8fe8si79613911cf.151.2024.07.22.09.09.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2024 09:09:17 -0700 (PDT) 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=QTXgPtLC; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVvaU-0007UU-4r; Mon, 22 Jul 2024 12:08:35 -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 1sVvaP-0007F6-Tv for qemu-devel@nongnu.org; Mon, 22 Jul 2024 12:08:30 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sVvaL-0007nl-Hy for qemu-devel@nongnu.org; Mon, 22 Jul 2024 12:08:29 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4266fcb311cso33735985e9.1 for ; Mon, 22 Jul 2024 09:08:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721664502; x=1722269302; 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=g5IVJQKs0mRewT92ekkS2OE3V+7eufImd7ZnhLfAtiw=; b=QTXgPtLCanqqaoj8ztYfRyGNp7OdOHfMN/jCgmGlh8F5WfxrzZHMdxhcyqRj9/qGRC PV4P0mxJV6denC5cTxQxOmEGyfYfTs59+D5eYtZVIgGzBvd9ebC++m5E8Im8/CLeM7Uz Khc1zZpKpAgXW66naP07dKbcywx2tW8f4VR0YAaKxuXBSQSZC0kCeAMgZ1pK4S1q/O95 wn5yH8xxoKbjg30FSRVZUcylZIxwgYLzLw+IGLS4WnUOZZDm7eoLdXU4NDLbSupV9mHf oz7Q36Bx8lwOJjmxOYa15PrGJzasUkbZQG0v5IjW6INr7+RCg96XxC38BQSJ7VWpNmE9 yD/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721664502; x=1722269302; 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=g5IVJQKs0mRewT92ekkS2OE3V+7eufImd7ZnhLfAtiw=; b=cuTkbo/TfEtYrxoLgdMkHxJsNg7m+b3go3SvGJxJ8lWXV/5hdI5e/MtVyvkiuczSS/ S6uCPXp4lUKCwx9est7u6PaeOVTrK+RmnYzVYPcoeJmoo/3xIXpmzX3BOXleMg7noBzA 7+n9jNybsG9ecPloiDZc1cx0DnsevtZX1yL72AdhVXQsRhE9Fifkuaz6R1R5kpThSs7t X5T3GmxcTnfwYtPAIXzOxETUD0jBMVDokbZ/oyYt+wpnAFUYUiRR8sBMyx0PFEPeOw2t oRIYWpCiqv516XIlO5y2QNEBAy6Hgjgj8vpOvjIjOVLRG+2j48kBVV72osKa7fQMRpkZ Uz7Q== X-Gm-Message-State: AOJu0YyK1nmjKEl8MBJ3D9FDaoAzY4NhSX+CvNoeEKq60Z2SaLbYVeKO wXZyGbPmpo4xljW7V8mrpxkSPK6ziCbHxJ24ugk36TlZBY0HGLdYfGWedibIndXXLc+D8m/NiR9 8 X-Received: by 2002:a05:600c:1c9e:b0:423:791:f446 with SMTP id 5b1f17b1804b1-427dc51a01emr45867695e9.7.1721664491827; Mon, 22 Jul 2024 09:08:11 -0700 (PDT) Received: from localhost.localdomain (gen92-h02-176-184-20-254.dsl.sta.abo.bbox.fr. [176.184.20.254]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a7257esm158849065e9.28.2024.07.22.09.08.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 Jul 2024 09:08:11 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell , qemu-arm@nongnu.org, =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 4/7] util/fifo8: Rename fifo8_peek_buf() -> fifo8_peek_constbuf() Date: Mon, 22 Jul 2024 18:07:42 +0200 Message-ID: <20240722160745.67904-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240722160745.67904-1-philmd@linaro.org> References: <20240722160745.67904-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Since fifo8_peek_buf() return a const buffer (which points directly into the FIFO backing store), rename it using the 'constbuf' suffix. This will help differentiate with methods *copying* the FIFO data. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Pierrick Bouvier Reviewed-by: Mark Cave-Ayland --- include/qemu/fifo8.h | 4 ++-- hw/scsi/esp.c | 2 +- util/fifo8.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h index 2692d6bfda..79450f4583 100644 --- a/include/qemu/fifo8.h +++ b/include/qemu/fifo8.h @@ -89,7 +89,7 @@ uint8_t fifo8_pop(Fifo8 *fifo); const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr); /** - * fifo8_peek_buf: read upto max bytes from the fifo + * fifo8_peek_constbuf: read upto max bytes from the fifo * @fifo: FIFO to read from * @max: maximum number of bytes to peek * @numptr: pointer filled with number of bytes returned (can be NULL) @@ -113,7 +113,7 @@ const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr); * * Returns: A pointer to peekable data. */ -const uint8_t *fifo8_peek_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr); +const uint8_t *fifo8_peek_constbuf(Fifo8 *fifo, uint32_t max, uint32_t *numptr); /** * fifo8_reset: diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 8504dd30a0..526ed91bef 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -486,7 +486,7 @@ static bool esp_cdb_ready(ESPState *s) return false; } - pbuf = fifo8_peek_buf(&s->cmdfifo, len, &n); + pbuf = fifo8_peek_constbuf(&s->cmdfifo, len, &n); if (n < len) { /* * In normal use the cmdfifo should never wrap, but include this check diff --git a/util/fifo8.c b/util/fifo8.c index 2925fe5611..21943c6032 100644 --- a/util/fifo8.c +++ b/util/fifo8.c @@ -92,7 +92,7 @@ static const uint8_t *fifo8_peekpop_buf(Fifo8 *fifo, uint32_t max, return ret; } -const uint8_t *fifo8_peek_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr) +const uint8_t *fifo8_peek_constbuf(Fifo8 *fifo, uint32_t max, uint32_t *numptr) { return fifo8_peekpop_buf(fifo, max, numptr, false); } From patchwork Mon Jul 22 16:07:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813735 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp1942300wro; Mon, 22 Jul 2024 09:11:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXNvfh37MLy504sPKdJgHJG4+pEmZjomvfbyD6tlganOXfnSDaQy7Br1uA2Knl4RmsnZwBnrelSgZQ18EbLcACr X-Google-Smtp-Source: AGHT+IEQWSNFZNEqWWINuUnNgxxUbd5u+uI47pKfm9F61jwh3ij/u3GJnG91pwc6vh+8Z4KpyiGW X-Received: by 2002:a05:6214:224b:b0:6b5:eba0:d0ab with SMTP id 6a1803df08f44-6b95a5de433mr93050866d6.15.1721664673402; Mon, 22 Jul 2024 09:11:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721664673; cv=none; d=google.com; s=arc-20160816; b=Rvi5bVnD2cvMmvP/UzKmgDynpEH30VQX8RDiMQJAXgcFhzdNK8XZi1rhxCni0LwUe6 ooGiojIt3CWRexj9tGU+9bfUE6eY5hgllqdbyf9uvHjI3F4Fh/NBamPU1FwO0WucJRIp T18Cq4dbdFlKcG+AwxP2L9Xk+m6Ht472QJ9tGA54zX49sN4VmRtY2JzQocgof1dM4Mqs Q7Lhwb+MLPymyn4Y/Ik3R88Bf3wsTDwgWGno40SvlZhA1DR3Z7o0c8NRCjd7OU4eG79C cRePHBKXDSJ1UcpqZJMzHG7KBDTM60NIWaueIwmV5sfMIDZ4Qb96UfSBJsVwEGNb/iib Pnow== 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=D13SsLbTdb+rPn3f2Roi8BU4ul1b5GgWpSQvaH/PkW0=; fh=pA26/TpFHAj3dhwie1wJOLhR+LuI9XikNoV1W9RAiFw=; b=T+cNl/ipK5Kr6A4VWeXEJJpQ6Q7odSjQwSTwYG2e+OIbTfN0Z7p1NQA43s6x6SSoOK CJbh6uf+/0Um6Y3jDy4xmRFkvFlRkHx+GoFJ8P/RUfWlzvqjwyILsaHvrxdcsyArTvSY QH/eX8Or8DnZdFf5eTVBzBvrWoFeqdP+ZP+13h4vR5ZAE/7dZiz3RyghbRLOfD67VUj8 td+Yhh1aYpalg1xgHlkX0T2wuJeCmVED3WsivK9uUSDLAev4e5iu+J7fAXEASZYWQyY4 S6KOeSU3/tFz/evUBRUMqb3nD6at0FtQ6k3weYuM2CmgATCDFGv+j9yw1v8YTx4ARCY0 8g8Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HTc7vL43; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b7ac79f082si85293666d6.44.2024.07.22.09.11.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2024 09:11:13 -0700 (PDT) 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=HTc7vL43; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVvaX-0007xL-NN; Mon, 22 Jul 2024 12:08:37 -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 1sVvaV-0007ly-P0 for qemu-devel@nongnu.org; Mon, 22 Jul 2024 12:08:35 -0400 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 1sVvaR-0007oY-NQ for qemu-devel@nongnu.org; Mon, 22 Jul 2024 12:08:35 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4279c924ca7so32747795e9.2 for ; Mon, 22 Jul 2024 09:08:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721664508; x=1722269308; 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=D13SsLbTdb+rPn3f2Roi8BU4ul1b5GgWpSQvaH/PkW0=; b=HTc7vL43soHt7J6N36/gUO0tC/QXqOJoRM/m2NjFiZwn0Ji5lF3DYub8vZ3RCM0ozp H0M7ASpBR5eNIWXKy+WDre3635XoGouBHqiE0rJc8DitqFXKyaYzvSIcdTTKOfsAme0H jH3bXTae42i61HHa+4kJFayaJBgU7DMU/Tud7M7J+I8aDuurmnpcq6bma0NQFjmgrJwv g31NKensoH7tS59Ec/QTC0aXySN22Wh4mflcDPwa4JZMs42N7YOAeJGSSzALtss6KTjE DNz6+f+Gnwm8xuCFYRaIAOvPEhyZCvd4wfH8Cd5i25PcBBVZYByZPsLG3/dEfXwqs51s EHxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721664508; x=1722269308; 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=D13SsLbTdb+rPn3f2Roi8BU4ul1b5GgWpSQvaH/PkW0=; b=eqGEyGmuQJAkq+FgUvhhkzksHTSF+YD44L8UHpxMuxe4yFcuPwTiPmHUxp0gd0ctC/ hbxMdZYBQEFe2SfXjyTk0Ps/wNbL1f9egIj4SmeV+6qrMf4cSOCZbMK80q3TDYTxUfZN EpjVCKCmNkdhOMJsWzkrbsZx+0CsP8Msssaj+X1LnuKJpNjPAk8L0lzejmzz6wtUU5rW 59Ib1ngx6I7JDQ9PFRh58QkA8Pj9K2CIu7Yk2SXia0NT/JYoAqb/5WlpF0bOp8Ec94IP aY7synxlj+v7FlG50ZVEdztf0mMmP+VtvTDjx1XJuF+lGkw3OULoYRyFirFo0XrOv5lS WoGw== X-Gm-Message-State: AOJu0YxiTOdfelTRJT+bGZmVO3yQnPD9dkCCiT5G/PJCxN26OyG0oeGb gm6B1O6w8zluiBJPLOMzgQ2WkRwA5LchYoqGaXRrg4+zOxZfnv7OrY00FbywfbbXkYQiN4caN94 S X-Received: by 2002:a05:600c:1d8f:b0:426:51dc:f6cd with SMTP id 5b1f17b1804b1-427dc529057mr55262845e9.18.1721664508179; Mon, 22 Jul 2024 09:08:28 -0700 (PDT) Received: from localhost.localdomain (gen92-h02-176-184-20-254.dsl.sta.abo.bbox.fr. [176.184.20.254]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-368787ced33sm8964748f8f.86.2024.07.22.09.08.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 Jul 2024 09:08:27 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell , qemu-arm@nongnu.org, =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 5/7] util/fifo8: Rename fifo8_pop_buf() -> fifo8_pop_constbuf() Date: Mon, 22 Jul 2024 18:07:43 +0200 Message-ID: <20240722160745.67904-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240722160745.67904-1-philmd@linaro.org> References: <20240722160745.67904-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Since fifo8_pop_buf() return a const buffer (which points directly into the FIFO backing store), rename it using the 'constbuf' suffix. This will help differentiate with methods *copying* the FIFO data. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Pierrick Bouvier Reviewed-by: Mark Cave-Ayland --- include/qemu/fifo8.h | 4 ++-- chardev/msmouse.c | 2 +- hw/char/goldfish_tty.c | 4 ++-- hw/net/allwinner_emac.c | 2 +- hw/scsi/esp.c | 4 ++-- ui/console-vc.c | 2 +- ui/gtk.c | 2 +- util/fifo8.c | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h index 79450f4583..686918a3a4 100644 --- a/include/qemu/fifo8.h +++ b/include/qemu/fifo8.h @@ -63,7 +63,7 @@ void fifo8_push_all(Fifo8 *fifo, const uint8_t *data, uint32_t num); uint8_t fifo8_pop(Fifo8 *fifo); /** - * fifo8_pop_buf: + * fifo8_pop_constbuf: * @fifo: FIFO to pop from * @max: maximum number of bytes to pop * @numptr: pointer filled with number of bytes returned (can be NULL) @@ -86,7 +86,7 @@ uint8_t fifo8_pop(Fifo8 *fifo); * * Returns: A pointer to popped data. */ -const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr); +const uint8_t *fifo8_pop_constbuf(Fifo8 *fifo, uint32_t max, uint32_t *numptr); /** * fifo8_peek_constbuf: read upto max bytes from the fifo diff --git a/chardev/msmouse.c b/chardev/msmouse.c index a774c397b4..08836d92e8 100644 --- a/chardev/msmouse.c +++ b/chardev/msmouse.c @@ -81,7 +81,7 @@ static void msmouse_chr_accept_input(Chardev *chr) const uint8_t *buf; uint32_t size; - buf = fifo8_pop_buf(&mouse->outbuf, MIN(len, avail), &size); + buf = fifo8_pop_constbuf(&mouse->outbuf, MIN(len, avail), &size); qemu_chr_be_write(chr, buf, size); len = qemu_chr_be_can_write(chr); avail -= size; diff --git a/hw/char/goldfish_tty.c b/hw/char/goldfish_tty.c index f8ff043c39..2c5004851d 100644 --- a/hw/char/goldfish_tty.c +++ b/hw/char/goldfish_tty.c @@ -69,7 +69,7 @@ static uint64_t goldfish_tty_read(void *opaque, hwaddr addr, static void goldfish_tty_cmd(GoldfishTTYState *s, uint32_t cmd) { uint32_t to_copy; - uint8_t *buf; + const uint8_t *buf; uint8_t data_out[GOLFISH_TTY_BUFFER_SIZE]; int len; uint64_t ptr; @@ -109,7 +109,7 @@ static void goldfish_tty_cmd(GoldfishTTYState *s, uint32_t cmd) len = s->data_len; ptr = s->data_ptr; while (len && !fifo8_is_empty(&s->rx_fifo)) { - buf = (uint8_t *)fifo8_pop_buf(&s->rx_fifo, len, &to_copy); + buf = fifo8_pop_constbuf(&s->rx_fifo, len, &to_copy); address_space_rw(&address_space_memory, ptr, MEMTXATTRS_UNSPECIFIED, buf, to_copy, 1); diff --git a/hw/net/allwinner_emac.c b/hw/net/allwinner_emac.c index 989839784a..3b0a2ee07e 100644 --- a/hw/net/allwinner_emac.c +++ b/hw/net/allwinner_emac.c @@ -349,7 +349,7 @@ static void aw_emac_write(void *opaque, hwaddr offset, uint64_t value, "allwinner_emac: TX length > fifo data length\n"); } if (len > 0) { - data = fifo8_pop_buf(fifo, len, &ret); + data = fifo8_pop_constbuf(fifo, len, &ret); qemu_send_packet(nc, data, ret); aw_emac_tx_reset(s, chan); /* Raise TX interrupt */ diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 526ed91bef..64384f9b0e 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -208,7 +208,7 @@ static uint32_t esp_fifo8_pop_buf(Fifo8 *fifo, uint8_t *dest, int maxlen) } len = maxlen; - buf = fifo8_pop_buf(fifo, len, &n); + buf = fifo8_pop_constbuf(fifo, len, &n); if (dest) { memcpy(dest, buf, n); } @@ -217,7 +217,7 @@ static uint32_t esp_fifo8_pop_buf(Fifo8 *fifo, uint8_t *dest, int maxlen) len -= n; len = MIN(len, fifo8_num_used(fifo)); if (len) { - buf = fifo8_pop_buf(fifo, len, &n2); + buf = fifo8_pop_constbuf(fifo, len, &n2); if (dest) { memcpy(&dest[n], buf, n2); } diff --git a/ui/console-vc.c b/ui/console-vc.c index 899fa11c94..e9906aae59 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -287,7 +287,7 @@ static void kbd_send_chars(QemuTextConsole *s) const uint8_t *buf; uint32_t size; - buf = fifo8_pop_buf(&s->out_fifo, MIN(len, avail), &size); + buf = fifo8_pop_constbuf(&s->out_fifo, MIN(len, avail), &size); qemu_chr_be_write(s->chr, buf, size); len = qemu_chr_be_can_write(s->chr); avail -= size; diff --git a/ui/gtk.c b/ui/gtk.c index bc29f7a1b4..a4db90e8cb 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1820,7 +1820,7 @@ static void gd_vc_send_chars(VirtualConsole *vc) const uint8_t *buf; uint32_t size; - buf = fifo8_pop_buf(&vc->vte.out_fifo, MIN(len, avail), &size); + buf = fifo8_pop_constbuf(&vc->vte.out_fifo, MIN(len, avail), &size); qemu_chr_be_write(vc->vte.chr, buf, size); len = qemu_chr_be_can_write(vc->vte.chr); avail -= size; diff --git a/util/fifo8.c b/util/fifo8.c index 21943c6032..31f0d34c0c 100644 --- a/util/fifo8.c +++ b/util/fifo8.c @@ -97,7 +97,7 @@ const uint8_t *fifo8_peek_constbuf(Fifo8 *fifo, uint32_t max, uint32_t *numptr) return fifo8_peekpop_buf(fifo, max, numptr, false); } -const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr) +const uint8_t *fifo8_pop_constbuf(Fifo8 *fifo, uint32_t max, uint32_t *numptr) { return fifo8_peekpop_buf(fifo, max, numptr, true); } From patchwork Mon Jul 22 16:07:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813732 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp1941812wro; Mon, 22 Jul 2024 09:10:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXbglJftSXrnqjizreRb3ZhbuZZyvqaF98wu1N0GI5kzwjKFvUxmKHMG4olc5AYVeVfCPyt5uaBOQCLrWt0FrCW X-Google-Smtp-Source: AGHT+IGMBS8dc789trfwO8qMb2VWak3zWSouobcWz2q51BPPFacz8alwA9WqURZcoDNJAkuEdqbC X-Received: by 2002:a05:6102:faa:b0:492:abbe:8923 with SMTP id ada2fe7eead31-492abbe8d39mr2426385137.6.1721664610990; Mon, 22 Jul 2024 09:10:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721664610; cv=none; d=google.com; s=arc-20160816; b=WizKyuVAdvbTReHapDjV1uA1Y/1NCqfStve0/bUGibQw7Df2/LfuEq6fGSiiCt56TL jbP3YBqCH787awOZQ7hco2DxYNng0tgHiAeWRdms0893Ypze7deUkEFsTnFtdTjVgcbx qnfcEjroaJrzYnjz1FiH0E36jRyg/tmAqmY+61byWGjWiCVEyk/OOkRHJwmmipXNoDKA oaJxaYasOjbz3jXorIXXNfaVLVQGpg7inlhsY0dCtA+Y6IvqvsjmHBOrQkR1Y0jE+Pcd JqBpR3lYYZlJLvO4wzfPHEr4/aqD2mN03AxjCBWJBESuD9HfB7w7b5v1ILpW+yfwLoHZ RDnA== 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=PGm6Mz1jj/9Q+YEDysgdokwei7I83wY7MgFeQkOcKf0=; fh=pA26/TpFHAj3dhwie1wJOLhR+LuI9XikNoV1W9RAiFw=; b=tC75++yf/lrDBqqx0Brd9Kls8U7kGbwf4hascv+50ao6MeEkyqzaLnx1LaWGeoDg97 ZoHDhfcJtGbnAYgrZALokItQd/aw0D6HbwmFwHW/sgske3oEQb4BwU+ra0qhum2/XO+7 YXSTYJcD4lvR0u/G4/bCJ2Th7PnHRyA0P76ohqOKJHaV3Cqo71boPHYxyq08zHdQCY/u ETmcPnOVOxiLFZxeAWyGr9HEnXK0Hh2dkYtXDTgn+FUbi5sOUF5EWvzUSkI2vKZL86D2 BsDj1tS25bJH8jbAmjNQjxmJjwzcDEack3j/p/+3xLv5LPxeIMOgAB+CGS+nTm8bmOtF Vy3A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JdjdY55b; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-4927941b57bsi1510205137.720.2024.07.22.09.10.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2024 09:10:10 -0700 (PDT) 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=JdjdY55b; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVvab-0008JW-Gn; Mon, 22 Jul 2024 12:08:41 -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 1sVvaZ-000886-Hn for qemu-devel@nongnu.org; Mon, 22 Jul 2024 12:08:39 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sVvaW-0007pM-Q4 for qemu-devel@nongnu.org; Mon, 22 Jul 2024 12:08:39 -0400 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3686b554cfcso2099841f8f.1 for ; Mon, 22 Jul 2024 09:08:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721664514; x=1722269314; 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=PGm6Mz1jj/9Q+YEDysgdokwei7I83wY7MgFeQkOcKf0=; b=JdjdY55byPLMPG+fk+Dcqbn+dH3pk0WXmxp0000EIyGSuPGvB7gr7+UK0h058/KEOp 4umhkTUjQQigTuhqIZRjMgRDAcSPLiS0XSgyE38/ap2ERbuWkD+Uj1NoODtbuFMrlWSK +2djAQi+/iAYQmiMRVzWviNEMlMSMLQEpE6siOqYsckKJf4hpCuenCfX9jFOAICkWn2d UPhhT7ViUOcL+roH1/CLy/bWGuG9S79n0HYZE7FKPtJZoPa24KTTpNi0fCes2Yochwrw INwcD8qW9s53Lla4nMeYDgV6pqiDs0UYOx2F81iPuANZw79zpFFm+MI8D13xZCBbYdtA aP1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721664514; x=1722269314; 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=PGm6Mz1jj/9Q+YEDysgdokwei7I83wY7MgFeQkOcKf0=; b=glf2uWNyz3DoMtdhJXUHxofm6oPgkumm/CQQLYL4Zli3EGyikwoh9ULheKcsFArb6A CgZurkhPT2Kl8qv0W8xx+jqAfdGmd7aLSJ11iblilwU8h//Nj1a01pBqFc7leb3FXRfi PHhJ2th1AXMwmHwJiJJteFWRtzza64cyOaOLL9HmgQNTI9qMf/PYCq9XYxDO9RoeWviJ hOMXXOFX8nNQye8MzpTatAvmPJHCaeHmV9uLCYhZkw/8VSqGpeST4Krk0JKG9fwtRAZQ 7WGMoA3aAOyWc9fCUnm3WqkrcQqPt7kuThj8tnMTBvzXUv0r3OJc9JFq0ZTSMvpFf9nD vNzA== X-Gm-Message-State: AOJu0YxULcuewzlFxyoXrrpDDOJ64DA2nzeWC9sEuZqYWsAWeYd2Csyz n0IF6I/00kFpZMxo9XiPCdZDKK0CQY3QQelOAALbmFwVguQzUUHMGpjsEF+4Pqjdlids+JDQ4fO p X-Received: by 2002:a05:6000:4e6:b0:368:5a32:f5bc with SMTP id ffacd0b85a97d-369dee4fa8dmr206590f8f.38.1721664513985; Mon, 22 Jul 2024 09:08:33 -0700 (PDT) Received: from localhost.localdomain (gen92-h02-176-184-20-254.dsl.sta.abo.bbox.fr. [176.184.20.254]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3687868b5fdsm8860554f8f.38.2024.07.22.09.08.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 Jul 2024 09:08:33 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell , qemu-arm@nongnu.org, =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 6/7] util/fifo8: Expose fifo8_pop_buf() Date: Mon, 22 Jul 2024 18:07:44 +0200 Message-ID: <20240722160745.67904-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240722160745.67904-1-philmd@linaro.org> References: <20240722160745.67904-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=philmd@linaro.org; helo=mail-wr1-x432.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Extract fifo8_pop_buf() from hw/scsi/esp.c and expose it as part of the API. This function takes care of non-contiguous (wrapped) FIFO buffer (which is an implementation detail). Suggested-by: Mark Cave-Ayland Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Pierrick Bouvier Reviewed-by: Mark Cave-Ayland --- include/qemu/fifo8.h | 14 ++++++++++++++ hw/scsi/esp.c | 36 +++--------------------------------- util/fifo8.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 33 deletions(-) diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h index 686918a3a4..21c7a22937 100644 --- a/include/qemu/fifo8.h +++ b/include/qemu/fifo8.h @@ -62,6 +62,20 @@ void fifo8_push_all(Fifo8 *fifo, const uint8_t *data, uint32_t num); */ uint8_t fifo8_pop(Fifo8 *fifo); +/** + * fifo8_pop_buf: + * @fifo: FIFO to pop from + * @dest: the buffer to write the data into (can be NULL) + * @destlen: size of @dest and maximum number of bytes to pop + * + * Pop a number of elements from the FIFO up to a maximum of @destlen. + * The popped data is copied into the @dest buffer. + * Care is taken when the data wraps around in the ring buffer. + * + * Returns: number of bytes popped. + */ +uint32_t fifo8_pop_buf(Fifo8 *fifo, uint8_t *dest, uint32_t destlen); + /** * fifo8_pop_constbuf: * @fifo: FIFO to pop from diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 64384f9b0e..cec847b54a 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -197,39 +197,9 @@ static uint8_t esp_fifo_pop(ESPState *s) return val; } -static uint32_t esp_fifo8_pop_buf(Fifo8 *fifo, uint8_t *dest, int maxlen) -{ - const uint8_t *buf; - uint32_t n, n2; - int len; - - if (maxlen == 0) { - return 0; - } - - len = maxlen; - buf = fifo8_pop_constbuf(fifo, len, &n); - if (dest) { - memcpy(dest, buf, n); - } - - /* Add FIFO wraparound if needed */ - len -= n; - len = MIN(len, fifo8_num_used(fifo)); - if (len) { - buf = fifo8_pop_constbuf(fifo, len, &n2); - if (dest) { - memcpy(&dest[n], buf, n2); - } - n += n2; - } - - return n; -} - static uint32_t esp_fifo_pop_buf(ESPState *s, uint8_t *dest, int maxlen) { - uint32_t len = esp_fifo8_pop_buf(&s->fifo, dest, maxlen); + uint32_t len = fifo8_pop_buf(&s->fifo, dest, maxlen); esp_update_drq(s); return len; @@ -335,7 +305,7 @@ static void do_command_phase(ESPState *s) if (!cmdlen || !s->current_dev) { return; } - esp_fifo8_pop_buf(&s->cmdfifo, buf, cmdlen); + fifo8_pop_buf(&s->cmdfifo, buf, cmdlen); current_lun = scsi_device_find(&s->bus, 0, s->current_dev->id, s->lun); if (!current_lun) { @@ -381,7 +351,7 @@ static void do_message_phase(ESPState *s) /* Ignore extended messages for now */ if (s->cmdfifo_cdb_offset) { int len = MIN(s->cmdfifo_cdb_offset, fifo8_num_used(&s->cmdfifo)); - esp_fifo8_pop_buf(&s->cmdfifo, NULL, len); + fifo8_pop_buf(&s->cmdfifo, NULL, len); s->cmdfifo_cdb_offset = 0; } } diff --git a/util/fifo8.c b/util/fifo8.c index 31f0d34c0c..6610b79182 100644 --- a/util/fifo8.c +++ b/util/fifo8.c @@ -102,6 +102,35 @@ const uint8_t *fifo8_pop_constbuf(Fifo8 *fifo, uint32_t max, uint32_t *numptr) return fifo8_peekpop_buf(fifo, max, numptr, true); } +uint32_t fifo8_pop_buf(Fifo8 *fifo, uint8_t *dest, uint32_t destlen) +{ + const uint8_t *buf; + uint32_t n1, n2 = 0; + uint32_t len; + + if (destlen == 0) { + return 0; + } + + len = destlen; + buf = fifo8_pop_constbuf(fifo, len, &n1); + if (dest) { + memcpy(dest, buf, n1); + } + + /* Add FIFO wraparound if needed */ + len -= n1; + len = MIN(len, fifo8_num_used(fifo)); + if (len) { + buf = fifo8_pop_constbuf(fifo, len, &n2); + if (dest) { + memcpy(&dest[n1], buf, n2); + } + } + + return n1 + n2; +} + bool fifo8_is_empty(Fifo8 *fifo) { return (fifo->num == 0); From patchwork Mon Jul 22 16:07:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813733 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp1942126wro; Mon, 22 Jul 2024 09:10:51 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUEWRLpzZYMsqsFKWHeaeZ2gNHQy7vgX3vhtAuo4j+WoWjW0kUZs0AYXZ+zjoknKMrpkrsmCTeiNZDmCWsQCGFV X-Google-Smtp-Source: AGHT+IHBik7Gq0+yivxwPVUQGFkulMyqKyrtvn5MUVAh0BwGLuZwgdJ1SZd5Zp7vw6b7AAXZUQMN X-Received: by 2002:ac8:7dc2:0:b0:446:64c9:df6a with SMTP id d75a77b69052e-44fc559b51dmr2986941cf.55.1721664651550; Mon, 22 Jul 2024 09:10:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721664651; cv=none; d=google.com; s=arc-20160816; b=pTcL8ZRHbeeo0JSDmy8B8PE2YNL5pRdEi5crHggr2E4trFzsD3yNcHk4+QPmt6gCaw 3qIIxXbrDfXOrpZ/s11i8tuKdaPNqbghCDevTBG1KRfFnlsPVhqUnIyhhLyAUC9ZCr/I k7X+F/CDmi0RefzkbYz3Y2XJOv0xJ4eYBX6maaVHajfOq95xwTPsbYRuH7O5rNQMoiqc CiG4xWyc74W55Rqg7bVczNxLmycj53EpQuP8yieN1WqNhJ1MEtM4TG9Z/x/AZm9BrNYk 0M1x0HlmKW3eCxjjHD8G4U7TOx+5gFx5S5L53rrwokfrGOlDg71i7Kicaa8nCf1fMJH7 6tfA== 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=oLrYF0/Wx1i/Oi595G8nLiFu8j75+0aJtBHlGLk36ig=; fh=pA26/TpFHAj3dhwie1wJOLhR+LuI9XikNoV1W9RAiFw=; b=zi4Xrl4JBTbdJac2W2gQ0MSIXZWbJ+xQSRf0Wad1r6QtwydIC29Jiihm6KqmvQsMQi C/AAqGCMtX7OlFDdcYX0FaAYGMxQFWLHGKDMYhUGx2+ADJVra4xgfY4m1JvmAnWFWzHs Yotrz0Vn+xcipVZw93nwHAf5Qv1hao/ZURc8y0Kf79xTAZsxg/OIBSN7WbojKk9kebHS rF6g+McJP97f7OA+luGjGNp+RnRWclTybutK6YDQZCWKyTVkVuZFnS6ToBlTilAMInIm Zpg4VfNASbGXeMbG+Tr4LAOCbeUR3AafG7PfGKEP9Oi7d7vYS/6+GXCSlv5Z9KerjA3q U9BQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K9YNVqLt; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44f9ce04cf8si85118951cf.619.2024.07.22.09.10.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2024 09:10:51 -0700 (PDT) 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=K9YNVqLt; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVvai-0000eR-W6; Mon, 22 Jul 2024 12:08:49 -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 1sVvah-0000YP-8H for qemu-devel@nongnu.org; Mon, 22 Jul 2024 12:08:47 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sVvad-0007qV-LP for qemu-devel@nongnu.org; Mon, 22 Jul 2024 12:08:46 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4266ea6a488so38728365e9.1 for ; Mon, 22 Jul 2024 09:08:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721664520; x=1722269320; 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=oLrYF0/Wx1i/Oi595G8nLiFu8j75+0aJtBHlGLk36ig=; b=K9YNVqLtWWTk+hxjMwf9Eatx1nXW+GfNWMwXRDGVMbXBREsT24Sh3+Rn6vzdaHlOXC YTHN6aYKqXS8b2nlRblCPlgwiCMp9PmyHMpCkarljXx0N4pruHFRpE+scBEx9WmNdK9D pb6pOP/iopkk/1cl3yoswM6JFh1EWRUSS7mT/wJlzbrhzbKmZf10PAAivQp+7XV+zZ4C CoOAi8ISS3AuO+pKEr2Kec/k1Vjx6CBym17pqHOL6jVrBft15dqV6pNtXi62urqSfnAK 9iUoQW+rZEPgZIleJwm0CAf7QVuKmxt0SYKu61urMPEP/YDgg7yuPoUyZ/bEfQF+ieVt GVFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721664520; x=1722269320; 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=oLrYF0/Wx1i/Oi595G8nLiFu8j75+0aJtBHlGLk36ig=; b=cfJbu0wlgoWQIrB6N0ooYnZ2lp9EV0dCfcN0gmkOLIUoG+aRcSfRlhOm0pSSQaTsZv W5VnqYmfBy63yy+iq6xPdy9NVu5L+toS5QDkNqHlmzunEYKRuyrjeMzT3fVOQprN7EbI MLA9YE776VZzNUtc9PX0CBbnChlaiy7KfMELEOYEmWXXZVokM2yfJbt5JDEALfvmg9+h GXh0O4cpAo/PDOHwv8zj+HGzlAZ04qH/mZgVW86SxZ58LR8x/zvtY/FUWHKPwqRNbC8H rr3TLJ/gg/Azsc2UJfl30Piszi16Kv/zrLD+b0KydTxSBt2Em6BJGPYIAWRIRJz6PELU eT4Q== X-Gm-Message-State: AOJu0YwLDPcY5MMeLUPzKtI7/qYVTMkS1ohyCo9onEx4UKt5x/lSeLsJ Lt+kKqKWEkMwqzj/Oo68ZXWrpRvYPapxNLcZJ0Ym5yVFR6G9gVjGUt5mB20vQitI+LYnYYagF/r m X-Received: by 2002:a05:600c:3b26:b0:426:5b44:2be7 with SMTP id 5b1f17b1804b1-427dc5204bfmr69229835e9.10.1721664520226; Mon, 22 Jul 2024 09:08:40 -0700 (PDT) Received: from localhost.localdomain (gen92-h02-176-184-20-254.dsl.sta.abo.bbox.fr. [176.184.20.254]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427e29d11d5sm66473215e9.38.2024.07.22.09.08.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 Jul 2024 09:08:39 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell , qemu-arm@nongnu.org, =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 7/7] util/fifo8: Introduce fifo8_discard() Date: Mon, 22 Jul 2024 18:07:45 +0200 Message-ID: <20240722160745.67904-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240722160745.67904-1-philmd@linaro.org> References: <20240722160745.67904-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.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=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 Add the fifo8_discard() helper for clarity. It is a simple wrapper over fifo8_pop_buf(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Pierrick Bouvier Reviewed-by: Mark Cave-Ayland --- include/qemu/fifo8.h | 8 ++++++++ hw/scsi/esp.c | 2 +- util/fifo8.c | 6 ++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h index 21c7a22937..53bafabd25 100644 --- a/include/qemu/fifo8.h +++ b/include/qemu/fifo8.h @@ -129,6 +129,14 @@ const uint8_t *fifo8_pop_constbuf(Fifo8 *fifo, uint32_t max, uint32_t *numptr); */ const uint8_t *fifo8_peek_constbuf(Fifo8 *fifo, uint32_t max, uint32_t *numptr); +/** + * fifo8_discard: + * @fifo: FIFO to consume bytes + * + * Discard (consume) bytes from a FIFO. + */ +void fifo8_discard(Fifo8 *fifo, uint32_t len); + /** * fifo8_reset: * @fifo: FIFO to reset diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index cec847b54a..c703fa7351 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -351,7 +351,7 @@ static void do_message_phase(ESPState *s) /* Ignore extended messages for now */ if (s->cmdfifo_cdb_offset) { int len = MIN(s->cmdfifo_cdb_offset, fifo8_num_used(&s->cmdfifo)); - fifo8_pop_buf(&s->cmdfifo, NULL, len); + fifo8_discard(&s->cmdfifo, len); s->cmdfifo_cdb_offset = 0; } } diff --git a/util/fifo8.c b/util/fifo8.c index 6610b79182..ea39ca2552 100644 --- a/util/fifo8.c +++ b/util/fifo8.c @@ -131,6 +131,12 @@ uint32_t fifo8_pop_buf(Fifo8 *fifo, uint8_t *dest, uint32_t destlen) return n1 + n2; } +void fifo8_consume(Fifo8 *fifo, uint32_t len) +{ + len -= fifo8_pop_buf(fifo, NULL, len); + assert(len == 0); +} + bool fifo8_is_empty(Fifo8 *fifo) { return (fifo->num == 0);