From patchwork Fri Jul 19 15:16:26 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: 813398 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp803735wro; Fri, 19 Jul 2024 08:17:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVhu2rqYbjmn2LOgeHDpzrzFPLanISCTZ/Cq9Uv2eSF84YpfnflUGiBVJnnLZzKGzKl0t6+u8TcwilhijaxCdRR X-Google-Smtp-Source: AGHT+IHCiUo6LPXDr/TzvaF8GNFV+yyhtRP5NuY1AAR49ymuZA2xcyxcxoyjYVBcNAolVzHLPCWl X-Received: by 2002:a05:622a:411:b0:446:49f1:79a with SMTP id d75a77b69052e-44fa528167amr1561551cf.24.1721402236845; Fri, 19 Jul 2024 08:17:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721402236; cv=none; d=google.com; s=arc-20160816; b=E4NmlAw3i9qjHBZLEET0YDspeVs03ZCFNt4KgKGkt995aYBpdOsL4W4okxih8wJzKY j76lijGXto8nfkmfSOhwlbfSqJiiYa0o8geC4ODzgYBqz/AMalKK3/wzpRWH2s0pnkKW JixellH8SWHVqI88AxY+dyLvW2WFsRUrHf9GoagnL57yTAWPJQDucDAc5BXgQRaZLm8j 1sWp3BoTLDou+Tkl2SKYQRGE/8TbsUYHXVJXO3XVszP+n/SxiiPZoeSRU0EtHh4gSCTu AV7KqK4DUrn0nFJ+SSrRDWZ9vi/7Z5Rs4J5C/SUhF/FjG/TlFhG+Cr+5X8pXVqXIBvzt u9Hg== 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=x85t1oRdkXPj1jKJlZTxTgRAxr541dTWHBTkbfm0IzE=; fh=6A5DDM1YnPXwV3TSnbnhuwczpdhYz895pM1DG+zdVnk=; b=fexHUAt8DqcTpQ8ZiHDrzKlQu0lCHRW5QHwUEFbRwK+v7h6wr0ruJtjk1UhgsW7Y9M 55v8HZW3HsMr73sGWr7Su2KDgQ7rY0X/3OIVitJ58AqTO7a2u2HYA3RC01pGGze6V7Ow U10OT9YngHSkfsV7QZIKQBCKk9opAS9FDjkIhB6wY3RdCblBiTgyiUfl/fyf7ixLn0/I IirTUq/6+TtscM0mZHFYtoGK6/Zif5l4wvOX2dCc0dqWjABEf29Oc/6AT+oHdTnKhcUM DwPRKlkmTihGmuZNHn9E0lddZTf4n+mYBTp+AbEierpCTQdJm37lEcziKpj3SejZ3n9B hStA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JMU6qQBj; 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-44f9ce0733dsi17839081cf.640.2024.07.19.08.17.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2024 08:17:16 -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=JMU6qQBj; 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 1sUpLe-0006px-91; Fri, 19 Jul 2024 11:16:42 -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 1sUpLc-0006lM-9e for qemu-devel@nongnu.org; Fri, 19 Jul 2024 11:16:40 -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 1sUpLa-0005vG-NA for qemu-devel@nongnu.org; Fri, 19 Jul 2024 11:16:40 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4266fcb311cso13872325e9.1 for ; Fri, 19 Jul 2024 08:16:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721402197; x=1722006997; 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=x85t1oRdkXPj1jKJlZTxTgRAxr541dTWHBTkbfm0IzE=; b=JMU6qQBjtX1bJDbNDxBDtxT95y2760ZkAE5G1JQQ71gS331uJroiWIGrVarorZL6AC hN5KKHzQq3HtwIcnzlcO5oRb7Ek5ZerxVVlRr4MNuP+Yx4WEtvTq90pYijcfkp9prcte RXPn26zNhiV64wI8gjJ8nRI64lp1VQNiG1IZiJDvoEIKIjxlL73B+FEJzzFmJwwMVcsL JaS30co2TSVgqXHoAZIA+C3n5+jvQ0rQ1E6fSXL0FVKB1wFM3NZfHsMgQmAT0SeWTULI QiJk0q+ixhQaFoV7p3EAZMUEzsMSCXdan6i7aWbVleCbAlOC4JM3hFDmx5d02UTFfCxf mrrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721402197; x=1722006997; 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=x85t1oRdkXPj1jKJlZTxTgRAxr541dTWHBTkbfm0IzE=; b=ImJs9ImN0Eex90MqTT7bVljoVjDwiCcsTFaJgTUs616WjDA0hADcY4KdkczHPjR324 Dfe+3dxvqnsoIq4oPmGmhc5alvP1ql2q0S4YzJqi+xNmftVU7eKwVjoDgmfK0Harl8bS ZaSYNS4KnFeqwrQzu0D3VjEeI0Pxt3w4wsihG9/tTfP/qUgA4z4+HezFbFyN0nTPmnXy 7fIWxm9HSm50EqDlrTzO6a8gXcXvmHZXvV/wT9WbO+Aq7eINJbs+K4wob1N/vdFf4Sd4 OorEtMqqvFeLqYHCSj47hHRvG6HNJMM4R3bhAVo4UHT9jJatNdtDLwIeNg2ILzvkg/iC tevw== X-Gm-Message-State: AOJu0YyN5r//M4n4QR+YPsZqpb+eLTnRvUgqY3Zn7cX/b5u3dEUt6TgG 3bx3MVbwcpDi5Gp4fIMWA6p0vaKAl9DM3ZHmTJ35JcHq9C+b+qHVe9SK8igAccpIcM0+dWtWzkP v X-Received: by 2002:adf:ed43:0:b0:368:4def:921f with SMTP id ffacd0b85a97d-3684def929emr3705972f8f.11.1721402196934; Fri, 19 Jul 2024 08:16:36 -0700 (PDT) Received: from localhost.localdomain ([176.187.209.227]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-368786848basm1873766f8f.15.2024.07.19.08.16.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jul 2024 08:16:36 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Mark Cave-Ayland , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 1/3] chardev/char-fe: Document returned value on error Date: Fri, 19 Jul 2024 17:16:26 +0200 Message-ID: <20240719151628.46253-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240719151628.46253-1-philmd@linaro.org> References: <20240719151628.46253-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=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 --- 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 Fri Jul 19 15:16:27 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: 813399 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp803752wro; Fri, 19 Jul 2024 08:17:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVGqmTogjlYlAQkvTc0Df4YEDoDn61KrVywRrEl/IfAckmjnPT3ij/iMs+bg7i/8iydHNMKyWc7h1NnLtFGYozB X-Google-Smtp-Source: AGHT+IFXAB8APHH0Q6LyBE6nWtnLIR+j6Fwqk45J9LrMIMJpMo3v/CYFhv0azV5Q0ESQCHuT4420 X-Received: by 2002:a05:620a:3949:b0:79f:720:ebad with SMTP id af79cd13be357-7a1a132c7b0mr23627485a.21.1721402238376; Fri, 19 Jul 2024 08:17:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721402238; cv=none; d=google.com; s=arc-20160816; b=kG8fYXqc3TBrT7WKw1hpPiaW0YLNWD6S+6tM+1t1U358LapnxO8JNzfdKDxbu5tzr7 KYjKv+gFJipIkuToX6JPDgjHQWvt+S6mkd32cP3TtdRw+5ChRSUEeum8xafXDymEt4jo V61Vysw7b/oqMk4xFXVZM68xgsYcalcxaVnlS9VKiWnV7C+GXxBaukBrKEpSaK7bKBQJ irbFvrG3e6lEOxDKAi27/y0FodUmq7luXpnZP3xS3UMZUtNH3jDTvUDai/hQEx0Lbtrd ESXPMIpymvfksgArLRtuoHd+8pQwe4W8EIgoPpwPPrqpE5HRCY8oezf9uxdDQTqMiVaz aB2A== 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=QSgsrmLsVPPMIVwIX59F0oVAQKgoQ9K5XRt0PeEYee4=; fh=6A5DDM1YnPXwV3TSnbnhuwczpdhYz895pM1DG+zdVnk=; b=FajoEd7711Ti+Yv8BMKvoSziZ9zX+bMWCI6NNnHuApORxv1VEyV8sZUEL7uR3QxS4W bZGYW3dnWWkqSuLXKL4Sveb1byo2Z8JxzTtXnav6fbfbvj2ZNXU9FLSpOKUMTfV3F5R+ DdVlwEDOZx0T5XCrib7yQwJTmOdST0bq8vqqsKEZMCWA1bLVa0Je/zSmNZwc+Fo6n3mp pKaueEwLwzFPw60ZrukvC8Iim8JYXKr037WVrbXsOjWdXkl1SJBj3C6hEdWTmMUV9EP2 8x5WK2jETwb9EHSxI3ySnxTI/egTiIHo2xywFwyQ8Z/3cBuweg6kcFAT2yS2zPj+/PiO nrIg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=l0ssbj8v; 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 af79cd13be357-7a199092a04si186738985a.592.2024.07.19.08.17.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2024 08:17:18 -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=l0ssbj8v; 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 1sUpLj-00075P-1C; Fri, 19 Jul 2024 11:16: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 1sUpLi-00074V-7L for qemu-devel@nongnu.org; Fri, 19 Jul 2024 11:16:46 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUpLg-0005w7-Kz for qemu-devel@nongnu.org; Fri, 19 Jul 2024 11:16:45 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-427b9dcbb09so14283095e9.3 for ; Fri, 19 Jul 2024 08:16:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721402202; x=1722007002; 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=QSgsrmLsVPPMIVwIX59F0oVAQKgoQ9K5XRt0PeEYee4=; b=l0ssbj8vvnyciIesIPlHkY9CpyBsvRCIoaE319riiFAnRm9Xc2yAV2jJ6cvgpS7tZR 4LtzIU9YU0Vi1w4c1dh4ONvh+TYtZJqJ9Dedzog2N+qfdFlV4Kyxj4OVMjEpi40Rzcsp eJjl/c3ioDWxdjIxdw33CDJWOWw/5dxU1RobNKaERzWNzhtA/h3Fw5hHFPfBs/ZG4y+L OBTeVJtpVswZdZlljTbd7KjZEEI2JxH/2vClE4HQRjXEZlEJoD9cp3WsBfrgykR+3E/S Y1nthYqZ6Jny0r7kCoCADNszBVDQY4APlGTUyIpqQjtYMXfwTn4taPd9/sdaTKoc0+wR UVkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721402202; x=1722007002; 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=QSgsrmLsVPPMIVwIX59F0oVAQKgoQ9K5XRt0PeEYee4=; b=TQ9gB9HDjXzcdLvohKQb3Hfv7WuJinKaEdPp1FqgghgHvtYCd/lrP9WsqeMQVj3w1+ 0ADxwk0JRxAVnb+ksNWG27jcXxtuIcowcqbJSlctZo6bu4bWgqO36HyW3q6b0oN3uMjA 5o94uoU7yGeYyTL+NoNy82YxVVEW1nCoO2sCF4UomQ7oKBvGMmYoSRR4TGD81tId0sW2 XV6+b9yEBcBGLox7RqhK/eL8uy8JI4bpEXqfjomItTdNSBIWEguqBf33XlicC8yF4GCp 9XigrWaU4h07epnsu8RWlgbv++6XN5Ux7EoNV4FHlF/cqbqWReDKvnqwZP1rO3im7URv NHTQ== X-Gm-Message-State: AOJu0Yyun+rTL5lujaYDYQlOAxeAGx+yDR0mDKta8mMZPvx4Vw2cVq8M 4ztKk05HkQSs1vQojIQdQtTFRNF0X7C7TpB1y+BPY4jBMM6F0MdSCVU8Th2iqw2najGipFYkVH1 v X-Received: by 2002:a05:600c:4f8a:b0:424:a2be:c161 with SMTP id 5b1f17b1804b1-427c2cd0996mr53064555e9.20.1721402202305; Fri, 19 Jul 2024 08:16:42 -0700 (PDT) Received: from localhost.localdomain ([176.187.209.227]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d69019a5sm28001065e9.18.2024.07.19.08.16.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jul 2024 08:16:41 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Mark Cave-Ayland , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 2/3] util/fifo8: Use fifo8_reset() in fifo8_create() Date: Fri, 19 Jul 2024 17:16:27 +0200 Message-ID: <20240719151628.46253-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240719151628.46253-1-philmd@linaro.org> References: <20240719151628.46253-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.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 Avoid open-coding fifo8_reset() in fifo8_create(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Mark Cave-Ayland --- 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 Fri Jul 19 15:16:28 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: 813400 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp803974wro; Fri, 19 Jul 2024 08:17:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXXJ1COC9giKDnqETiA2qRI3KcyZa2WMrYcrk9SE337rkUeNnNqIw/HW7/UIXWsKooDoCLJ8/VL/pcbh4Dqf9cZ X-Google-Smtp-Source: AGHT+IFp4gw+x/O/qO5Th3DSr68EBZwFCnl55IrmtxfrLFAmO9eQkWBItzsfc1laZW8bd4khGQHx X-Received: by 2002:a05:620a:44c2:b0:79d:7014:920e with SMTP id af79cd13be357-7a18744120dmr923096185a.7.1721402265908; Fri, 19 Jul 2024 08:17:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721402265; cv=none; d=google.com; s=arc-20160816; b=ezbrudi8pU1YwvSlMmHCAIS/melQY/ewSJMDRCCN5B8bU7Sl3Yl6AdFTLa2jeHs20y ppnW7nieEPN1JtR/SB9zBzkt8JTq2UJLcC++GryzOX4o9X1Mlrk4AdyzFjjAhos7Y7qH O/Quy2HcTcSougEOJAwFvpSVu3F3NTQaEKvCHHmoFbQQwv6Pu7pQIh2R2H+8dx8STUhu syYmCUk8uk5U8KaZEFh/3CYGemmtqtIt0uv9et5M/5Yq/MesiOATr9BCly/ISFkrx1O1 Hhm8YxfbUk35wUTjPEoDmD8Ea0ms4tJtTEIn3toz78+OpjkxNxPV5vnd/0glww7PVeJ6 PGAw== 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=i62jBV6Wd55qPAZwjTal/ze4o9fjzCulHJqhfykkTds=; fh=6A5DDM1YnPXwV3TSnbnhuwczpdhYz895pM1DG+zdVnk=; b=O+VH6ty56IPO/5h6X0B3Vvek9S2qBgSBxHPHyUUdfGBeHEg8ZdXTcOHm/5YJYCD0ng Vq+a6zrQonXMnWXA/DSXZM2XnGGX1w0PwZzSms6Cow1xLxJtzKRSlhifXa7/Q6qf7sV9 2+XXy8a/26XG72JiQ/vgUHdCeXK0q3yXYFrx5/5xaXrsw+oYQhGnb2P+nuomNbtDz1Lo bc8Jq3/S7TuijJ9wP1nH136Uj32iJmFPUz397kU2z+Hfpcz1lzVIDhjtC6LUQrk4vbDP 4OFtpSQmjH3Cf5yIKs6Shm1+FqykSBBRtx9QXmqRhmeg/y02GVM23kz4F40JKuqX3ZDZ CKxQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dfvdO26D; 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 af79cd13be357-7a1990925e7si185946285a.548.2024.07.19.08.17.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2024 08:17:45 -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=dfvdO26D; 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 1sUpLo-0007NV-3Q; Fri, 19 Jul 2024 11:16:52 -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 1sUpLn-0007KG-59 for qemu-devel@nongnu.org; Fri, 19 Jul 2024 11:16:51 -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 1sUpLl-0005x2-G9 for qemu-devel@nongnu.org; Fri, 19 Jul 2024 11:16:50 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4257d5fc9b7so14736175e9.2 for ; Fri, 19 Jul 2024 08:16:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721402208; x=1722007008; 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=i62jBV6Wd55qPAZwjTal/ze4o9fjzCulHJqhfykkTds=; b=dfvdO26DReFXZr4UPuNmazfJHBaKFJPBA4WQDsG9Ge3mFy/8TPjZpQQUgrfNZjuDSG jL5IaytnC/rfNtbDihbfvHw+MXq6iu2M6Qu3EoG62G3H1rtWEHi3ywYMu3Id2ZFva0T+ 1myk2XTn4cYat63znf3HGbXNFzhyMut1pjTHOyhnd6lNAALG02Vpho335aMumAvh+xVJ kOt/jCNHZjFZcMtJ2NgRygvB1KQ+07GU1Elhm3M+HERqDWuvq/etGv6TPoeQifLnI/sA 1iH+v6kl0fvzQH8gn0d4QP+VIuyXeSg8uTmDVbTa5DOpxw8eRQyL1TJr9JrlUa1HKW8r agqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721402208; x=1722007008; 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=i62jBV6Wd55qPAZwjTal/ze4o9fjzCulHJqhfykkTds=; b=ADHAQLzQSjDhuxIFQ6leqNDh/Tpoyfs4rFcxurHCyYtKbBjL7tDX99YhOHQ6TfHrji U8DqI5uN0Ko6x4o/ZHCLWgmWty4KbmEOAvoQxpmk5sS2u7j6aRe3g+qswxTzDwdDfcnR 0BhEC1KFjyE4TTLZS7nyyy3aIvVppALYxwPyqfv5+fa57LZAXs4jrMwzXVMXcV+HuEMs 2itkej9CNL/fcSo3NFcumcgWPhesuKhXJotr2yoK9nTFNUgokDMzPWbDvLHHOujIMaEz gU/kGmZTsRlkpBDGGQBuCS4Vv1xNyoGS3HM+dWhnz/162zsdQXtCwshebI9+jejmRxPZ BxJw== X-Gm-Message-State: AOJu0YwEYqrfPCashFeTyNZ5ZBIcSB7uXpPkwqgYwNU0BhryN5Od+onM Gp2gBd+y8h8bwrVdBQ/0lz7Gvq493nWoVJVUJ3wdp7/glHBY7na9yTN3RlME1OqDx1I31UEa52m M X-Received: by 2002:a05:6000:9:b0:368:7f53:6b57 with SMTP id ffacd0b85a97d-3687f536bd8mr1363963f8f.18.1721402207833; Fri, 19 Jul 2024 08:16:47 -0700 (PDT) Received: from localhost.localdomain ([176.187.209.227]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36878684204sm1857670f8f.2.2024.07.19.08.16.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jul 2024 08:16:47 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Mark Cave-Ayland , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 3/3] util/fifo8: Introduce fifo8_change_capacity() Date: Fri, 19 Jul 2024 17:16:28 +0200 Message-ID: <20240719151628.46253-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240719151628.46253-1-philmd@linaro.org> References: <20240719151628.46253-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 FIFOs can be resized at runtime. Introduce the fifo8_change_capacity() method to do that. When capacity is changed, the FIFO must be reset. Signed-off-by: Philippe Mathieu-Daudé --- include/qemu/fifo8.h | 10 ++++++++++ util/fifo8.c | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h index c6295c6ff0..9fe0555a24 100644 --- a/include/qemu/fifo8.h +++ b/include/qemu/fifo8.h @@ -31,6 +31,16 @@ void fifo8_create(Fifo8 *fifo, uint32_t capacity); void fifo8_destroy(Fifo8 *fifo); +/** + * fifo8_change_capacity: + * @fifo: struct Fifo8 to change the capacity + * @capacity: new capacity of the FIFO + * + * Change a FIFO capacity to the specified size. The FIFO is reset. + */ + +void fifo8_change_capacity(Fifo8 *fifo, uint32_t capacity); + /** * fifo8_push: * @fifo: FIFO to push to diff --git a/util/fifo8.c b/util/fifo8.c index 2925fe5611..c453afd774 100644 --- a/util/fifo8.c +++ b/util/fifo8.c @@ -34,6 +34,13 @@ void fifo8_destroy(Fifo8 *fifo) g_free(fifo->data); } +void fifo8_change_capacity(Fifo8 *fifo, uint32_t capacity) +{ + fifo->data = g_renew(uint8_t, fifo->data, capacity); + fifo->capacity = capacity; + fifo8_reset(fifo); +} + void fifo8_push(Fifo8 *fifo, uint8_t data) { assert(fifo->num < fifo->capacity);