From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516149; cv=none; d=zohomail.com; s=zohoarc; b=R8+Ph8TnS1iGGidt7lLDcuefQ+3L/X3/g0ORslFzcLEm8DguocThwRCpYwI9kXyDlOUnzpf8jvY6Mmeoz3O1sJnd8atln5ekhLh2PTmukW65ErvX9MaBF3Kq4bsqFqUD6WeVdZ3Sa2oc1ZBMWCvQ1epl49b7BRidpu4bQErrU2s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516149; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=yy1snK9B+SCgWiCxmQTHuCxjH+9ISs/0CoWZHoMFEnQ=; b=OwVWhnE3IH9tMGoBTQyIsPFURgtZtiCrEzxeH0cvaY62qVr5QJIPcG0Nzw8pOoA35JL7emscjMRVcbVgpr5Am+3K/SYxIYfIOH6Adw2y5KA3zscyZ246ePZVJYV+6CONXBUbhet9UBbmF2JvcT+iHN49hgtgebDEkL99ag3HLas= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700516149900887.0919633228924; Mon, 20 Nov 2023 13:35:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5Bta-0000su-8S; Mon, 20 Nov 2023 16:33:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5BtX-0000sA-Gm for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:33:27 -0500 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 1r5BtV-00038C-0R for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:33:27 -0500 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-40839652b97so18294705e9.3 for ; Mon, 20 Nov 2023 13:33:24 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id k15-20020a5d518f000000b00332cba50ac3sm1859981wrv.45.2023.11.20.13.33.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:33:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516003; x=1701120803; 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=yy1snK9B+SCgWiCxmQTHuCxjH+9ISs/0CoWZHoMFEnQ=; b=nBb/tg7vnqbGh4qi0HIlSVpJFdSijMscvVO5AeDmwK9EtEwD1XMFB2FHFA8C0msjNz QMUXEDuqMQs6de49qxwMW6sH/+Y3/wqm95tMX8dKKSYtg2Q0mj5wOPU/dWM9vxl0TJMz dDIHvxplGtKyyXBvEV+X7eUxdTjRa7UxwRczhAii9OpXfUpLiga1tyvmBMfdNQB8UD+B nJdy8Ty9b5UIAJArKxC84DiQUq5fLsN4G6hwCx8r2zJO0ijcZs9IJcwvMqEZrp11+a8d QnFvC50goDhyyybdecjtSMmop3UkE6t3STiZ1WZTP7gu3UrFtFkm2KBRaYY+wnXwZbo/ zY2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516003; x=1701120803; 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=yy1snK9B+SCgWiCxmQTHuCxjH+9ISs/0CoWZHoMFEnQ=; b=YhlGm+c00NCKAym/thZDOC2t+/Oluz46r8p+9g7r5NAqD7Oo4qVKmYvO+glZpc6H9S queSdrSBLWGOZrbkpq0thS93qZiAYEOspRETD9XuOwLOvcA3xFwY/8W6q9vBTHr+xVnu WAwy01Nj+M+ATmj99eQvJAfgCDJAuLoBQDgbc7ZBPYolEwY4WuKuOc2oLtKuP0JHBHGt JGZdq00h6XyqTUBWfaX4chtFPXYaJubd37YBb2CPUo8oziBWbnsPX7EMhQVSOeqJCjz+ 1RQsuzUIcQMVEgvNsGyYQYYxXhDDJ2qOSCoInC0KDGiT5hvRw4eLLyBFODr3U+b4jBWm 7mgw== X-Gm-Message-State: AOJu0Yzjuj5Y3Z/9lh+KEkWelyWKS43Lccor0fZQYS2Gi1Bj691FVkNP D2151NYnQUD6cVEzXTFqx7Ew508VOz4jvozY8sE= X-Google-Smtp-Source: AGHT+IEkr26kiTb0vYXxIqK3/wBlqfrekq6CRZlLvz+0+kUPl7IXjrSmAPlwz1l/ysLWkRuBzcmP7A== X-Received: by 2002:a05:6000:18a2:b0:32f:a3fb:835b with SMTP id b2-20020a05600018a200b0032fa3fb835bmr7271877wri.44.1700516003375; Mon, 20 Nov 2023 13:33:23 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu Subject: [PATCH-for-9.0 01/25] memory: Have memory_region_init_ram_flags_nomigrate() return a boolean Date: Mon, 20 Nov 2023 22:32:35 +0100 Message-ID: <20231120213301.24349-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516151014100001 Following the example documented since commit e3fe3988d7 ("error: Document Error API usage rules"), have cpu_exec_realizefn() return a boolean indicating whether an error is set or not. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gavin Shan Reviewed-by: Manos Pitsidianakis Reviewed-by: Peter Xu --- include/exec/memory.h | 4 +++- system/memory.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index 831f7c996d..f038a7e5cf 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1310,8 +1310,10 @@ void memory_region_init_ram_nomigrate(MemoryRegion *= mr, * * Note that this function does not do anything to cause the data in the * RAM memory region to be migrated; that is the responsibility of the cal= ler. + * + * Return: true on success, else false setting @errp with error. */ -void memory_region_init_ram_flags_nomigrate(MemoryRegion *mr, +bool memory_region_init_ram_flags_nomigrate(MemoryRegion *mr, Object *owner, const char *name, uint64_t size, diff --git a/system/memory.c b/system/memory.c index 4d9cb0a7ff..313dbb2544 100644 --- a/system/memory.c +++ b/system/memory.c @@ -1583,7 +1583,7 @@ void memory_region_init_ram_nomigrate(MemoryRegion *m= r, memory_region_init_ram_flags_nomigrate(mr, owner, name, size, 0, errp); } =20 -void memory_region_init_ram_flags_nomigrate(MemoryRegion *mr, +bool memory_region_init_ram_flags_nomigrate(MemoryRegion *mr, Object *owner, const char *name, uint64_t size, @@ -1600,7 +1600,9 @@ void memory_region_init_ram_flags_nomigrate(MemoryReg= ion *mr, mr->size =3D int128_zero(); object_unparent(OBJECT(mr)); error_propagate(errp, err); + return false; } + return true; } =20 void memory_region_init_resizeable_ram(MemoryRegion *mr, --=20 2.41.0 From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516178; cv=none; d=zohomail.com; s=zohoarc; b=Pe+eg92GD69vPvY3luoxDBbOlUd+PochaFvQQYlu3kJtFDcZsCAHznzblifKViTfk5m2XfK/1qceaU+ySGRFVvSWmbhy0oMYJoZBfP8dEGee5g0YpcRo5lEJEz/RijZ8/KrghBqjpJT5t7sp1ZLf5+C4HbIuQuu+oSjH/UI6RQw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516178; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=a3R2bk2+TIy0U91qpyefgUOXYaNCg17GUPUMA/PpOZ0=; b=M0PkavsyKXeFEdCjGZwfI7n9BuqIrO8hzSv62vfNoqviclUwDzmSd57pFMhKXB3F4QehtnzoO0ahlBUm3kb25zr8gaXvD1xY/c+NaP4oqn08xr3s5SkDHBSUlDyiO+rGmMcFFvsKnZ+aBU09oVE9hgqthp/8a5aZ7kiL3AAb7KY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700516178699320.9142274117655; Mon, 20 Nov 2023 13:36:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5Btf-0000vv-QO; Mon, 20 Nov 2023 16:33:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5Bte-0000ve-Da for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:33:34 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r5Btb-000396-Tb for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:33:34 -0500 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-40b27b498c3so1308845e9.0 for ; Mon, 20 Nov 2023 13:33:31 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id n18-20020a05600c3b9200b00407efbc4361sm19623645wms.9.2023.11.20.13.33.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:33:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516010; x=1701120810; 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=a3R2bk2+TIy0U91qpyefgUOXYaNCg17GUPUMA/PpOZ0=; b=Wjdo8LXTJVtWVNM7cf4DD3DmNfX1hWErdwZCCu9PccWQm3yMMHmUFkW+buausZipmQ Cks/JK2/bl1sAvsbfBdpn0RBD51tgagCvxHP4NbcAGiqXB1FZmz5iTuUI7vS+jVhRbFm jMUvhOK+/kzz1sS+POgnZWRZD4S5IP09pC1sFgzpI7u37K6IkIaDbbma1aF2RzXjjqH4 tUwGp72RGhA5apPitaoq4dRWJV/BsJiPKxTIf5pl8HUsobeFrU1w5ZmlxqsZr7g9EKLt l4UcFHIBTqO23kxZ2tNQmTcXrlYPV9BgSn1D3GT8BD2lDDOMmsuhe+tOQgv3/Sb++5pf C/oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516010; x=1701120810; 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=a3R2bk2+TIy0U91qpyefgUOXYaNCg17GUPUMA/PpOZ0=; b=UCEs/dGkA9NYid079cXY0cG3dzJkUJsXBsnPhLYYt8ZFEOe3lyNyBH7dFcZB+tvq/h WaGrjgt6ZhyYw3s0NGU3EPS1FTVD/rIdMmG0Ga1X2xOZlyB83o51/65JrqZPrujgP6e7 wfe/qaavHILyzRAhp2HJdfNnY6Bgyq6rNw0NZz5Vf587DvFGBmR5fh5jeKzah9yVljlA +tGd45e3SkFGmpepmpiAzq0plo5wbHe36nzpbyFj+W2QgmRiZIuTxY9CVBboK0tM9kdz vE9uvGSrI5u3L/hrEFMLxu4KwiowJAZdOrRVIbp115x5A+uT7b4nsKagAn2w7cltWPP6 iqTw== X-Gm-Message-State: AOJu0YyQTpSyL7QRjWUGa/pGUMBEYu2sVEl4WW/2+uB3ObGwyAmlkChf di3xgytRwQYDg553QpLaFwE0aoMa9CnemToYkuk= X-Google-Smtp-Source: AGHT+IF4Fu/EHZIo8KqkEPLn1ulASCMhy1UyZQ70zwysYhCk8FlaAqB80HRdcHL78ePjqfq/OB+LbA== X-Received: by 2002:a05:600c:1ca4:b0:405:359a:c965 with SMTP id k36-20020a05600c1ca400b00405359ac965mr6739626wms.4.1700516009941; Mon, 20 Nov 2023 13:33:29 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu Subject: [PATCH-for-9.0 02/25] memory: Have memory_region_init_ram_nomigrate() handler return a boolean Date: Mon, 20 Nov 2023 22:32:36 +0100 Message-ID: <20231120213301.24349-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516179082100005 Following the example documented since commit e3fe3988d7 ("error: Document Error API usage rules"), have cpu_exec_realizefn() return a boolean indicating whether an error is set or not. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gavin Shan Reviewed-by: Manos Pitsidianakis --- include/exec/memory.h | 4 +++- system/memory.c | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index f038a7e5cf..4140eb0c95 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1288,8 +1288,10 @@ void memory_region_init_io(MemoryRegion *mr, * * Note that this function does not do anything to cause the data in the * RAM memory region to be migrated; that is the responsibility of the cal= ler. + * + * Return: true on success, else false setting @errp with error. */ -void memory_region_init_ram_nomigrate(MemoryRegion *mr, +bool memory_region_init_ram_nomigrate(MemoryRegion *mr, Object *owner, const char *name, uint64_t size, diff --git a/system/memory.c b/system/memory.c index 313dbb2544..337b12a674 100644 --- a/system/memory.c +++ b/system/memory.c @@ -1574,13 +1574,14 @@ void memory_region_init_io(MemoryRegion *mr, mr->terminates =3D true; } =20 -void memory_region_init_ram_nomigrate(MemoryRegion *mr, +bool memory_region_init_ram_nomigrate(MemoryRegion *mr, Object *owner, const char *name, uint64_t size, Error **errp) { - memory_region_init_ram_flags_nomigrate(mr, owner, name, size, 0, errp); + return memory_region_init_ram_flags_nomigrate(mr, owner, name, + size, 0, errp); } =20 bool memory_region_init_ram_flags_nomigrate(MemoryRegion *mr, --=20 2.41.0 From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516135; cv=none; d=zohomail.com; s=zohoarc; b=nQg7Uv0PbcvUmGcGzSbCanZzqj6p/et9GaADz3/HeUEhcgahZUy9lZqhuyfTjtVwlFVFpAEUh8C+lImqRiTz4YrevWBlsPJTC2ZlGAhmsTTGKVDznEgklV2lyuRaKXrbqvvZdQ7fUwuxjFMdfHA7XfHRzToBBT4E6lzKjYPCCV0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516135; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LbDA9YGRe7qNIe50oT0Ny26RZPp0o8gVGjIEnbyILZM=; b=O7THY3nf2XKTQwIPM8uY3MIRtiDv5TmQzU+gLG3OK2jKFFQNkpxrsZx83mWXsFQxeyBdRNX3i/mBNjiOhLuM4S1f0uB6sYnTcpkz1nKp38U4NV5Kd4kezlHdHEhh2KErucVRyY4obEtQYpaB6ZUEr4Tjg1WQbO1dhhmmXxjUnog= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700516135934745.4141575656656; Mon, 20 Nov 2023 13:35:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5Btq-00018c-GU; Mon, 20 Nov 2023 16:33:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5Bto-00016F-S7 for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:33:44 -0500 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 1r5Btm-0003BQ-AZ for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:33:44 -0500 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4083f61312eso22408275e9.3 for ; Mon, 20 Nov 2023 13:33:41 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id j32-20020a05600c1c2000b004094c5d929asm14891734wms.10.2023.11.20.13.33.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:33:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516021; x=1701120821; 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=LbDA9YGRe7qNIe50oT0Ny26RZPp0o8gVGjIEnbyILZM=; b=cAxnqNxGWqekkN92GLQ8zKXsAL5t26rbEEO/cjQITi6I/0iv2iMR0CCdu6mTHnApur 7/bppD+qcmdr58agvZ27FQMBH8ot648OuHSjwlHSXnrDfgyFDDaDdTxP9kQtT5b3e9r6 c364UHE/lPI9C1jbs9TlF9HAkMQQHFrpozOd9mIn8kz/rphv90aUL0LYJzOnyrLshkBR xmdEP+INbq+jiHPFGZweskQOrCD4ivCfkIbvKIZ4t9UwXV2n2WqOynxRtCS8/I2GkJ0R Rsx28Sr6PGMUPPzzWeKLqBwmyHaOvCt24S5rHVqGCx7d91t3+sRA/fvja+BxsPyVkGG/ mIuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516021; x=1701120821; 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=LbDA9YGRe7qNIe50oT0Ny26RZPp0o8gVGjIEnbyILZM=; b=ChlJx/sfcH2zFnTi6483RnlilYAXqdt61onBnuMOA2Sdz1LH8zvcDM35BVhVRONU+3 aedLFTc42VlYYnbbbl2AdwLe74VGurXvCQQwqX1+sgu17iQg91koHUBj6t+uO7FmtxG6 znSaF1o7diu4vvB3rJyKCa5fuMNIfKqNxLFU56OnZRPkTtN6zySLdnUIsgK8UtpOoAZn 3a49tIn1zJEG81045oadhey3c5fzsHjJpjM0k0u9qEdO6o3uQLyQMVxpkSnupqEPT9dM GArsU/Zw3N0Zic9DvYadKJsuxuTmmY+s/XHxHd2avc/M9xihy8r0bPmJAD4vNBLnBdsQ /RQw== X-Gm-Message-State: AOJu0YwhdyJRR5xZqPuQ6zMaDTxSeGVsgcrPoTAR8/WUU/vOZ5pCi7RO AweZA1/2lQnwnN+Ol6dhxODkqKuG1vdAog4VfMc= X-Google-Smtp-Source: AGHT+IGV4DlNWGMbTD3xq4BBT3E729eZTiGtQ1hohduWzUYFvKfsGB15/8I9/AEUED0Q+S8SHsYNkQ== X-Received: by 2002:a05:600c:1994:b0:405:40ec:415d with SMTP id t20-20020a05600c199400b0040540ec415dmr6998432wmq.39.1700516020706; Mon, 20 Nov 2023 13:33:40 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu Subject: [PATCH-for-9.0 03/25] memory: Have memory_region_init_rom_nomigrate() handler return a boolean Date: Mon, 20 Nov 2023 22:32:37 +0100 Message-ID: <20231120213301.24349-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516136962100001 Following the example documented since commit e3fe3988d7 ("error: Document Error API usage rules"), have cpu_exec_realizefn() return a boolean indicating whether an error is set or not. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gavin Shan --- include/exec/memory.h | 4 +++- system/memory.c | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index 4140eb0c95..8e6fb55f59 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1498,8 +1498,10 @@ void memory_region_init_alias(MemoryRegion *mr, * must be unique within any device * @size: size of the region. * @errp: pointer to Error*, to store an error if it happens. + * + * Return: true on success, else false setting @errp with error. */ -void memory_region_init_rom_nomigrate(MemoryRegion *mr, +bool memory_region_init_rom_nomigrate(MemoryRegion *mr, Object *owner, const char *name, uint64_t size, diff --git a/system/memory.c b/system/memory.c index 337b12a674..bfe0b62d59 100644 --- a/system/memory.c +++ b/system/memory.c @@ -1729,14 +1729,18 @@ void memory_region_init_alias(MemoryRegion *mr, mr->alias_offset =3D offset; } =20 -void memory_region_init_rom_nomigrate(MemoryRegion *mr, +bool memory_region_init_rom_nomigrate(MemoryRegion *mr, Object *owner, const char *name, uint64_t size, Error **errp) { - memory_region_init_ram_flags_nomigrate(mr, owner, name, size, 0, errp); + bool rv; + + rv =3D memory_region_init_ram_flags_nomigrate(mr, owner, name, size, 0= , errp); mr->readonly =3D true; + + return rv; } =20 void memory_region_init_rom_device_nomigrate(MemoryRegion *mr, --=20 2.41.0 From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516066; cv=none; d=zohomail.com; s=zohoarc; b=fR9rFtLn/5uB0qiJVDHo5eH8N6RBx9sZ9micHo3BAmkPMiWJY0NaiLdu9MmMkyTh6DWlc3953zSNfNGEMawsG0A4LsaSMVeaEIZPj1wPQL4OlUvH1a3GqpZ3RYrY+41WK0aR346SFJ8WzcoF9hJWB0SaBYAsZIaCLpZhIDefx6c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516066; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fonaudvT/zI6eYgx9UtSiLdTbmVbD2gVa6JY6eKabgU=; b=UcCg1QB9Bg1my89D39XnH2jRlczBuk7V5YJ8UEB1foewBHkkKji2rfLFsRbGmiSoWGuWyRtksdj246AuiCHo2O+mBMpyXrDajip1cEAwGdzROtww4ZQamdRmRamL/3SWiBdbwbcwjNpmK13CV/5UQi8VjKC21x/MGjf8r/uU6bI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700516066862408.32113700019215; Mon, 20 Nov 2023 13:34:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5Btz-0001AD-4y; Mon, 20 Nov 2023 16:33:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5Btx-00019c-9G for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:33:53 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r5Btu-0003DP-Ex for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:33:52 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-40a5a444c3eso16881325e9.2 for ; Mon, 20 Nov 2023 13:33:50 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id je12-20020a05600c1f8c00b0040839fcb217sm14809038wmb.8.2023.11.20.13.33.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:33:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516029; x=1701120829; 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=fonaudvT/zI6eYgx9UtSiLdTbmVbD2gVa6JY6eKabgU=; b=INOhgKhilQedlZMhwtosqFZpSxTUqRnWapdsPPsXvpkFW5XoqvunY//K0AJptYpA5n GKlJbOhqK0H9P+lOGs8W6d6BVFsaeBc2OLIBuBsOAkEG9Inhz1LD3GgJVLuW0wPCUJir zRi4A4D7QnMLzFjKQ8Nj4G0rC9G7Iq3ZxNHqbcwI9YKiBaW3ew3IGZY6Z0Sfq598pCfT dTPrYayzQz+HwLJpF2EjKE4ec32Qsc+ZT9wo/W7bUcYhT2HKkxkCbQf0wSCQ+X/IhUol k0galAB/etIzsr5uqFRZ5dysweBNX/I2YkS2kcPAgFTm/4uKZVxhoH3R864xjX7PfSVM HVFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516029; x=1701120829; 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=fonaudvT/zI6eYgx9UtSiLdTbmVbD2gVa6JY6eKabgU=; b=m8B3HanIeWqvnpRewilmmybj5FFbX4AwE3XTbTVMI5OxIvtVfFc3+OJRYPICjexojc fEG1mCSYJqiS8tFMXf/DYpi/KVAGHBsXy5qEjhGF7RQmsMI5NE//ZlJTg6iWUUfRcYz0 mvUkTl9Ex0k3C3EKHXpbAH3nj1yFi2dcXBiqitBhzZWuvGbjN+Z+ED9L+lmDbtnoiaV5 UG352LNF5shJZYLUAzVCCecU2+nZ/La9qtWtOX/G0/b/8Pd+qcKwt28UEIkREen6Rd4K dQrqfN4AITiAKyAaTS4nB3yFUWJLn6PrZe6Duc5pB6gc7B0xY3OF6GwivtvgsBz3u+mK T0+A== X-Gm-Message-State: AOJu0YyedRJMSkfyXLCMVg3YjpTsTBGdfOZ6qghY/Mv72PkXiyppV2uf CKatQVEm0Dqirrg4PHVk0PJHoZJsGjSF1mT2xhY= X-Google-Smtp-Source: AGHT+IG+UMzpfApSrpqBcDz7//bNLjdvqb0aTsN1x9v0ryzyBvE+PB3hSXzV/HU8pb9pxUnHkU5P4Q== X-Received: by 2002:a05:600c:19d2:b0:405:4f78:e128 with SMTP id u18-20020a05600c19d200b004054f78e128mr6897554wmq.4.1700516028900; Mon, 20 Nov 2023 13:33:48 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu Subject: [PATCH-for-9.0 04/25] memory: Simplify memory_region_init_rom_nomigrate() calls Date: Mon, 20 Nov 2023 22:32:38 +0100 Message-ID: <20231120213301.24349-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516068642100006 Mechanical change using the following coccinelle script: @@ expression mr, owner, arg3, arg4, errp; @@ - memory_region_init_rom_nomigrate(mr, owner, arg3, arg4, &errp); if ( - errp + !memory_region_init_rom_nomigrate(mr, owner, arg3, arg4, &errp) ) { ... return; } and removing the local Error variable. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gavin Shan Reviewed-by: Peter Xu Reviewed-by: Richard Henderson --- system/memory.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/system/memory.c b/system/memory.c index bfe0b62d59..2fe4c3861b 100644 --- a/system/memory.c +++ b/system/memory.c @@ -3628,11 +3628,8 @@ void memory_region_init_rom(MemoryRegion *mr, Error **errp) { DeviceState *owner_dev; - Error *err =3D NULL; =20 - memory_region_init_rom_nomigrate(mr, owner, name, size, &err); - if (err) { - error_propagate(errp, err); + if (!memory_region_init_rom_nomigrate(mr, owner, name, size, errp)) { return; } /* This will assert if owner is neither NULL nor a DeviceState. --=20 2.41.0 From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516196; cv=none; d=zohomail.com; s=zohoarc; b=ekTyQpu8/zB10o69BceO5RCOjuDMdpt8T6nQ2MspIz0c4vm5SNAWUrrEZL7EBwac0sIvp3VBrpowNSp5u+WFRugucqoZyVE0AHtOs2JaYfv3Kt0HpULe32zjHp0gqPrJkicxRrSEYFdZjrLQOIhR5/R2ahNu5j5Igz5JwtoO5SU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516196; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Q5q8QrKQWuc5ZJauQIVd7Hh9PAH4SP4rAcWXs3pwmqE=; b=nmoLW4BBDgfWkMl8cadphndXJgHAYB1En87FOGn/DPOxtInR9MRS51tJRsjKB6oBW9DwMnLxujEJOI4OikPSlqahQKcg7PQoEqRcW9HLa0jXb02UoknVDU6feJd60QdbHJKo+2CTRWYPAaWeUqjPDR3dI8lnLlMVIM3bYp2z1e8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700516196875421.2806265395243; Mon, 20 Nov 2023 13:36:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5Bu4-0001K4-UJ; Mon, 20 Nov 2023 16:34:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5Bu3-0001J3-IJ for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:33:59 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r5Bu0-0003Iy-IU for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:33:59 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4084de32db5so23400665e9.0 for ; Mon, 20 Nov 2023 13:33:56 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id a3-20020a05600c348300b0040a5e69482esm19351694wmq.11.2023.11.20.13.33.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:33:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516035; x=1701120835; 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=Q5q8QrKQWuc5ZJauQIVd7Hh9PAH4SP4rAcWXs3pwmqE=; b=jCWV1wbkyERg6hF35VqiCyW8CUpdsYYaWQBOV9YfJziIQCJ3CPACMs4bhVDav5Lp7b wFXvwevdIgCfNyG+ok/+nk4vdfXfPfDHOixuqlDuAw4MsfTGxshHhMSg+xR7f3QpSCF1 uEVK95K4NOiRw+TSfx7wJP5Ut6lZm5duCixsDu8c6FEuEDts84a+na6qbT4X4wU3DSUJ 3hcoMjzt8yqlLSEeva2+kOsa3tJVXbMC8XG7UymB2xcx0hpW7aDldYSYdjMY2INq9UmZ UDI3fvrRb1O+FK+zDMrZpVroo7b+6Dy0x2s0UM+wL4G23JuMRasssW6MEpNrchorOFwK OYfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516035; x=1701120835; 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=Q5q8QrKQWuc5ZJauQIVd7Hh9PAH4SP4rAcWXs3pwmqE=; b=LUqQNspU+uWy+Tmfhm4cclpW3fO1KX1/MQ02+dYxpc61wkROETEiPL9NuReJjmrYXq Xh4iXk4K5qfjo3aTu9f57pR0JIfpqmFxjXiMhUZIiaWw6gwb7XmPZAr3Lx0dMglGukZb /MbPZ6xNNNUUDS9DujKOX36dusi8ys/02cOIZxZKZ/Z2q6jWXQ0RdVZoTKj/cVgQ+kNT 2RTO+qS4g5dK04AK3hzRTlk36LwTSYYaI9ZyM2WUrNYn/CtTJUDTwhIgAu7IE/PqnNtc uklnP04BrHfyb4ro9BsneB6XHudZ1txe8WdkutqKZkE2sIBpNSTPuJp0rYNUxdkkqQ+g 0rHQ== X-Gm-Message-State: AOJu0Yzqc+h9llRU13UroxmpV0GBcHWAWTjOQAUNBkO3ujDIvEVZG6vS bX8XuMfmq3jPDw4XDW9D+LQj9yAIJEn8N8VG8v0= X-Google-Smtp-Source: AGHT+IFtChFCcJ1xXKeaT07FMhkAl1Yfp8nNYMMp/8/9C/tFefF/sI10PcAYlvV5dQpfoLRA6l1ciQ== X-Received: by 2002:a7b:cd14:0:b0:408:3804:2a20 with SMTP id f20-20020a7bcd14000000b0040838042a20mr6807648wmj.22.1700516035088; Mon, 20 Nov 2023 13:33:55 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu Subject: [PATCH-for-9.0 05/25] memory: Simplify memory_region_init_ram_from_fd() calls Date: Mon, 20 Nov 2023 22:32:39 +0100 Message-ID: <20231120213301.24349-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516197133100001 Mechanical change using the following coccinelle script: @@ expression mr, owner, arg3, arg4, arg5, arg6, arg7, errp; @@ - memory_region_init_ram_from_fd(mr, owner, arg3, arg4, arg5, arg6, arg7,= &errp); if ( - errp + !memory_region_init_ram_from_fd(mr, owner, arg3, arg4, arg5, arg6, = arg7, &errp) ) { ... return; } and removing the local Error variable. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gavin Shan Reviewed-by: Manos Pitsidianakis --- system/memory.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/system/memory.c b/system/memory.c index 2fe4c3861b..ca05c4defa 100644 --- a/system/memory.c +++ b/system/memory.c @@ -3604,11 +3604,8 @@ void memory_region_init_ram(MemoryRegion *mr, Error **errp) { DeviceState *owner_dev; - Error *err =3D NULL; =20 - memory_region_init_ram_nomigrate(mr, owner, name, size, &err); - if (err) { - error_propagate(errp, err); + if (!memory_region_init_ram_nomigrate(mr, owner, name, size, errp)) { return; } /* This will assert if owner is neither NULL nor a DeviceState. --=20 2.41.0 From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516066; cv=none; d=zohomail.com; s=zohoarc; b=Ud0vmcf7in8HY7FnGwgzsy94oMMV8q9IjuGRKWc5hLlvZaO+jBoLtoE7evb1SYsPChV60RtrHHaTSwBbntl1CspgoM6qrl1cE1qWIelOA4u0nqVleTdvwRH/RtrlF8rcLPr7c4Loa9/jAh+ejVaTAUwhbsBFa3KdNrj4h9qsSWM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516066; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QBwxNmvGLLiXqhul31X+YfHhcCHLwXIU2jAo+ECLv+g=; b=MUqGPldZW7TNZdZIze5iJCfUfLRmRVdVo0ZVxNZaRUc/wR7DHNKdzUwtp8JN1ySllT9z++qGQ7hatrGTqXchaPSgz9K7O9wbrLd8rySvbOCht+s9K6pOOrjzA8Q2HF8pKHOWAlZP7DyCXjgSoZInGesLJN1Y4D8/lXetDBSN8KI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700516066872365.510192638151; Mon, 20 Nov 2023 13:34:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5BuF-0001RG-Ia; Mon, 20 Nov 2023 16:34:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5BuC-0001ON-Gh for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:34:08 -0500 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 1r5BuA-0003PH-Ft for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:34:07 -0500 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-332cc1f176bso402325f8f.2 for ; Mon, 20 Nov 2023 13:34:05 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id p9-20020a5d6389000000b00332cc3e0817sm1072899wru.39.2023.11.20.13.34.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:34:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516044; x=1701120844; 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=QBwxNmvGLLiXqhul31X+YfHhcCHLwXIU2jAo+ECLv+g=; b=B9ioF4l86mJ2HmniwrgFW9kmnsIW/KovEavtrtHrjV5TtcuGMCIhRxnHgJ7eQxP0sC y+7g5oKDwqYoNcQKp5CeygIROOVB/LwCeS9G/awhb2j3wfqS+HcEcJOIU6JYK0L91Iif ybXbRB6efcajU4tCbFgNMGNOP+7F7fB8dEdupbtssNm9vCdH698GAQBRvk9CM2CBYrxx ltJTaTqeGTw7Ie9lLiiwgowK+w1iCzZFPXdkoJaBjfw84GtsQ5ofrq9jV0vrZgG5GwoR ycqKwFoQx9lBTozjxwZxvQM4T28IsapjhhvPqnUbDNujPQK7DFoSjsIMQqkY1iYDVKKM qV0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516044; x=1701120844; 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=QBwxNmvGLLiXqhul31X+YfHhcCHLwXIU2jAo+ECLv+g=; b=HigChOZZBGaWIuZ8oeK97hwNSYenLQ5lo8cF9iyraLMmS9fl4sVknF0EOSR5Wa7/C9 SEAl/cJqMlg1uy3KykUcVNveUSN5sOcbXFl3U9SzIwB7lPWJLYnAgfwC3GuS7h3E2g0Y +kqOS64tsk7ulZ8r7Pwpq8eJRbfdO5TD8Paj2y3noZnE8dSsbSMtlPqJif3cEikUGQmV 8ERuFWY0veh+ehlr9Wiz+jHqR1NfhGcFX4eOFIB+lT1th7mim/qqHKefOh+0Gge4GO2K TnyPcCc/11AeRvP7AbAX6HW5GXXkPTcTqFWDsci4+HdLrjlGhBzzBB2GgDV+ycdu6MGK nD7Q== X-Gm-Message-State: AOJu0YyV34DxlVFZKHlAN5wGxGtw7nUwZ3buYTzKsoRk61JEtto9TbiF 0koZiMECw84WVrXaiLijZySPoycLzTWuLtwpxKk= X-Google-Smtp-Source: AGHT+IGhoeFxLVb1c8O/iSAw6YZEAiWFSVuYIYRW6k+270zx082Jw3NUxxEXlyAiLjU+Q41lF4Llog== X-Received: by 2002:adf:a3c3:0:b0:332:c284:c3c7 with SMTP id m3-20020adfa3c3000000b00332c284c3c7mr3558809wrb.37.1700516044460; Mon, 20 Nov 2023 13:34:04 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu Subject: [PATCH-for-9.0 06/25] memory: Have memory_region_init_ram() handler return a boolean Date: Mon, 20 Nov 2023 22:32:40 +0100 Message-ID: <20231120213301.24349-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516068611100005 Following the example documented since commit e3fe3988d7 ("error: Document Error API usage rules"), have cpu_exec_realizefn() return a boolean indicating whether an error is set or not. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gavin Shan Reviewed-by: Peter Xu --- include/exec/memory.h | 4 +++- system/memory.c | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index 8e6fb55f59..788872e4a4 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1582,8 +1582,10 @@ void memory_region_init_iommu(void *_iommu_mr, * give the RAM block a unique name for migration purposes. * We should lift this restriction and allow arbitrary Objects. * If you pass a non-NULL non-device @owner then we will assert. + * + * Return: true on success, else false setting @errp with error. */ -void memory_region_init_ram(MemoryRegion *mr, +bool memory_region_init_ram(MemoryRegion *mr, Object *owner, const char *name, uint64_t size, diff --git a/system/memory.c b/system/memory.c index ca05c4defa..4142eac498 100644 --- a/system/memory.c +++ b/system/memory.c @@ -3597,7 +3597,7 @@ void mtree_info(bool flatview, bool dispatch_tree, bo= ol owner, bool disabled) } } =20 -void memory_region_init_ram(MemoryRegion *mr, +bool memory_region_init_ram(MemoryRegion *mr, Object *owner, const char *name, uint64_t size, @@ -3606,7 +3606,7 @@ void memory_region_init_ram(MemoryRegion *mr, DeviceState *owner_dev; =20 if (!memory_region_init_ram_nomigrate(mr, owner, name, size, errp)) { - return; + return false; } /* This will assert if owner is neither NULL nor a DeviceState. * We only want the owner here for the purposes of defining a @@ -3616,6 +3616,8 @@ void memory_region_init_ram(MemoryRegion *mr, */ owner_dev =3D DEVICE(owner); vmstate_register_ram(mr, owner_dev); + + return true; } =20 void memory_region_init_rom(MemoryRegion *mr, --=20 2.41.0 From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516131; cv=none; d=zohomail.com; s=zohoarc; b=eWPaDlQxSHsp5Pz/LJwYB4rJrPP/pqvCJj9QaFhn+DGieELsRw1UfkZUkQGqmHRsYz/muJYenycx14HSCxWFvqX5TAndfGPnre/2WgKERfSQnOUr2EL5ptaEVBaeEz+eF+fnRhL/F4rzrZqoXyPx2ntyHNXLwBb80I0TZywJXtU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516131; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WK6ixy1lWz865bxFpaXwaNdgjrdvugwCVDt1SZLip8M=; b=fRsajug1hey49LPwnKtQKYUCdL6atP9EUm4gv3gCu6je/n4N9sqn+czMkYgzzBEO4fHa+YWR0q6LMiRYwspXsfKpzONUSMdF1TNMdSP3v46/GNruVGMQ05E3Yft0CncTyOsogT9YbkNvvzq7rJN2i9S7Tp6jCH4rK3/xVDjmuns= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700516131754923.6692983874823; Mon, 20 Nov 2023 13:35:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5Bun-0001zd-N4; Mon, 20 Nov 2023 16:34:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5BuU-0001mB-RC for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:34:27 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r5BuS-0003Uc-90 for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:34:25 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40a5a444c3eso16884195e9.2 for ; Mon, 20 Nov 2023 13:34:14 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id a3-20020a05600c348300b0040a5e69482esm19352313wmq.11.2023.11.20.13.34.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:34:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516053; x=1701120853; 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=WK6ixy1lWz865bxFpaXwaNdgjrdvugwCVDt1SZLip8M=; b=OfYtZD1hwOiGO2WrGPlQ1/u8tmVk9ydezkCv6qz3eIaDsWxT+Jr1Rn8PcThTcdLttr eUS2e4fzYbP5qovO5GzP90cn19YkyE2Fxo2dwVthZwd23OXvqubyNxJW4NIuycs4N2kq LDTCcQ4L3M8ydyrsUkB9+4sRpmMeLg0+A8pbh/7Y5rXK7h/OzK7sK38h+J0rt9HqkmAf HB5s4NTVSoaDvHDCO9VUcrpP81N4FRF4w262PM8ZY/pLpRkFBPL4oWy59E6ML/21zC0L e8BXkV/wk1IeFcLqR23/8wtgYeRIA5WMV0nkMi5eDijW9l72H6xUuqZsifUHSkGGhYJi 6OmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516053; x=1701120853; 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=WK6ixy1lWz865bxFpaXwaNdgjrdvugwCVDt1SZLip8M=; b=RJPSVhLdFqsh3leY7FXfB2Uz935kuMmzEEbJfoUxOHQUZ4EjEKhd1Mg0UnUYc4uCr4 UI5hIN97GXU9iDqqUHpn4zFJSe+ket9aBEMG7hmbsBhP7eZ6dEPlrmyZnc2SF6EpUG9e rDiA7/uJPfi0rlzdNEApa0rbZznnDQdPONw+t8ctnc/TwYlIl8T6bQzQIGYN2ertyXzj wVFhAsUCy5UVXjuQzHbBN9cA69jvjto4rFs6B9tvZQyo0hCV+n4a1EuURBAkRgN0B5kh vaH1fs1QCg07L1BfGmtJeuf2lOzC3sbarLfCiP25W2pQ/Gelj+Wmy789OyXmse+2FPcU 5Cxw== X-Gm-Message-State: AOJu0Yyb/TpF9Gt4MYQlW0fIv17NAYwAX+zr4JDXNkov0d55XnA5Xxne Ik+Hm/onnhREIXSLXfTx2oUlgKSVFfVgPT+gBhY= X-Google-Smtp-Source: AGHT+IEeFFU1fX7WoADlosMCv+szb4F8TKJeBk0nZaKMtXyIxhdIWJOPUQL8I7pzqRwYibVwRa+KDg== X-Received: by 2002:a05:600c:3b05:b0:408:5a1c:9de7 with SMTP id m5-20020a05600c3b0500b004085a1c9de7mr7663702wms.7.1700516053245; Mon, 20 Nov 2023 13:34:13 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu Subject: [PATCH-for-9.0 07/25] memory: Have memory_region_init_rom() handler return a boolean Date: Mon, 20 Nov 2023 22:32:41 +0100 Message-ID: <20231120213301.24349-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516132914100002 Following the example documented since commit e3fe3988d7 ("error: Document Error API usage rules"), have cpu_exec_realizefn() return a boolean indicating whether an error is set or not. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gavin Shan Reviewed-by: Manos Pitsidianakis --- include/exec/memory.h | 4 +++- system/memory.c | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index 788872e4a4..9d9798a527 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1611,8 +1611,10 @@ bool memory_region_init_ram(MemoryRegion *mr, * must be unique within any device * @size: size of the region. * @errp: pointer to Error*, to store an error if it happens. + * + * Return: true on success, else false setting @errp with error. */ -void memory_region_init_rom(MemoryRegion *mr, +bool memory_region_init_rom(MemoryRegion *mr, Object *owner, const char *name, uint64_t size, diff --git a/system/memory.c b/system/memory.c index 4142eac498..2c764947fa 100644 --- a/system/memory.c +++ b/system/memory.c @@ -3620,7 +3620,7 @@ bool memory_region_init_ram(MemoryRegion *mr, return true; } =20 -void memory_region_init_rom(MemoryRegion *mr, +bool memory_region_init_rom(MemoryRegion *mr, Object *owner, const char *name, uint64_t size, @@ -3629,7 +3629,7 @@ void memory_region_init_rom(MemoryRegion *mr, DeviceState *owner_dev; =20 if (!memory_region_init_rom_nomigrate(mr, owner, name, size, errp)) { - return; + return false; } /* This will assert if owner is neither NULL nor a DeviceState. * We only want the owner here for the purposes of defining a @@ -3639,6 +3639,8 @@ void memory_region_init_rom(MemoryRegion *mr, */ owner_dev =3D DEVICE(owner); vmstate_register_ram(mr, owner_dev); + + return true; } =20 void memory_region_init_rom_device(MemoryRegion *mr, --=20 2.41.0 From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516519; cv=none; d=zohomail.com; s=zohoarc; b=V1uYTWybAfZqh3is4/w/v9m7LaLm6+Op8sR0oGSSqnzIPuYKQ/Vy4B1vzY/KN6YTm4g37RL5nfYs1sMd+xSTZxva5AErbp5WS7/A6voY+FsmBMYuVUYzwra8M4Dk2/XyEuOjyX49GD0GHtrU4osxzjC2TKeqbFAjCIN1btXqWa0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516519; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7Db5rVC7IYaMSjFIzhw37gGhb/kt8tXVyhffbU+sslQ=; b=EntCsyhCva5QM+38xcveMpBc5B1aJWTRsv94Mfw14eAExHUL9bUmmGLbsMpHO5l5WQts/aqpS+tOlztrI4Xtily+TlTePZT47Z7jjzJWi51U3lryJcF6/cIZAZbrymGpPzXbGRUOqNN5ASZLDESS1cfnIizZPEhjHfnPiSFpyuM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700516519922747.9245429317368; Mon, 20 Nov 2023 13:41:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5BvV-0003Gu-M4; Mon, 20 Nov 2023 16:35:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5Bub-0001vm-Ke for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:34:36 -0500 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r5BuZ-0003Xx-13 for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:34:33 -0500 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-332cb136335so701285f8f.0 for ; Mon, 20 Nov 2023 13:34:21 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id d1-20020a5d5381000000b0032f7f4d008dsm12298763wrv.20.2023.11.20.13.34.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:34:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516060; x=1701120860; 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=7Db5rVC7IYaMSjFIzhw37gGhb/kt8tXVyhffbU+sslQ=; b=eqWZvHHqCa+ofTZ70YtFMAOY0fivaadnc9qLJjDhm3HkjFL5+MlNTSvtwFqp96aNaK Qq8rryfyVDyjXvBO0D+eVYZJzefV5lcUcaN9DC1YFh96BdXWTkIUF4tk6hFg8cDlja8o ZogAmQfa9BD3FbQqwCsUqQUmOYhTsqO+3ofWpUYlMIJoc6CZsr+sqnW1LcFP8+VVHMNQ xXGDPPgAseDn3wZ/nOWSmJrELLEwSxBcaFbWlh8/a+gVBN4e00cxRULX7cdqnBurmnWv VtmxQSU05l5LJorhE7IMgw0IZ/CW9xf57yhIF3E8CLDmxK/9JuiyItcMEmMl/Wy6Wfmo 140g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516060; x=1701120860; 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=7Db5rVC7IYaMSjFIzhw37gGhb/kt8tXVyhffbU+sslQ=; b=ciu9q+6DmBnu6VCpDfLHy9HEc3x8qXm+mMYG9lOX46h0bRioJrdRgZftkm8GEeFTe0 b+DU+sKMUBZpgRpEh0kthAIfKV76aXiEU+NpX0zKZkwwiJd4nL+khui73Kfjz0axBlO2 ky0a2rWlv+QuHmKCoUG6jwKrj4FaYDKkqJtj42KTlDY20YvoBfsbXQIGFqcpvvvWKUFt aPu+kidoK8mFZZdoLOFpkrkwwn3rO4YgAxKH5SPjTeInu8kqCev9FSYzzK5vHJ8AMUEQ uNZSXDSpbRHZ66RxLnb3ICWVokuT5FASBoBDGy6xuE6YLx8p7nJHlP5y+ufco9yglvO7 kTUw== X-Gm-Message-State: AOJu0YwEKF1sc/xMabZnMerP/ntikbCOwUgU42IALFnjLvNNXVeEGwnJ 6M475+BXC8L/YSXFhcNj8LqRruLcoUF7pzrqRao= X-Google-Smtp-Source: AGHT+IE1dcMRs4ITuaIZlmOY5WENAknRhBAUic/LtnF0eF7kmZeG4TCNmWJoEfpiR+DzZrkd4guCFQ== X-Received: by 2002:a05:6000:1acd:b0:332:c2ae:ca4f with SMTP id i13-20020a0560001acd00b00332c2aeca4fmr4041008wry.46.1700516059836; Mon, 20 Nov 2023 13:34:19 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu Subject: [PATCH-for-9.0 08/25] memory: Have memory_region_init_rom_device_nomigrate() return a boolean Date: Mon, 20 Nov 2023 22:32:42 +0100 Message-ID: <20231120213301.24349-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=philmd@linaro.org; helo=mail-wr1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516520503100007 Following the example documented since commit e3fe3988d7 ("error: Document Error API usage rules"), have cpu_exec_realizefn() return a boolean indicating whether an error is set or not. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gavin Shan Reviewed-by: Peter Xu --- include/exec/memory.h | 4 +++- system/memory.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index 9d9798a527..e2cf3e58de 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1523,8 +1523,10 @@ bool memory_region_init_rom_nomigrate(MemoryRegion *= mr, * must be unique within any device * @size: size of the region. * @errp: pointer to Error*, to store an error if it happens. + * + * Return: true on success, else false setting @errp with error. */ -void memory_region_init_rom_device_nomigrate(MemoryRegion *mr, +bool memory_region_init_rom_device_nomigrate(MemoryRegion *mr, Object *owner, const MemoryRegionOps *ops, void *opaque, diff --git a/system/memory.c b/system/memory.c index 2c764947fa..1cccc4b755 100644 --- a/system/memory.c +++ b/system/memory.c @@ -1743,7 +1743,7 @@ bool memory_region_init_rom_nomigrate(MemoryRegion *m= r, return rv; } =20 -void memory_region_init_rom_device_nomigrate(MemoryRegion *mr, +bool memory_region_init_rom_device_nomigrate(MemoryRegion *mr, Object *owner, const MemoryRegionOps *ops, void *opaque, @@ -1764,7 +1764,9 @@ void memory_region_init_rom_device_nomigrate(MemoryRe= gion *mr, mr->size =3D int128_zero(); object_unparent(OBJECT(mr)); error_propagate(errp, err); + return false; } + return true; } =20 void memory_region_init_iommu(void *_iommu_mr, --=20 2.41.0 From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516440; cv=none; d=zohomail.com; s=zohoarc; b=CclovdiogzkDNbiFasSfn2ey+wLCcK+LhO2zO7WsOZkmOL619kmhe7sy00Q35v2NhN83wDFarePCbP158KcjT3/anQF8SSXwJmS4tydsU/NyjEWL4spStOuGaVFXPL88f0NXy1PxuXuGf5yCJDdQu211zpd2+ZZG0FkTZkBjWKc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516440; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DIex8QjcVHMzUQGfRlZtiLonUpnm8G6I3FWEQ6zYP+4=; b=XsU7oxaKMKEKHN918cdSYy66E29hX21UlLju0Zg/sH7qvxLEmjP4KjeCAD1ATGiuIG19FljVmD3Qu187y+BPEUzSZPQCI/AVMLO7nmDzk0cQWlDiEI6eeCTpEapM36W+LSXBiYAUik4uPyPJ3L9uERCOL7oXwkdgDiLLfuBdp7s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700516440432358.2087611764192; Mon, 20 Nov 2023 13:40:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5Bv8-0002sF-Fa; Mon, 20 Nov 2023 16:35:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5Buc-0001vy-Kt for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:34:35 -0500 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r5Bua-0003ao-Uz for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:34:34 -0500 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2c87903d314so26309481fa.1 for ; Mon, 20 Nov 2023 13:34:27 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id t8-20020a05600c198800b0040531f5c51asm14963797wmq.5.2023.11.20.13.34.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:34:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516066; x=1701120866; 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=DIex8QjcVHMzUQGfRlZtiLonUpnm8G6I3FWEQ6zYP+4=; b=CFXuIQnsSbbPfKf+1+Ki7L0fZ7WmHCfWo2WgW/tfU+ikZbqAJ6m8Oy0Wwjeyl97Gxq SrFoivpcSewRLeH1NXDfI4a6a4H7j2z8buwcrVrBssYP9P+Iim+tb3i4ctSrEeX7H7MJ 8+TfQudvl+vLXkQGPGHfyvAK3HFeIkevnz0UrVrPjbyqAvRkchaNo89VCKWbZmNUg86H dwxMRw5m2vcK6gmgAQI8hBff8ZU9C+ZTCFUfz51T0SM1DjuIxnKwoInxS9wa6nQrbmAp 9bnmQKBPsmQIAVzvO7twOCUpgW0tprSQBO+esxVpjI8t5zRlXjgYpi7AFhq/hEtn2L9J tZoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516066; x=1701120866; 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=DIex8QjcVHMzUQGfRlZtiLonUpnm8G6I3FWEQ6zYP+4=; b=WIJUrNHMUR0pjn8v+ivLKBthhWoJn5DGnWLyKxkuS7V75DnRja1sJJgxHubjP6kfVL d36acLJ+xbRtM/mmAh5n26sVIjvIOMb8pDcrGZYJAjPw9iu4hrQOT6jcy1FMmC1GhyWM zCg2uydFOlTc7ovnBRZPPfaVtp7A6V6X3wogXnMS/HCHmcuj7mlyiQZ15vYNVco3i3RM K+vop5z+L4nNzZWijwdhwCmn/cAGVjG7eYPF03L/uhhlwsaEKocyhhS/yD8iP3MGQker kT14sQqaDh9PoQjG+cPSPcwFlG/xVYXJSIzdEtCJ6IGR91W+6rvUCSj+JUU9Q7LK7arJ 2wxA== X-Gm-Message-State: AOJu0YyayL6CioflM6QLRqHwMkXkj8lW6CpPEODngYY4f4qtb7xNtbDX SNl+a3FVdq74Gg3iFSAAQrcJCcD5pStf/f6XVfM= X-Google-Smtp-Source: AGHT+IEKwyStgC/1RuCdQLc7MNsMAQyl+TNdJH8aV+M6L+dpnANNsaETUJqoKnZMqncm+jtfCfXqiQ== X-Received: by 2002:a05:651c:210:b0:2c0:20e3:990f with SMTP id y16-20020a05651c021000b002c020e3990fmr5660346ljn.10.1700516065839; Mon, 20 Nov 2023 13:34:25 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu Subject: [PATCH-for-9.0 09/25] memory: Simplify memory_region_init_rom_device_nomigrate() calls Date: Mon, 20 Nov 2023 22:32:43 +0100 Message-ID: <20231120213301.24349-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::231; envelope-from=philmd@linaro.org; helo=mail-lj1-x231.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516442252100003 Mechanical change using the following coccinelle script: @@ expression mr, owner, arg3, arg4, arg5, arg6, errp; @@ - memory_region_init_rom_device_nomigrate(mr, owner, arg3, arg4, arg5, ar= g6, &errp); if ( - errp + !memory_region_init_rom_device_nomigrate(mr, owner, arg3, arg4, arg= 5, arg6, &errp) ) { ... return; } and removing the local Error variable. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gavin Shan Reviewed-by: Peter Xu --- system/memory.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/system/memory.c b/system/memory.c index 1cccc4b755..6d1d315d0e 100644 --- a/system/memory.c +++ b/system/memory.c @@ -3654,12 +3654,9 @@ void memory_region_init_rom_device(MemoryRegion *mr, Error **errp) { DeviceState *owner_dev; - Error *err =3D NULL; =20 - memory_region_init_rom_device_nomigrate(mr, owner, ops, opaque, - name, size, &err); - if (err) { - error_propagate(errp, err); + if (!memory_region_init_rom_device_nomigrate(mr, owner, ops, opaque, + name, size, errp)) { return; } /* This will assert if owner is neither NULL nor a DeviceState. --=20 2.41.0 From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516176; cv=none; d=zohomail.com; s=zohoarc; b=RwOUUkobldL02VzdFDS1rnqi6Y+4sCtqwp7Nm0AFsv7Ugrsq0oOXKT41eOk4jGjnDAXsDAMojsGP/kDOfeKx9jBbugW995WRBMKKE1uOraehXoh1XtlAbmW8Y6a/Uz2D9uTlUFPP/tIZoltD8m5CqXgZ0F3cU6GC0Vu2efl20oU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516176; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Fn2fBz5vRqFzHrFrTMPe8dy33731H5v7e4n8L1UYY2M=; b=KcSPwkNd5GPghZygXI62si+kj1+owdqAuZIWmPNJSykyB0eXCe4vznzRygnP2WUVDq8gB+cMvXrIMX3NFZ6CYFHEgLI5XyUiRzv6ASVcp6BszpVi+M9QnmpjLaKsOD9rb0Zb2YdgSbONL1/5Xs6y+hwC7HkUMojcnSBzbtbtyUE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700516176085769.3747951238297; Mon, 20 Nov 2023 13:36:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5Bva-0003l7-Ar; Mon, 20 Nov 2023 16:35:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5Bug-00027w-K8 for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:34:42 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r5Bue-0003bw-Fi for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:34:38 -0500 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-332ca7f95e1so696804f8f.0 for ; Mon, 20 Nov 2023 13:34:35 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id p17-20020a5d48d1000000b003316ad360c1sm11581303wrs.24.2023.11.20.13.34.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:34:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516073; x=1701120873; 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=Fn2fBz5vRqFzHrFrTMPe8dy33731H5v7e4n8L1UYY2M=; b=efL7PO8rq9lBpiZBeOKhRxPOLIM5Hnx72MnzJYcL5tcyQVrjakFesBX1hWb6MwdIYC ONvz5Prcxhy24sYP6Bj3ucWDs96WPtHSGI+1eDRAY7EWdiXn00efMqaX3srtDCRuiJeK RlKR+CoBaSFrGNBCFJUXZwjFZx9dW9W73yg4KkwUzDAADfBUCGM7ByjQ4G1azr9i47YW +HNm3FRQ1SN2r8P0EA13tpwiQQ03oljdnE2s3IXiEMs0qkViV3Kjw2YL5D/Rp8/qWOLB bTZJLGU59iGgecCKfPPNtob/1hqpyyebLnYRsZNF+CwA2csuzP/Gee+yXG9+5w+lnZP1 +EnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516073; x=1701120873; 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=Fn2fBz5vRqFzHrFrTMPe8dy33731H5v7e4n8L1UYY2M=; b=YOy2O0URfHn2Cna+roKUjREs0Ns8Fm0LB+GffVK+572IIVXz7bafhYMuRNqSGdnGBA b1sYu81D5yOM2TV4Hfikslev4onq8WtqUauBNRdpmL3vfpnqjdQITYPUrRLRxsROjhmB X/DC9Hd6/8/qOq7OayP9qLc3S+epw0dyyzzqBuzsIa17kZm9aK2LWONrxaFwjZa+ex3V ssflHQ9jydigKthrb625MWU1NQubFCxEWkygP8VMZMiopOGUS7zM4MdRuFdhIqadlt6t tvYptNbXblU+VYccf+3TC5saIhJ+P9K02pr/LNVjtPTF41uXkgtY6BzrxN2ccKhTqLHC 9Upw== X-Gm-Message-State: AOJu0YwUT4H+HcjlSjMs03JdYkbAij3jORA+zGD9jV0khEkayhavHNwO yV5wMakAdaZYwtK8mKvQE2phulj2T2u7t9Ml2bg= X-Google-Smtp-Source: AGHT+IG0Aezfr6nY5g2si6cT8mAcH6q2jEW+ZAAAook2GU6LNsGqscsh5FvQHKnc1fDayuOPIcWOVg== X-Received: by 2002:adf:e644:0:b0:32f:8214:5ba1 with SMTP id b4-20020adfe644000000b0032f82145ba1mr5772816wrn.45.1700516073513; Mon, 20 Nov 2023 13:34:33 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu Subject: [PATCH-for-9.0 10/25] memory: Have memory_region_init_rom_device() handler return a boolean Date: Mon, 20 Nov 2023 22:32:44 +0100 Message-ID: <20231120213301.24349-11-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516177065100001 Following the example documented since commit e3fe3988d7 ("error: Document Error API usage rules"), have cpu_exec_realizefn() return a boolean indicating whether an error is set or not. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gavin Shan Reviewed-by: Peter Xu --- include/exec/memory.h | 4 +++- system/memory.c | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index e2cf3e58de..92b0c0aa46 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1646,8 +1646,10 @@ bool memory_region_init_rom(MemoryRegion *mr, * must be unique within any device * @size: size of the region. * @errp: pointer to Error*, to store an error if it happens. + * + * Return: true on success, else false setting @errp with error. */ -void memory_region_init_rom_device(MemoryRegion *mr, +bool memory_region_init_rom_device(MemoryRegion *mr, Object *owner, const MemoryRegionOps *ops, void *opaque, diff --git a/system/memory.c b/system/memory.c index 6d1d315d0e..1b10e177f5 100644 --- a/system/memory.c +++ b/system/memory.c @@ -3645,7 +3645,7 @@ bool memory_region_init_rom(MemoryRegion *mr, return true; } =20 -void memory_region_init_rom_device(MemoryRegion *mr, +bool memory_region_init_rom_device(MemoryRegion *mr, Object *owner, const MemoryRegionOps *ops, void *opaque, @@ -3657,7 +3657,7 @@ void memory_region_init_rom_device(MemoryRegion *mr, =20 if (!memory_region_init_rom_device_nomigrate(mr, owner, ops, opaque, name, size, errp)) { - return; + return false; } /* This will assert if owner is neither NULL nor a DeviceState. * We only want the owner here for the purposes of defining a @@ -3667,6 +3667,8 @@ void memory_region_init_rom_device(MemoryRegion *mr, */ owner_dev =3D DEVICE(owner); vmstate_register_ram(mr, owner_dev); + + return true; } =20 /* --=20 2.41.0 From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516446; cv=none; d=zohomail.com; s=zohoarc; b=lvOx4Ysm10YZlXXnvKYnCBMJgvHhTSeg18p+Lj9/V+JgrBkw6C1clVcb/338KEEDGl2eDHD+LyHiLNbpixyxdKLwI1lHHtz4WV2s8K4Pw4/C5Vf3QlQcp+BBiXm8B9oL3Gh90q+I3Ndru6dyzk8MOqxniZ8uZwUumUlJ0dRXdaw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516446; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=srROQw79PZz9736kD+JTLPR9CRLssrTQx2X8yf5dBJc=; b=ml+tak1N9fwcCsc3iCLrwxhjN8XT88UVps6efq53/idTBSPiZoJ+uZ1gI7zs/Wh4p3lFm1dB3NFrbWwNWEy5cs9XIjTGf0tEZnIklkyyWbOhXARvHADXFC0gSzlTpsRFkpcYquCLtZovby/6J7C6ogL6ILvN/c4gPJBD6ILwqQY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700516446053222.48088427171535; Mon, 20 Nov 2023 13:40:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5Bvh-0004UF-9I; Mon, 20 Nov 2023 16:35:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5BvG-0002zn-1O for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:35:18 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r5Bv8-0003qi-NB for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:35:08 -0500 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-40b23aeb9d9so10477815e9.3 for ; Mon, 20 Nov 2023 13:35:06 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id k39-20020a05600c082700b004083729fc14sm18726935wmp.20.2023.11.20.13.34.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:35:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516104; x=1701120904; 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=srROQw79PZz9736kD+JTLPR9CRLssrTQx2X8yf5dBJc=; b=mr7IOdsdVySBB/BP4JNC+BDBPVNVCm23iLT1u1qfvgHWPg8cSpqhAo4cEbdwC5BrYc QUAJuxAoIysb4Seu1JyuRZNK3JrDQ1viRpyqmae1gnXM2eAOgerkoNfq6JZ8iX7Z4ZTP R9tAdKzHX48PYM6ctr705yceQzsTrBHXWe864V98FOOzfTDhB+stUj3rjW0k5+m3v8pc L6mJ9XIc9lHHlzZXoxzoKCROjBFMXDSnnV7tdmJYS2pAFPsGxWVOEG8tX30z8vKCZVPT vRVIrZ5eujv6eMfPrjAa0QHUgMrfnuKrGfMZKenLCve/rg0ZpUUS+t26CIer9z5c3BNJ t6XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516104; x=1701120904; 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=srROQw79PZz9736kD+JTLPR9CRLssrTQx2X8yf5dBJc=; b=nMRAB2VdaWyIGvlCzNXQFbbPEmrcTYLxS9q2LKHJh61bDBBHG5QS3r9lHgp4tg6kb3 AFpxoqjIzUWcX0nj74Ctso5oCvmIVYb6Uj/VveUW2jOBxGi4UCWQMEGAJ7THD6k4Lxro X8YIZYaeyB3ulgjYpaW4tEH9AheNn8XkcJeFUKB+V0X+bqvpLPIxWszs6+uFkhb+uI/l pITCW7hxowObiqQnHhTXMd3u1nmvdYj+bmKZP0Ui2IuGmktUCsdcMJ2AG48udaZGWvml LIZz1CWkkH72sEFnvMC/RNtpTasAaGfsew+6QeRKLF2qnBudGC+KXDOxJndeJREpBqQ5 j2WQ== X-Gm-Message-State: AOJu0YxLCgHx5lG/na09rq0ngWSdI/fUZj/EczzJDIzmid1c3RKKpLFu CQ8MjtLnnhec/H5TOhZVMoVYQvf6K7VAXV+9Mdc= X-Google-Smtp-Source: AGHT+IEIZ+IFo2JacPAN1sUnLp/dq59vh8dOehkHkVB7GrmhKVzG+i0hdb/IjX5jwGgLeEfojsmKgQ== X-Received: by 2002:a05:600c:548c:b0:409:325:e499 with SMTP id iv12-20020a05600c548c00b004090325e499mr7267468wmb.32.1700516104774; Mon, 20 Nov 2023 13:35:04 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu Subject: [PATCH-for-9.0 11/25] memory: Have memory_region_init_resizeable_ram() return a boolean Date: Mon, 20 Nov 2023 22:32:45 +0100 Message-ID: <20231120213301.24349-12-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516448187100003 Following the example documented since commit e3fe3988d7 ("error: Document Error API usage rules"), have cpu_exec_realizefn() return a boolean indicating whether an error is set or not. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gavin Shan Reviewed-by: Peter Xu --- include/exec/memory.h | 4 +++- system/memory.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index 92b0c0aa46..218b35a849 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1342,8 +1342,10 @@ bool memory_region_init_ram_flags_nomigrate(MemoryRe= gion *mr, * * Note that this function does not do anything to cause the data in the * RAM memory region to be migrated; that is the responsibility of the cal= ler. + * + * Return: true on success, else false setting @errp with error. */ -void memory_region_init_resizeable_ram(MemoryRegion *mr, +bool memory_region_init_resizeable_ram(MemoryRegion *mr, Object *owner, const char *name, uint64_t size, diff --git a/system/memory.c b/system/memory.c index 1b10e177f5..f424282526 100644 --- a/system/memory.c +++ b/system/memory.c @@ -1606,7 +1606,7 @@ bool memory_region_init_ram_flags_nomigrate(MemoryReg= ion *mr, return true; } =20 -void memory_region_init_resizeable_ram(MemoryRegion *mr, +bool memory_region_init_resizeable_ram(MemoryRegion *mr, Object *owner, const char *name, uint64_t size, @@ -1627,7 +1627,9 @@ void memory_region_init_resizeable_ram(MemoryRegion *= mr, mr->size =3D int128_zero(); object_unparent(OBJECT(mr)); error_propagate(errp, err); + return false; } + return true; } =20 #ifdef CONFIG_POSIX --=20 2.41.0 From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516151; cv=none; d=zohomail.com; s=zohoarc; b=GV8M64WpA9z4hCUC/sFHPKOlLxDaOqRehovyTHBgtBT107iIAtkhgwUdRyE+9ARHBiVjpw9lp7wfKV1iMdaGWcGEyFmBbBRxOiM72c2mKhgr5WDkscMG4pSUZ1cUPpiOdfp2GelJo4z2fNZeHlCaaZrwDNQbVM44hFChKqYDJuA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516151; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fJ1tGChnS+y/+vqRU30qRdlKveuA7pm7ifWNUTeCbQ8=; b=FlBl+zgegPHXcb5Eipwk4S20uadrB93AE79NbUWXCRUwg+EE8Y08TnSXzTrbWOVDlXw0Xx9N4MGdCohObEUmGxWkjXe8dWh8ATSB+W5tyYIYKXIKGwmxmsqdpKuwZZQfkniQksZjk7fRigPp7MhDD9I2Fap19Tt/9ug2gCbzyBg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700516151464300.1809407273662; Mon, 20 Nov 2023 13:35:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5Bvj-0004mJ-Cm; Mon, 20 Nov 2023 16:35:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5BvR-000387-6u for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:35:26 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r5BvH-0003rz-T8 for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:35:23 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-409299277bbso17767055e9.2 for ; Mon, 20 Nov 2023 13:35:15 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id i11-20020a5d55cb000000b003143867d2ebsm12261018wrw.63.2023.11.20.13.35.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:35:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516114; x=1701120914; 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=fJ1tGChnS+y/+vqRU30qRdlKveuA7pm7ifWNUTeCbQ8=; b=LbtoaCYOXYyLmbo/ul88SjSjs3XWMMEu3I2lWuwfdJBQphPhEAAHhlSJgRJKeujnzr 4FXCGNKKmCE90yLmYWun6eOdTLmSG3D75998b1uNou53O14Ywmz1s6rfESHodNcS3lZU 8UEt8+MexczjZfXo8wf16Af4WuaMeQGUVQHwMOntqfNXR8YszlpPsjd7ncslIcpHj10e mjfdlVO76QuVpGAPLy1nIUaS/JXmCRVFofF0h+DQWB94Geu7Z9UrDXjvs8t628FB1vgM mlD9oDTNRkoBXhv/ZuAWXhoDPv9hHkKOF6XM4Rwk77ZRGKKZSBLzAMsUSQHAH3SwKxKL 6J0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516114; x=1701120914; 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=fJ1tGChnS+y/+vqRU30qRdlKveuA7pm7ifWNUTeCbQ8=; b=A3MqigkomR+ae37wxzBGoxJA13sHXInKEY7W7Ym5IgWM42fQjJXYuLcEHiXM2IpjUp kuipOtqX6O71HpMDvWec7oNEN2oIoKd43k5oKCkr3T6XszkCFxhIFVoEMTjl6NrNNGsd +fXu34vmGaROhMfK40yxt9+q5SHUby+M1TNuA8l1lsRdKIEVleiwkmNan1ADWaNRFqf7 NBIAPLvFwYZW1oGLSHqqfYUakk24JBk8+TUUdnprK63MuBfPj0aN+S6rQLoI8ze048ka LE2GQBezJPWk+AE22wnrACEVNlBGoJ0NEV4i+eEGGwZR35oZs3R+bUajJE1kK0FdsBWZ 45eg== X-Gm-Message-State: AOJu0Yy6wRrR7xwghtJRTrrhzKYJ4jGDOUZ87+Zuko5wS14vs6+OBz6U nNeoKq4rlMdUsSQP3SrdRdZhgFH6WQ2+RRotJOc= X-Google-Smtp-Source: AGHT+IHiyGUFpX5jt4b5PB+6jtg/LgCz8QOHMl5gjegIOzgQkr8+STUiUx9FhC9lOhjhooArH7Zzag== X-Received: by 2002:a5d:464a:0:b0:32d:9a1b:5d79 with SMTP id j10-20020a5d464a000000b0032d9a1b5d79mr5092751wrs.33.1700516113920; Mon, 20 Nov 2023 13:35:13 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu Subject: [PATCH-for-9.0 12/25] memory: Have memory_region_init_ram_from_file() handler return a boolean Date: Mon, 20 Nov 2023 22:32:46 +0100 Message-ID: <20231120213301.24349-13-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516153025100003 Following the example documented since commit e3fe3988d7 ("error: Document Error API usage rules"), have cpu_exec_realizefn() return a boolean indicating whether an error is set or not. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gavin Shan Reviewed-by: Peter Xu --- include/exec/memory.h | 4 +++- system/memory.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index 218b35a849..2034a48544 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1376,8 +1376,10 @@ bool memory_region_init_resizeable_ram(MemoryRegion = *mr, * * Note that this function does not do anything to cause the data in the * RAM memory region to be migrated; that is the responsibility of the cal= ler. + * + * Return: true on success, else false setting @errp with error. */ -void memory_region_init_ram_from_file(MemoryRegion *mr, +bool memory_region_init_ram_from_file(MemoryRegion *mr, Object *owner, const char *name, uint64_t size, diff --git a/system/memory.c b/system/memory.c index f424282526..4a36779ba1 100644 --- a/system/memory.c +++ b/system/memory.c @@ -1633,7 +1633,7 @@ bool memory_region_init_resizeable_ram(MemoryRegion *= mr, } =20 #ifdef CONFIG_POSIX -void memory_region_init_ram_from_file(MemoryRegion *mr, +bool memory_region_init_ram_from_file(MemoryRegion *mr, Object *owner, const char *name, uint64_t size, @@ -1656,7 +1656,9 @@ void memory_region_init_ram_from_file(MemoryRegion *m= r, mr->size =3D int128_zero(); object_unparent(OBJECT(mr)); error_propagate(errp, err); + return false; } + return true; } =20 void memory_region_init_ram_from_fd(MemoryRegion *mr, --=20 2.41.0 From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516200; cv=none; d=zohomail.com; s=zohoarc; b=PPLflRydwaC+gjUmxOsUwiAy+9fsMc4F3muD3fi3Lp3/cz7VFVZ3NynvccViS/SjV7emIN/DSPxHKKFKXC6+mR5oW9wcghxWx662fWxXIrHDhwPLIfsfTuTmDrWIrzFvhDQajv04FnfTY1pnTYFWxa/LJXe9HLceTHYNnYP0pOg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516200; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=M7/Bz5MtMeHpeaKi/bqx4so110l8AvikzKIx6tOl8A8=; b=Pc1SOC+Q0OGpZ89imV9AzXBNb/osMhwpZ4V7RrbOYPZz22vYOf2jVwZfm+WCEuAG/9KwePnWK17/EsebgPxbQIc9s7rHeGqVbJ80fC78A/oLOwIVVNCBcaktMKJiA+lnUy1ikzuMW3bFPOZ0uXzBk6x8/Z61Hr1aULKkexoKBFE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700516200891580.496836641689; Mon, 20 Nov 2023 13:36:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5Bvd-0003vP-VG; Mon, 20 Nov 2023 16:35:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5BvS-00039q-Bz for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:35:27 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r5BvQ-00041t-Lb for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:35:26 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-40b27726369so1511505e9.0 for ; Mon, 20 Nov 2023 13:35:22 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id q12-20020adff50c000000b003296b488961sm12377965wro.31.2023.11.20.13.35.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:35:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516121; x=1701120921; 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=M7/Bz5MtMeHpeaKi/bqx4so110l8AvikzKIx6tOl8A8=; b=nh8AX2v4N0slJSKx3A746qNCDQIZXckN0yTyQJP/BsvILBlGSTi1I8UD9jWHqRlp/X vfB9hDkXJiJsZJ6VvURwGzcplFGnJgkCTgY/5vImDdHR2QXKHyoswm1q1Us8cnoPY3dC 7gVMZTxPFJxYPTe4C55vZtqgS2EXpUHU33LhPnT0W0AtouuZoBHdeSTvAV2mN8Cf1XRE mR35db0paKsnBMi3uShHByY8eTXZH6RxcpLUSnDWRtsOGowSuW5WxaruR4CGuhSwEEf7 lpmyqkIwqrSFqq/c0f5GPMVZA52bZmFbF8elObMXB2FgZDTs5s5/6yFkkJ0GcNy5ttVP KPUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516121; x=1701120921; 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=M7/Bz5MtMeHpeaKi/bqx4so110l8AvikzKIx6tOl8A8=; b=HsDIhUbVImom6CjzZ2OHPW4TBvTmql0JrBBd3+SQfNWcVmbGbnkKukmjd1H33GR9wR L1yzgvXC2fcvNkMWdXihS/WiI5g16iug/kWtaHRDoMlADYxBU2WL7ooUwxup5ec7WHy/ zf/IjJKFiRRFuSR0SJNVfKdqHLaVeoJ4n/GEGptBXAD6dNS3SmyURNhnRwsbihcdfPQL 2tA0lJjqKo4CIfh328xEnwM4fzaRAg20TLDSLctFo/4TXe0ZNr9AZu2IXB6gesCj+Jtv 1CF6oX7BMTpUFPakjaeFvP6m512pln4O+lK+bOTTPbAQvYNBVEsu9uvW0Y94T1yHbXLr aJwA== X-Gm-Message-State: AOJu0YxHrJvTdFlMb46oAoQbgF9Lz33bK9tyQSHt1s8Scn+wr8xrH1L9 Ea5Zi02ZpUZZA/j5sG1ZDkmPe/Z/fLtWIWoL2jI= X-Google-Smtp-Source: AGHT+IGaf4RaD2Uhn0xo8hDQEg/NMe2xKILXRUs6IGBmGf9HM0Hy+38NF3wmAg1VdJxGo0IYaxyevQ== X-Received: by 2002:a5d:5b0d:0:b0:32f:7c6c:aa13 with SMTP id bx13-20020a5d5b0d000000b0032f7c6caa13mr8626935wrb.24.1700516121465; Mon, 20 Nov 2023 13:35:21 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu Subject: [PATCH-for-9.0 13/25] memory: Have memory_region_init_ram_from_fd() handler return a boolean Date: Mon, 20 Nov 2023 22:32:47 +0100 Message-ID: <20231120213301.24349-14-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516201121100001 Following the example documented since commit e3fe3988d7 ("error: Document Error API usage rules"), have cpu_exec_realizefn() return a boolean indicating whether an error is set or not. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gavin Shan Reviewed-by: Peter Xu --- include/exec/memory.h | 4 +++- system/memory.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index 2034a48544..f81b48499a 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1406,8 +1406,10 @@ bool memory_region_init_ram_from_file(MemoryRegion *= mr, * * Note that this function does not do anything to cause the data in the * RAM memory region to be migrated; that is the responsibility of the cal= ler. + * + * Return: true on success, else false setting @errp with error. */ -void memory_region_init_ram_from_fd(MemoryRegion *mr, +bool memory_region_init_ram_from_fd(MemoryRegion *mr, Object *owner, const char *name, uint64_t size, diff --git a/system/memory.c b/system/memory.c index 4a36779ba1..e55fe3dfdf 100644 --- a/system/memory.c +++ b/system/memory.c @@ -1661,7 +1661,7 @@ bool memory_region_init_ram_from_file(MemoryRegion *m= r, return true; } =20 -void memory_region_init_ram_from_fd(MemoryRegion *mr, +bool memory_region_init_ram_from_fd(MemoryRegion *mr, Object *owner, const char *name, uint64_t size, @@ -1682,7 +1682,9 @@ void memory_region_init_ram_from_fd(MemoryRegion *mr, mr->size =3D int128_zero(); object_unparent(OBJECT(mr)); error_propagate(errp, err); + return false; } + return true; } #endif =20 --=20 2.41.0 From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516460; cv=none; d=zohomail.com; s=zohoarc; b=AO4sfxzAoFyF6zgDJbDFkz4J3U0fARmKocEdPmQGGSXpSBP2F+KcN9rSks8dS0kWkS47yIWNd/J5VuT8GZXU+rkb4i1gHIOnG7HoBnZykay8+H7Ltk/8xM1sujOwI/tUHzlXnEH9yAHa9eLQOaeJ/pzpJrZZ/gLY9hC/FCZSHYE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516460; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3MTfYspIRofl2d+GaSi2n8kVPRZkUBrCgY4w5h7qsWI=; b=Yo1Z4p9jkIaXs+hRjmZ0LG9Dz8g+jZOEXffkJnbW+hmII2lVMNoTz2dtjUkKYPg4Ju6JpI+HsHMmDryvtDVg1B/BaadjOZH5cu68kqAtgJw6Txvbn16EAHRPG5Gseiy/tX772ABl1frLpqz/7MW1tG2MhqrU5irOfIMak/kCnkY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170051646028916.24148149221935; Mon, 20 Nov 2023 13:41:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5Bvt-0005xa-NS; Mon, 20 Nov 2023 16:35:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5Bvr-0005dh-I5 for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:35:51 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r5Bvo-0004An-29 for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:35:51 -0500 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-32df66c691dso3101499f8f.3 for ; Mon, 20 Nov 2023 13:35:47 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id v9-20020a5d5909000000b0032f9688ea48sm12319327wrd.10.2023.11.20.13.35.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:35:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516146; x=1701120946; 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=3MTfYspIRofl2d+GaSi2n8kVPRZkUBrCgY4w5h7qsWI=; b=rHCisfklOOZap7cAJbGgmlFoeqKULQ+vmkXMpcqkYm1FMUQgU/uqY8C9XKoF4vJcon EOQClWEzXKJ2tY6eaWz7z/R0M14kcrBKyL/UP5MCMcG80eRYNepDWAI3pLooUsXP4Ay/ CY4lariSQW5YBcH8ebqgWUKiVFq+tYlHoQxeeakHbfLX4xpB6upFB8/GEGOrO7cfUA9b /6+weJHKreC4kXBwZJHu1lVuo2R4Rcn5PPa1RS3Pp7YGoxdvhdJ1bJ2j5i9vSOYFNJ/H ssgKeIliyOmCpHjweuy/hFVETRZOL932UePeKnUuR3AJlvM7eThIZoEO6hAlE+YChpdH 2frg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516146; x=1701120946; 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=3MTfYspIRofl2d+GaSi2n8kVPRZkUBrCgY4w5h7qsWI=; b=FBfKuTjbAZrZi/QpVWv8cP+2YL4VeFoGJBehPqePcu/ndUPBxeaNpC02PMrVhQA8qO 9bM6/Q8wWjoE9R7R54RwnZSzswK/M80TQanwii1yindUUZZo2EKkDZs3q+kYJBE0klPL SgDOR77mGrmJkE9M/CBuE7gLxjUA2KiivVuKKol6Jg/Q3IMN+Ky5GZMN4An0HZS53H6M SyFTjAoWaeuYqjFcDIOn4UI+aoFDWX3WPGg86Bcx3U4o05+EwvYM19J8nbLFtJD2YxLQ MSv5qGBQzEaqJp51EOS08NTI4jrDwzmyC/ll+Nl5DzID7/XWza58fiMS4lTfQka+YiVP IXnA== X-Gm-Message-State: AOJu0YzIYNVPrL6cCslXHxvz7CRvFIuiPeVPL7DAce5roSdlSEV8rXS2 zOldmt8U7t4/cR4X8kznp4WnnJZ4bvYmpKV+rk8= X-Google-Smtp-Source: AGHT+IHJw4br/gAEOYJKCgGb2gTZzW99Smd0qhk85joM8RLaXzPatxg5y5ZLale/3WnFXBjccrYtZg== X-Received: by 2002:a5d:4012:0:b0:32d:8855:138d with SMTP id n18-20020a5d4012000000b0032d8855138dmr5256601wrp.66.1700516146517; Mon, 20 Nov 2023 13:35:46 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu Subject: [PATCH-for-9.0 14/25] backends: Use g_autofree in HostMemoryBackendClass::alloc() handlers Date: Mon, 20 Nov 2023 22:32:48 +0100 Message-ID: <20231120213301.24349-15-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=philmd@linaro.org; helo=mail-wr1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516462299100003 In preparation of having HostMemoryBackendClass::alloc() handlers return a boolean, have them use g_autofree. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gavin Shan Reviewed-by: Manos Pitsidianakis --- backends/hostmem-epc.c | 3 +-- backends/hostmem-file.c | 3 +-- backends/hostmem-memfd.c | 3 +-- backends/hostmem-ram.c | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/backends/hostmem-epc.c b/backends/hostmem-epc.c index 4e162d6789..3ceb079f9e 100644 --- a/backends/hostmem-epc.c +++ b/backends/hostmem-epc.c @@ -20,8 +20,8 @@ static void sgx_epc_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) { + g_autofree char *name =3D NULL; uint32_t ram_flags; - char *name; int fd; =20 if (!backend->size) { @@ -41,7 +41,6 @@ sgx_epc_backend_memory_alloc(HostMemoryBackend *backend, = Error **errp) memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend), name, backend->size, ram_flags, fd, 0, errp); - g_free(name); } =20 static void sgx_epc_backend_instance_init(Object *obj) diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index 361d4a8103..fe8c481f8f 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -44,8 +44,8 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Err= or **errp) object_get_typename(OBJECT(backend))); #else HostMemoryBackendFile *fb =3D MEMORY_BACKEND_FILE(backend); + g_autofree gchar *name =3D NULL; uint32_t ram_flags; - gchar *name; =20 if (!backend->size) { error_setg(errp, "can't create backend with size 0"); @@ -89,7 +89,6 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Err= or **errp) memory_region_init_ram_from_file(&backend->mr, OBJECT(backend), name, backend->size, fb->align, ram_flags, fb->mem_path, fb->offset, errp); - g_free(name); #endif } =20 diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c index 3fc85c3db8..db28ab5a56 100644 --- a/backends/hostmem-memfd.c +++ b/backends/hostmem-memfd.c @@ -35,8 +35,8 @@ static void memfd_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) { HostMemoryBackendMemfd *m =3D MEMORY_BACKEND_MEMFD(backend); + g_autofree char *name =3D NULL; uint32_t ram_flags; - char *name; int fd; =20 if (!backend->size) { @@ -57,7 +57,6 @@ memfd_backend_memory_alloc(HostMemoryBackend *backend, Er= ror **errp) ram_flags |=3D backend->reserve ? 0 : RAM_NORESERVE; memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend), name, backend->size, ram_flags, fd, 0, errp); - g_free(name); } =20 static bool diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c index b8e55cdbd0..0a670fc22a 100644 --- a/backends/hostmem-ram.c +++ b/backends/hostmem-ram.c @@ -19,8 +19,8 @@ static void ram_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) { + g_autofree char *name =3D NULL; uint32_t ram_flags; - char *name; =20 if (!backend->size) { error_setg(errp, "can't create backend with size 0"); @@ -32,7 +32,6 @@ ram_backend_memory_alloc(HostMemoryBackend *backend, Erro= r **errp) ram_flags |=3D backend->reserve ? 0 : RAM_NORESERVE; memory_region_init_ram_flags_nomigrate(&backend->mr, OBJECT(backend), = name, backend->size, ram_flags, errp); - g_free(name); } =20 static void --=20 2.41.0 From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516183; cv=none; d=zohomail.com; s=zohoarc; b=iFxUhu9AdYThVZTTEc+uKXdcQ2xKsYXsWF7hzGJKAyjHDBqkABWUJYgyEtCzSTHIl8No2J6Yiw2UqPD7O9HRYIvJewe5MLTJx8HhPZ1Rb/UqxxigccLgQIamBO0tfaW/FMCJG/YxHMmseV+v2LbUWdtsMcix9AP6T479JzKuv9U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516183; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bJsPtTyJ8AvLk2JmJxbXP+WyZeZtfo9yWUZ/XM9f5N8=; b=jWPU2QbEhhJRGFifuU9XT3xgElEcB6fGzzAHnoKcu1Wu8JkOhzKXWE/8XovRR7uBjDZLsktXSMjB4ikloek4DuItGTt7ifHkI2FrhsMV62lqKPlesysKggItEf5a4jIk4c9fRRx8XsnumKZal8Td0lBqkXCGShSbse6XbqJgAU8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700516183861799.2596381918574; Mon, 20 Nov 2023 13:36:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5Bw5-0006oD-5G; Mon, 20 Nov 2023 16:36:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5Bvy-0006eM-7a for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:35:58 -0500 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 1r5Bvv-0004DL-00 for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:35:57 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-40a48775c58so21420005e9.3 for ; Mon, 20 Nov 2023 13:35:54 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id f6-20020a7bc8c6000000b004030e8ff964sm18673462wml.34.2023.11.20.13.35.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:35:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516153; x=1701120953; 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=bJsPtTyJ8AvLk2JmJxbXP+WyZeZtfo9yWUZ/XM9f5N8=; b=oP3wfeLpB3ZBWZDclWN2uV7Jb7+65wnS6ZRtM70NnmA6jvOmmh+hNu9lQjlkACUq3t HZ5xuvrismjZpv60fL1WnsVa5DKBVPy+ReueWf/13WLk/zEBAfo9iqfScxEXFZue89t5 81xlUPxyZByyVIR2qKcTdgR+5pFGoVQ17mcTS7Ma0Fv/xclqa/tYVv6BcTt2cUdDHvYU WQFnrH6J/lrGHpNQzdNwXwSaZsIXmOnExjS+CTeoYx0OyTUKOTm+rYIQmelsVI4l9864 9pyWaD53qSSfJvKqUO2vKcwZlbJIbgeYMNLiFzvzsHmF+MzC2yWLsIqj6E9wZohSb15u WmqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516153; x=1701120953; 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=bJsPtTyJ8AvLk2JmJxbXP+WyZeZtfo9yWUZ/XM9f5N8=; b=mvqtNzHF5SrIQmsDaL8si8QNSeV9x5UcVdFdblFd9rM9usr6ChucRwjFgWd+gcWxjz oSWl1s/g7S6dcfkQDJKy6MkPuN81XhuZFAgnwdGRaRMTFJCSvlsGPEah+UDdUlP2S+sI pOTb69ORgJmQq68Vxb2nWgivDBu2nxvW+4e9kl+nziuvkn8L2YKPRxV4DVkCMd/6D0pL /Vxo/cAy4vhPZNNz6lSuZLmN2MEwjTUDqDj2duHXlk0tkAH/KWuNU1aQivakQwdewj2u 6dKw+IjbABb4CZTGoz/nyzWVBB4miqCRZbyOvv07W25tsKAHSbozfFG3qrfWfZvgIsTJ 5zeQ== X-Gm-Message-State: AOJu0YyXiUByhwl6FqUsUTL36H5WjO+ZvSFJTLcyohCQtDC6oG7KYHFl +hJJfm4L7LYrTdlcnZZ0bmxNpnCr464284xgUtg= X-Google-Smtp-Source: AGHT+IGaU7Di37CDPM7YHvwmjuIz3SZqWetIjdoyZIOCCdwwPPXAThpDcu0+ZMAY6J0jgcTGBkPzlA== X-Received: by 2002:a05:600c:3143:b0:406:44e6:c00d with SMTP id h3-20020a05600c314300b0040644e6c00dmr7281481wmo.2.1700516153074; Mon, 20 Nov 2023 13:35:53 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu Subject: [PATCH-for-9.0 15/25] backends: Simplify host_memory_backend_memory_complete() Date: Mon, 20 Nov 2023 22:32:49 +0100 Message-ID: <20231120213301.24349-16-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516185377100001 Return early if bc->alloc is NULL. De-indent the if() ladder. Note, this avoids a pointless call to error_propagate() with errp=3DNULL at the 'out:' label. Change trivial when reviewed with 'git-diff --ignore-all-space'. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gavin Shan Reviewed-by: Manos Pitsidianakis --- backends/hostmem.c | 133 +++++++++++++++++++++++---------------------- 1 file changed, 67 insertions(+), 66 deletions(-) diff --git a/backends/hostmem.c b/backends/hostmem.c index 747e7838c0..1723c19165 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -328,83 +328,84 @@ host_memory_backend_memory_complete(UserCreatable *uc= , Error **errp) void *ptr; uint64_t sz; =20 - if (bc->alloc) { - bc->alloc(backend, &local_err); - if (local_err) { - goto out; - } + if (!bc->alloc) { + return; + } + bc->alloc(backend, &local_err); + if (local_err) { + goto out; + } =20 - ptr =3D memory_region_get_ram_ptr(&backend->mr); - sz =3D memory_region_size(&backend->mr); + ptr =3D memory_region_get_ram_ptr(&backend->mr); + sz =3D memory_region_size(&backend->mr); =20 - if (backend->merge) { - qemu_madvise(ptr, sz, QEMU_MADV_MERGEABLE); - } - if (!backend->dump) { - qemu_madvise(ptr, sz, QEMU_MADV_DONTDUMP); - } + if (backend->merge) { + qemu_madvise(ptr, sz, QEMU_MADV_MERGEABLE); + } + if (!backend->dump) { + qemu_madvise(ptr, sz, QEMU_MADV_DONTDUMP); + } #ifdef CONFIG_NUMA - unsigned long lastbit =3D find_last_bit(backend->host_nodes, MAX_N= ODES); - /* lastbit =3D=3D MAX_NODES means maxnode =3D 0 */ - unsigned long maxnode =3D (lastbit + 1) % (MAX_NODES + 1); - /* ensure policy won't be ignored in case memory is preallocated - * before mbind(). note: MPOL_MF_STRICT is ignored on hugepages so - * this doesn't catch hugepage case. */ - unsigned flags =3D MPOL_MF_STRICT | MPOL_MF_MOVE; - int mode =3D backend->policy; + unsigned long lastbit =3D find_last_bit(backend->host_nodes, MAX_NODES= ); + /* lastbit =3D=3D MAX_NODES means maxnode =3D 0 */ + unsigned long maxnode =3D (lastbit + 1) % (MAX_NODES + 1); + /* ensure policy won't be ignored in case memory is preallocated + * before mbind(). note: MPOL_MF_STRICT is ignored on hugepages so + * this doesn't catch hugepage case. */ + unsigned flags =3D MPOL_MF_STRICT | MPOL_MF_MOVE; + int mode =3D backend->policy; =20 - /* check for invalid host-nodes and policies and give more verbose - * error messages than mbind(). */ - if (maxnode && backend->policy =3D=3D MPOL_DEFAULT) { - error_setg(errp, "host-nodes must be empty for policy default," - " or you should explicitly specify a policy other" - " than default"); - return; - } else if (maxnode =3D=3D 0 && backend->policy !=3D MPOL_DEFAULT) { - error_setg(errp, "host-nodes must be set for policy %s", - HostMemPolicy_str(backend->policy)); - return; - } + /* check for invalid host-nodes and policies and give more verbose + * error messages than mbind(). */ + if (maxnode && backend->policy =3D=3D MPOL_DEFAULT) { + error_setg(errp, "host-nodes must be empty for policy default," + " or you should explicitly specify a policy other" + " than default"); + return; + } else if (maxnode =3D=3D 0 && backend->policy !=3D MPOL_DEFAULT) { + error_setg(errp, "host-nodes must be set for policy %s", + HostMemPolicy_str(backend->policy)); + return; + } =20 - /* We can have up to MAX_NODES nodes, but we need to pass maxnode+1 - * as argument to mbind() due to an old Linux bug (feature?) which - * cuts off the last specified node. This means backend->host_nodes - * must have MAX_NODES+1 bits available. - */ - assert(sizeof(backend->host_nodes) >=3D - BITS_TO_LONGS(MAX_NODES + 1) * sizeof(unsigned long)); - assert(maxnode <=3D MAX_NODES); + /* We can have up to MAX_NODES nodes, but we need to pass maxnode+1 + * as argument to mbind() due to an old Linux bug (feature?) which + * cuts off the last specified node. This means backend->host_nodes + * must have MAX_NODES+1 bits available. + */ + assert(sizeof(backend->host_nodes) >=3D + BITS_TO_LONGS(MAX_NODES + 1) * sizeof(unsigned long)); + assert(maxnode <=3D MAX_NODES); =20 #ifdef HAVE_NUMA_HAS_PREFERRED_MANY - if (mode =3D=3D MPOL_PREFERRED && numa_has_preferred_many() > 0) { - /* - * Replace with MPOL_PREFERRED_MANY otherwise the mbind() below - * silently picks the first node. - */ - mode =3D MPOL_PREFERRED_MANY; - } + if (mode =3D=3D MPOL_PREFERRED && numa_has_preferred_many() > 0) { + /* + * Replace with MPOL_PREFERRED_MANY otherwise the mbind() below + * silently picks the first node. + */ + mode =3D MPOL_PREFERRED_MANY; + } #endif =20 - if (maxnode && - mbind(ptr, sz, mode, backend->host_nodes, maxnode + 1, flags))= { - if (backend->policy !=3D MPOL_DEFAULT || errno !=3D ENOSYS) { - error_setg_errno(errp, errno, - "cannot bind memory to host NUMA nodes"); - return; - } + if (maxnode && + mbind(ptr, sz, mode, backend->host_nodes, maxnode + 1, flags)) { + if (backend->policy !=3D MPOL_DEFAULT || errno !=3D ENOSYS) { + error_setg_errno(errp, errno, + "cannot bind memory to host NUMA nodes"); + return; } + } #endif - /* Preallocate memory after the NUMA policy has been instantiated. - * This is necessary to guarantee memory is allocated with - * specified NUMA policy in place. - */ - if (backend->prealloc) { - qemu_prealloc_mem(memory_region_get_fd(&backend->mr), ptr, sz, - backend->prealloc_threads, - backend->prealloc_context, &local_err); - if (local_err) { - goto out; - } + /* Preallocate memory after the NUMA policy has been instantiated. + * This is necessary to guarantee memory is allocated with + * specified NUMA policy in place. + */ + if (backend->prealloc) { + qemu_prealloc_mem(memory_region_get_fd(&backend->mr), ptr, sz, + backend->prealloc_threads, + backend->prealloc_context, &local_err); + if (local_err) { + goto out; } } out: --=20 2.41.0 From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516240; cv=none; d=zohomail.com; s=zohoarc; b=Nch0IXCmglE9muOCZBGd7LkJl50WP3X4K9WQ8++RpJNcqvsJrrRNLRnM+dEuBVesmDxzKMSYZUkVKJkwJoAT/y69S422IUY2I/L/KS6BQrQVk3bGAFCxlWQub7sfntOi9LAFO+9dODd50071a0AzxmUljriw8HVbhrDaQbhTGtU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516240; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0dlpM+IXDv7rbEXsFyB/MgTxRgvBWVHr070iMACWqDk=; b=D5CyY5XZNgr/ulsIJAZi+4iSGmUVdPL+bmqwUku27NbhvIlRgt/UEqaOR10ymKe3B31sLgeHWhXZuwBNgioDQX42DMrL+nlmK0DeoEm+j6wV8K2GdnOefyjHPo0xfjCc3u+wP79Y2g4Rl1m+Bx3DTSkJeAO9tGvOL8kUUsQ8uUA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700516240159142.45048781530602; Mon, 20 Nov 2023 13:37:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5BwP-0007G9-0f; Mon, 20 Nov 2023 16:36:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5Bw8-00071A-UI for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:36:09 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r5Bw6-0004EW-NW for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:36:08 -0500 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-32d81864e3fso3099062f8f.2 for ; Mon, 20 Nov 2023 13:36:05 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id df10-20020a5d5b8a000000b00331a55d3875sm8189914wrb.38.2023.11.20.13.35.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:36:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516164; x=1701120964; 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=0dlpM+IXDv7rbEXsFyB/MgTxRgvBWVHr070iMACWqDk=; b=K81jkTwoupQ1E9CW6VNTe6j4cTqznb8xldikM3B8ZleWUlwEVd0eNwcHJScPH//qX1 9hcdmSgQUarTc4KUWl4LVyvfElTBsfIfboyPnfW09r2hUMe2LiURleWjHWJYD2Wq50OX DPzYb+C8C2E42IcPJvAiPLxDnUsD3M229Kgcezd5tTfZhhBMC5sAqKY3HohrlsJSxKR9 cFnfcKmJQ99nBmuRxkdXw7cvgaxRWs2L/G4UbRj49io7o3Zebo5b4TvitTbmt5Xw/tS6 R2f9AQfhSsiQygDgX95Zu9XIw/XmG8qbtnTl8DKJltFE5hTAF0L3MJ+wlrhuaCsaU9ot htRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516164; x=1701120964; 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=0dlpM+IXDv7rbEXsFyB/MgTxRgvBWVHr070iMACWqDk=; b=sqGe6m01vByv7Oym1+cxoNOUMEjuLmvpZ6O/oIBw2kbBlXrrbqUfgZIj58zhq9LgSM I+XZ+AqEYuDaDZMW63Wx6FCthRiooo1Nrjo5pAKsGPPys4+kNYNgKWib2mT6ycVSHJfF SP7wzIONMqyzhhr4o8uOCJBnZQJd5ImJc9leewD4ptXi8NNqpWBn3RuC0van4iz0svTB mPMeVxDla4Y9aFWkM/BSK7ATcax1Qb6E+XcjEjg50aoVutM39nAPgkg10qNnj0R8ABKP 5iVd2fOkAMVWwjR5LlX9/RjsFSSstibg5ZydeRcjxRwk+/KN6I0S6R8QmC8E1GZd5YCT m3Cw== X-Gm-Message-State: AOJu0Yy7MWKm79Xbb2RUy6LrIrwDwUC1pRPqLaqqT1fPcJ5KM+qaTbs4 B4sHQJgfUqmQF/ecmkTV90tcZzXKo4tGQxwETcM= X-Google-Smtp-Source: AGHT+IFKWWsEUaV+GlawzfgfQFbqDi3cRyBFKHW1tYfi2uX7aM39x3KOrU7IYYjmKoPQP6ycH3BlJg== X-Received: by 2002:a5d:5b83:0:b0:32f:b4ab:8cb with SMTP id df3-20020a5d5b83000000b0032fb4ab08cbmr4544478wrb.34.1700516163652; Mon, 20 Nov 2023 13:36:03 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu Subject: [PATCH-for-9.0 16/25] backends: Have HostMemoryBackendClass::alloc() handler return a boolean Date: Mon, 20 Nov 2023 22:32:50 +0100 Message-ID: <20231120213301.24349-17-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_FILL_THIS_FORM_SHORT=0.01, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516241406100003 Following the example documented since commit e3fe3988d7 ("error: Document Error API usage rules"), have cpu_exec_realizefn() return a boolean indicating whether an error is set or not. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gavin Shan Reviewed-by: Manos Pitsidianakis --- include/sysemu/hostmem.h | 10 +++++++++- backends/hostmem-epc.c | 11 +++++------ backends/hostmem-file.c | 19 ++++++++++--------- backends/hostmem-memfd.c | 10 +++++----- backends/hostmem-ram.c | 9 +++++---- backends/hostmem.c | 5 ++--- 6 files changed, 36 insertions(+), 28 deletions(-) diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h index 39326f1d4f..0e411aaa29 100644 --- a/include/sysemu/hostmem.h +++ b/include/sysemu/hostmem.h @@ -47,7 +47,15 @@ OBJECT_DECLARE_TYPE(HostMemoryBackend, HostMemoryBackend= Class, struct HostMemoryBackendClass { ObjectClass parent_class; =20 - void (*alloc)(HostMemoryBackend *backend, Error **errp); + /** + * alloc: Allocate memory from backend. + * + * @backend: the #HostMemoryBackend. + * @errp: pointer to Error*, to store an error if it happens. + * + * Return: true on success, else false setting @errp with error. + */ + bool (*alloc)(HostMemoryBackend *backend, Error **errp); }; =20 /** diff --git a/backends/hostmem-epc.c b/backends/hostmem-epc.c index 3ceb079f9e..735e2e1cf8 100644 --- a/backends/hostmem-epc.c +++ b/backends/hostmem-epc.c @@ -17,7 +17,7 @@ #include "sysemu/hostmem.h" #include "hw/i386/hostmem-epc.h" =20 -static void +static bool sgx_epc_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) { g_autofree char *name =3D NULL; @@ -26,21 +26,20 @@ sgx_epc_backend_memory_alloc(HostMemoryBackend *backend= , Error **errp) =20 if (!backend->size) { error_setg(errp, "can't create backend with size 0"); - return; + return false; } =20 fd =3D qemu_open_old("/dev/sgx_vepc", O_RDWR); if (fd < 0) { error_setg_errno(errp, errno, "failed to open /dev/sgx_vepc to alloc SGX EPC"); - return; + return false; } =20 name =3D object_get_canonical_path(OBJECT(backend)); ram_flags =3D (backend->share ? RAM_SHARED : 0) | RAM_PROTECTED; - memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend), - name, backend->size, ram_flags, - fd, 0, errp); + return memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend), n= ame, + backend->size, ram_flags, fd, 0,= errp); } =20 static void sgx_epc_backend_instance_init(Object *obj) diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index fe8c481f8f..ac3e433cbd 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -36,12 +36,13 @@ struct HostMemoryBackendFile { OnOffAuto rom; }; =20 -static void +static bool file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) { #ifndef CONFIG_POSIX error_setg(errp, "backend '%s' not supported on this host", object_get_typename(OBJECT(backend))); + return false; #else HostMemoryBackendFile *fb =3D MEMORY_BACKEND_FILE(backend); g_autofree gchar *name =3D NULL; @@ -49,11 +50,11 @@ file_backend_memory_alloc(HostMemoryBackend *backend, E= rror **errp) =20 if (!backend->size) { error_setg(errp, "can't create backend with size 0"); - return; + return false; } if (!fb->mem_path) { error_setg(errp, "mem-path property not set"); - return; + return false; } =20 switch (fb->rom) { @@ -65,18 +66,18 @@ file_backend_memory_alloc(HostMemoryBackend *backend, E= rror **errp) if (!fb->readonly) { error_setg(errp, "property 'rom' =3D 'on' is not supported wit= h" " 'readonly' =3D 'off'"); - return; + return false; } break; case ON_OFF_AUTO_OFF: if (fb->readonly && backend->share) { error_setg(errp, "property 'rom' =3D 'off' is incompatible wit= h" " 'readonly' =3D 'on' and 'share' =3D 'on'"); - return; + return false; } break; default: - assert(false); + g_assert_not_reached(); } =20 name =3D host_memory_backend_get_name(backend); @@ -86,9 +87,9 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Err= or **errp) ram_flags |=3D backend->reserve ? 0 : RAM_NORESERVE; ram_flags |=3D fb->is_pmem ? RAM_PMEM : 0; ram_flags |=3D RAM_NAMED_FILE; - memory_region_init_ram_from_file(&backend->mr, OBJECT(backend), name, - backend->size, fb->align, ram_flags, - fb->mem_path, fb->offset, errp); + return memory_region_init_ram_from_file(&backend->mr, OBJECT(backend),= name, + backend->size, fb->align, ram_= flags, + fb->mem_path, fb->offset, errp= ); #endif } =20 diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c index db28ab5a56..3923ea9364 100644 --- a/backends/hostmem-memfd.c +++ b/backends/hostmem-memfd.c @@ -31,7 +31,7 @@ struct HostMemoryBackendMemfd { bool seal; }; =20 -static void +static bool memfd_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) { HostMemoryBackendMemfd *m =3D MEMORY_BACKEND_MEMFD(backend); @@ -41,7 +41,7 @@ memfd_backend_memory_alloc(HostMemoryBackend *backend, Er= ror **errp) =20 if (!backend->size) { error_setg(errp, "can't create backend with size 0"); - return; + return false; } =20 fd =3D qemu_memfd_create(TYPE_MEMORY_BACKEND_MEMFD, backend->size, @@ -49,14 +49,14 @@ memfd_backend_memory_alloc(HostMemoryBackend *backend, = Error **errp) F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL : 0, errp); if (fd =3D=3D -1) { - return; + return false; } =20 name =3D host_memory_backend_get_name(backend); ram_flags =3D backend->share ? RAM_SHARED : 0; ram_flags |=3D backend->reserve ? 0 : RAM_NORESERVE; - memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend), name, - backend->size, ram_flags, fd, 0, errp); + return memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend), n= ame, + backend->size, ram_flags, fd, 0,= errp); } =20 static bool diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c index 0a670fc22a..d121249f0f 100644 --- a/backends/hostmem-ram.c +++ b/backends/hostmem-ram.c @@ -16,7 +16,7 @@ #include "qemu/module.h" #include "qom/object_interfaces.h" =20 -static void +static bool ram_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) { g_autofree char *name =3D NULL; @@ -24,14 +24,15 @@ ram_backend_memory_alloc(HostMemoryBackend *backend, Er= ror **errp) =20 if (!backend->size) { error_setg(errp, "can't create backend with size 0"); - return; + return false; } =20 name =3D host_memory_backend_get_name(backend); ram_flags =3D backend->share ? RAM_SHARED : 0; ram_flags |=3D backend->reserve ? 0 : RAM_NORESERVE; - memory_region_init_ram_flags_nomigrate(&backend->mr, OBJECT(backend), = name, - backend->size, ram_flags, errp); + return memory_region_init_ram_flags_nomigrate(&backend->mr, OBJECT(bac= kend), + name, backend->size, + ram_flags, errp); } =20 static void diff --git a/backends/hostmem.c b/backends/hostmem.c index 1723c19165..3f8eb936d7 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -331,9 +331,8 @@ host_memory_backend_memory_complete(UserCreatable *uc, = Error **errp) if (!bc->alloc) { return; } - bc->alloc(backend, &local_err); - if (local_err) { - goto out; + if (!bc->alloc(backend, errp)) { + return; } =20 ptr =3D memory_region_get_ram_ptr(&backend->mr); --=20 2.41.0 From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516502; cv=none; d=zohomail.com; s=zohoarc; b=PJBp1Ez3VDdoEX4nuvYwpKRRwwTGvpkei/ERfL9MkJini0jGif0CCsb5oV4VEyfuI7JeOK/OrlVonG/bMaSHJrtfCTkxPev/qc92NLKBDlZEUCx42DgQNnDd1VcT8MPsfWh7zUSFGRVQaeyF7/1Bu6Fa2oYBIS0kSrZzRltt8/4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516502; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hOzYF2dzBcuolmQzvvXqLCwUi3E1rapeqqZCPtHm/3E=; b=aLiNUB8mwynjo3JSyG9s8WC7l3B/zcN4abUoSAXy5Vb31de93wwtgp1APSyqqBsRmzx4gv0bIHWJrhhycrO6uIoA1UBFCcisGgX3C/wB/C3N4W2vVfyxYYpfnCZJc9dQkWocAbsdlvQ8vkMAUiJPXMPO7PhtCI7GyXhiA2LSbs8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700516502325180.60225000534876; Mon, 20 Nov 2023 13:41:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5Bwa-0007xg-BK; Mon, 20 Nov 2023 16:36:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5BwI-0007Cg-TJ for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:36:20 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r5BwD-0004FT-Fn for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:36:14 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-40842752c6eso20368165e9.1 for ; Mon, 20 Nov 2023 13:36:11 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id f6-20020a7bc8c6000000b004030e8ff964sm18674108wml.34.2023.11.20.13.36.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:36:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516170; x=1701120970; 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=hOzYF2dzBcuolmQzvvXqLCwUi3E1rapeqqZCPtHm/3E=; b=nU4SQtss+A5RcGRDcXNWpwmn6Q4k2ciTRipTM7zrxgPsJgPTSwiol5AjjsqAf4MnDn y3fZpZ82ayPHe8WFsz981bajPQzZWKWMGJ9apQeNY5f7d2JeCGgsxUzXsMkSTy8UYntf ng6xE7aDzFpsCMs/BrDiGq75cnPr7Mi9LsYNu4BJU+8YYp25abkKwNhdT+Pcnge6lWkd wxSYevVHiWP53YD8wy+8GVm7PY+cs8hMRaGmBxrNzcPy61Ip0hvsU3I9AoX1Tes3KLqE 3sUWPgSlub0xwfpcowUZsLS7XSvnbOVyHGJWAnjbpy5KPBp6uV7/mHE14v9EVsDNiXOg wxMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516170; x=1701120970; 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=hOzYF2dzBcuolmQzvvXqLCwUi3E1rapeqqZCPtHm/3E=; b=bOCGVgf6Rh32ITIC7AUyG3IHbw2iapiFa2P2wFV5hB3c/0e6yPUIeCiM4R9GT3vo1S BjJVV8aMEyc+HKNCh2JjUt5qh56tkZ6Vmi+7FkfpzjmdZqHEZBq3BUvMj39tg/9jxvez CtkZjua44emZJF4QnH3fm6NnXV0Q2QYfB+93MYD7ePvO/Fh8YDNne1Bdoo0aIawn1mNb JiJ7ltkpstZzCQgruin776BwYEp1dH63ET4ZZ0G2BGhn2HzQPv9H/UdUKKht5vmsPM74 q3seJGAKnO8UEE+Uvu+wsl+e1sbZw1YfrIwUtu3U2AtqW9InULdIaDuGurovYOYyFT48 JqEg== X-Gm-Message-State: AOJu0YyYDTdh46QXQx7JYFjRtd185qXtc6lR8xttX8b4pd18N6ML6TaR 8im1S3UKIbd6AYgw4U2jt4SSIZokiGmTjeOVfKA= X-Google-Smtp-Source: AGHT+IGeJlR/HkVqyUUEWHAjFyqHC1WcCYFo5ZDZidCF/ISCKiyZ0Bi5axUFaKzlaf91QClbY/DD9A== X-Received: by 2002:a05:600c:1c96:b0:405:336b:8307 with SMTP id k22-20020a05600c1c9600b00405336b8307mr7178838wms.7.1700516170346; Mon, 20 Nov 2023 13:36:10 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu Subject: [PATCH-for-9.0 17/25] backends: Reduce variable scope in host_memory_backend_memory_complete Date: Mon, 20 Nov 2023 22:32:51 +0100 Message-ID: <20231120213301.24349-18-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516504558100005 Reduce the &local_err variable use and remove the 'out:' label. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gavin Shan Reviewed-by: Manos Pitsidianakis --- backends/hostmem.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backends/hostmem.c b/backends/hostmem.c index 3f8eb936d7..1b0043a0d9 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -324,7 +324,6 @@ host_memory_backend_memory_complete(UserCreatable *uc, = Error **errp) { HostMemoryBackend *backend =3D MEMORY_BACKEND(uc); HostMemoryBackendClass *bc =3D MEMORY_BACKEND_GET_CLASS(uc); - Error *local_err =3D NULL; void *ptr; uint64_t sz; =20 @@ -400,15 +399,16 @@ host_memory_backend_memory_complete(UserCreatable *uc= , Error **errp) * specified NUMA policy in place. */ if (backend->prealloc) { + Error *local_err =3D NULL; + qemu_prealloc_mem(memory_region_get_fd(&backend->mr), ptr, sz, backend->prealloc_threads, backend->prealloc_context, &local_err); if (local_err) { - goto out; + error_propagate(errp, local_err); + return; } } -out: - error_propagate(errp, local_err); } =20 static bool --=20 2.41.0 From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516454; cv=none; d=zohomail.com; s=zohoarc; b=jauv/HK2+LxbKj3ReENN1YHERXoeDnkNlHMnkoJC6kFEi0jPmuqK9cMRClI9oQ4mIw+iUnFWwa25ityj8cSsn3j7K65KAP9uEenGQeyxnotq069jBkk+STVnG9wS9oAJ0l0hNsRyflKlqzKmrS/fG0+1kJiovfwBgJXViIXZh8E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516454; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JQm9clEeaAsqfkXJ+UfY2CLg9Wh2rq/brUmgmj9iQWU=; b=UeySlVltm4Ax3uVjaxdXrewqdF93xxrcUb27ICEVIQ4vURONtbG9yMIBRkaKrFItwBy2UZIWbXLyptWCoozutRcdf28NGbLVGi1UpEdcgGuQq+seO7eEAp1kkL8RHyYsMwTPPWYDiAOzCNKNXM2KOEPInQL5eLjJ+Vp7GXXQrFc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700516454952328.1947005928978; Mon, 20 Nov 2023 13:40:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5BxC-00017O-FH; Mon, 20 Nov 2023 16:37:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5Bx8-0000sM-Id for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:37:12 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r5Bx2-0004L4-V5 for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:37:08 -0500 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-32ddfb38c02so3232694f8f.3 for ; Mon, 20 Nov 2023 13:36:49 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id r15-20020a5d6c6f000000b00332cb17f87csm2549410wrz.5.2023.11.20.13.36.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:36:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516208; x=1701121008; 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=JQm9clEeaAsqfkXJ+UfY2CLg9Wh2rq/brUmgmj9iQWU=; b=pfEXiHS4YcEiTtG6WmG8G0i/yRSMIXVUFjrsh08eOY+l6/rlpbw1h8eLXGwFsFYnMS 1lzuf8vOtU1h51tijmBUN2WTSHuH18fi9Xhq+yJFs0OLfwIbuITMKlEr/st5M5FYpera cBY8hWv+Mt9QBN7UMxF++5tahrB6LH0VH0cxqIXCsW++dy+waB4vaJ+0KdyzBE9e9+TA 9cbC2ExOm63QLpAXHYFEo0Mr5YxSCHPyyWfOOhJKV9o4D7eL+HSC0r5/e4QMJU7Le81d RBu0UDNECc3Zh13Vyn00x5XKQG1yln9bncCP/8MtkR0IXyxOs3HBxsJgEOPIZ//CeZZQ 76OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516208; x=1701121008; 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=JQm9clEeaAsqfkXJ+UfY2CLg9Wh2rq/brUmgmj9iQWU=; b=iTsP+GtBS1kn7ChuAtILcpZ+jN35Fr6lDJ1wBGse0NVpTg3Qy4TWrtWh3rBt6+CXb1 E6Fkwh+mLYgbkouawX+uIzznOc3oJS9fWBMY4MVavB5KrXeQOGVu46hjEngJsnbPRC89 hncfVNu69UiwwH4NuS84oNf9QCw7fDo1uDQ2ftz6fF6r0jAuoMXXMRqtTac82cYGJagu 0TUPJ8v4I1IYZX0B6YXUGd0UT+aMMPwf9vAZRY/TKUckwnVueaaN+XFIVdozUspRK54O WWh3gV2DN7W/VUJXy6KYsD2QWVHubHiQPxzyk520qG5ARv4E/oIebgfG30n4uUzB7TWK oRXg== X-Gm-Message-State: AOJu0Yxa8IUMeJI9Sdoc2avsIJwub5oSHxmj49fTjH7Fu72VhIcg8nLh s4haNQ9vcrxxyl15AFjDBNt/yd3EqRXuOMYy21Y= X-Google-Smtp-Source: AGHT+IHAKJ7RIB7+H8HQdeo7TpwytD3c234Zuu0bEkvAXHi7McyYwlv9W4jpBdIznNFfXNZ9YgkDWw== X-Received: by 2002:a05:6000:381:b0:332:c593:16c with SMTP id u1-20020a056000038100b00332c593016cmr4272767wrf.45.1700516207758; Mon, 20 Nov 2023 13:36:47 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu , Stefan Weil Subject: [PATCH-for-9.0 18/25] util/oslib: Have qemu_prealloc_mem() handler return a boolean Date: Mon, 20 Nov 2023 22:32:52 +0100 Message-ID: <20231120213301.24349-19-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=philmd@linaro.org; helo=mail-wr1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516456273100003 Following the example documented since commit e3fe3988d7 ("error: Document Error API usage rules"), have cpu_exec_realizefn() return a boolean indicating whether an error is set or not. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gavin Shan Reviewed-by: Peter Xu --- include/qemu/osdep.h | 4 +++- util/oslib-posix.c | 7 +++++-- util/oslib-win32.c | 4 +++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 475a1c62ff..9a405bed89 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -678,8 +678,10 @@ typedef struct ThreadContext ThreadContext; * memory area starting at @area with the size of @sz. After a successful = call, * each page in the area was faulted in writable at least once, for exampl= e, * after allocating file blocks for mapped files. + * + * Return: true on success, else false setting @errp with error. */ -void qemu_prealloc_mem(int fd, char *area, size_t sz, int max_threads, +bool qemu_prealloc_mem(int fd, char *area, size_t sz, int max_threads, ThreadContext *tc, Error **errp); =20 /** diff --git a/util/oslib-posix.c b/util/oslib-posix.c index e86fd64e09..7c297003b9 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -497,7 +497,7 @@ static bool madv_populate_write_possible(char *area, si= ze_t pagesize) errno !=3D EINVAL; } =20 -void qemu_prealloc_mem(int fd, char *area, size_t sz, int max_threads, +bool qemu_prealloc_mem(int fd, char *area, size_t sz, int max_threads, ThreadContext *tc, Error **errp) { static gsize initialized; @@ -506,6 +506,7 @@ void qemu_prealloc_mem(int fd, char *area, size_t sz, i= nt max_threads, size_t numpages =3D DIV_ROUND_UP(sz, hpagesize); bool use_madv_populate_write; struct sigaction act; + bool rv =3D true; =20 /* * Sense on every invocation, as MADV_POPULATE_WRITE cannot be used for @@ -534,7 +535,7 @@ void qemu_prealloc_mem(int fd, char *area, size_t sz, i= nt max_threads, qemu_mutex_unlock(&sigbus_mutex); error_setg_errno(errp, errno, "qemu_prealloc_mem: failed to install signal handler"); - return; + return false; } } =20 @@ -544,6 +545,7 @@ void qemu_prealloc_mem(int fd, char *area, size_t sz, i= nt max_threads, if (ret) { error_setg_errno(errp, -ret, "qemu_prealloc_mem: preallocating memory failed"); + rv =3D false; } =20 if (!use_madv_populate_write) { @@ -555,6 +557,7 @@ void qemu_prealloc_mem(int fd, char *area, size_t sz, i= nt max_threads, } qemu_mutex_unlock(&sigbus_mutex); } + return rv; } =20 char *qemu_get_pid_name(pid_t pid) diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 55b0189dc3..c4a5f05a49 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -264,7 +264,7 @@ int getpagesize(void) return system_info.dwPageSize; } =20 -void qemu_prealloc_mem(int fd, char *area, size_t sz, int max_threads, +bool qemu_prealloc_mem(int fd, char *area, size_t sz, int max_threads, ThreadContext *tc, Error **errp) { int i; @@ -274,6 +274,8 @@ void qemu_prealloc_mem(int fd, char *area, size_t sz, i= nt max_threads, for (i =3D 0; i < sz / pagesize; i++) { memset(area + pagesize * i, 0, 1); } + + return true; } =20 char *qemu_get_pid_name(pid_t pid) --=20 2.41.0 From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516354; cv=none; d=zohomail.com; s=zohoarc; b=WDyl/Z3iZBcvH5K6l6ssqN2XLXc98G18mbHTFfp2RnQsgf8ZgLuENUh+BviO86PrcwQEIpAtWKRKtpaSJTt2+Lcb7UpU2/bxSLaq3srvvyvt7z6emJYadesT20t3/zWp0ioK9BhE/6sAX56qMa7vgs8sVG6izc98YZSpjoSu31Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516354; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=p/MsY2VFHgbOiPtWRWKtDZy46HK6KETJnE5K0HuwqNo=; b=B3WmAWZWBPw8957ONcB8IVzqzGg6+AqTzGBS3CW6bB9yvlhjAy9NRSwFZP/WJwWCyfQDCwHXMbv/vdHDsDLynuGILMXTtqluGdKHu6FtInU7ZkggpJiIqe0nk6xxfo1RFDm2HKa6I9VuulT6JY0U5a/KvDcJZKn+5cIVtl+Iu2k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700516354881275.7585988425765; Mon, 20 Nov 2023 13:39:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5Bxq-0002GN-5S; Mon, 20 Nov 2023 16:37:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5Bxi-0002FG-Kh for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:37:46 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r5Bxg-0004Ts-1S for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:37:46 -0500 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-32d9d8284abso3241688f8f.3 for ; Mon, 20 Nov 2023 13:37:43 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id l6-20020a5d5606000000b00331698cb263sm12119027wrv.103.2023.11.20.13.37.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:37:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516262; x=1701121062; 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=p/MsY2VFHgbOiPtWRWKtDZy46HK6KETJnE5K0HuwqNo=; b=O5RQUENCCErWTYTEnoNxkniRinvV1FB17+hMpcT7/e8VCKb5QLe3rQ/Wq6AlvGfaDF GJ8XH3AZjkmOUdawnnxaU/syG9EEHJ9GVdbwPcJhCw2V1ajahla7O0mPLlPAnx2+SI4P WCM86gqW1ta3w5GPv++QmY6fMqgb+XqGDhMbDRgHDnTpuWf81FiRB9y/yHQzP8ZZZ+fE yAucheq0DppBU3eBqTj6jgPKOqAP6L/6kB6lvpY2Hjg1cuRZ34ErYdqvekHjUheY1jok gp8b7n09c4qf2GC4ET5AQW66CampadO3lMYDDDONh2ctfOb+aqc5bQj7VTuuYG0BMgno FgUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516262; x=1701121062; 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=p/MsY2VFHgbOiPtWRWKtDZy46HK6KETJnE5K0HuwqNo=; b=Fp5N8yH76YIFfHsYwCPGuyUSXZX5ffoTYW0akpj7L7FtGcXjgOPRfraxnxaMfejUDe oKakCtnslW07b8BfXorNlQ9soyhfBuuG8AJTnXdsXvQBB4UYXdom3BxX7ljX/4P9hl84 WGoEXySQrUTra72+aAbAtaOU9LP3NWqcseB9FYaQamORvoWSjLfCiPeQqRd/U6OcPQxK rd2qRhgBcVQnSDsZuxzchHwZ2NTbrFJxC9LL2dxhD9T0FGnS0WaNoWpjb8WuJR+uegiF meKdhi/zdaO4U98qjhdpsOQV13WmJlcWx/Ly7+kBnTRAVj/ydGeCvNOe/dUeSi4rMruv n91g== X-Gm-Message-State: AOJu0YyQyZn7JgU48LEY0n2gmhbKPHzYRiCMZ1pMt0j6EfKF9bdZb/LS 8/TVqipuPYwF6A4tBsR8JxsW2a7OamOHyiVVUro= X-Google-Smtp-Source: AGHT+IE8gBcwoSYEGtKWmwdpw3yHY8HAAZKAHltL7GBuNQW31gMUJeCsu5m5xUdBC6ykAj0kPtWBKw== X-Received: by 2002:a05:6000:1050:b0:332:c6d1:b6e1 with SMTP id c16-20020a056000105000b00332c6d1b6e1mr3068944wrx.14.1700516262358; Mon, 20 Nov 2023 13:37:42 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu Subject: [PATCH-for-9.0 19/25] misc: Simplify qemu_prealloc_mem() calls Date: Mon, 20 Nov 2023 22:32:53 +0100 Message-ID: <20231120213301.24349-20-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516355889100003 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gavin Shan Reviewed-by: Manos Pitsidianakis --- backends/hostmem.c | 22 +++++++--------------- hw/virtio/virtio-mem.c | 6 ++---- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/backends/hostmem.c b/backends/hostmem.c index 1b0043a0d9..30f69b2cb5 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -219,7 +219,6 @@ static bool host_memory_backend_get_prealloc(Object *ob= j, Error **errp) static void host_memory_backend_set_prealloc(Object *obj, bool value, Error **errp) { - Error *local_err =3D NULL; HostMemoryBackend *backend =3D MEMORY_BACKEND(obj); =20 if (!backend->reserve && value) { @@ -237,10 +236,8 @@ static void host_memory_backend_set_prealloc(Object *o= bj, bool value, void *ptr =3D memory_region_get_ram_ptr(&backend->mr); uint64_t sz =3D memory_region_size(&backend->mr); =20 - qemu_prealloc_mem(fd, ptr, sz, backend->prealloc_threads, - backend->prealloc_context, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!qemu_prealloc_mem(fd, ptr, sz, backend->prealloc_threads, + backend->prealloc_context, errp)) { return; } backend->prealloc =3D true; @@ -398,16 +395,11 @@ host_memory_backend_memory_complete(UserCreatable *uc= , Error **errp) * This is necessary to guarantee memory is allocated with * specified NUMA policy in place. */ - if (backend->prealloc) { - Error *local_err =3D NULL; - - qemu_prealloc_mem(memory_region_get_fd(&backend->mr), ptr, sz, - backend->prealloc_threads, - backend->prealloc_context, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } + if (backend->prealloc && !qemu_prealloc_mem(memory_region_get_fd(&back= end->mr), + ptr, sz, + backend->prealloc_threads, + backend->prealloc_context,= errp)) { + return; } } =20 diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index 75ee38aa46..12dc39e0b1 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -605,8 +605,7 @@ static int virtio_mem_set_block_state(VirtIOMEM *vmem, = uint64_t start_gpa, int fd =3D memory_region_get_fd(&vmem->memdev->mr); Error *local_err =3D NULL; =20 - qemu_prealloc_mem(fd, area, size, 1, NULL, &local_err); - if (local_err) { + if (!qemu_prealloc_mem(fd, area, size, 1, NULL, &local_err)) { static bool warned; =20 /* @@ -1249,8 +1248,7 @@ static int virtio_mem_prealloc_range_cb(VirtIOMEM *vm= em, void *arg, int fd =3D memory_region_get_fd(&vmem->memdev->mr); Error *local_err =3D NULL; =20 - qemu_prealloc_mem(fd, area, size, 1, NULL, &local_err); - if (local_err) { + if (!qemu_prealloc_mem(fd, area, size, 1, NULL, &local_err)) { error_report_err(local_err); return -ENOMEM; } --=20 2.41.0 From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516502; cv=none; d=zohomail.com; s=zohoarc; b=TU2bA4Jm/LaciXr3Y1F52SwjSSHpxLrQZkrN1+P8paslmKnrKVilXVCyFdAwJCpKYTKcapSV2+aZ367C3b2NgxYQ9tBMOr7zkVljf+v9k578gjtJJlDPqaXo+by0/rKSigws0kQ7bqqme1k7PlZWiTVciM3a9kvYnF5uRZZavEc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516502; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UraS1TRuHZYl48d9Wxp+wjyyWyHIh0UIpS4MHa3Y4jk=; b=aW1QEA2Ye3puMpxkPooSzyB507Y9rd9bAJlTtWM7psVozSMbM6osS//VmnJ7fC2MVUGUEUOy7BB845UNO5xRU/t73RVtB8PscLIZIGuff8Ivefx1OI1f6U6AMVvt73flyNcBPY4G2tR9VBSpe37aV2TsNRgs2Fs2USnYOVbFhLc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700516502437671.1560143096976; Mon, 20 Nov 2023 13:41:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5ByQ-0002Uj-2b; Mon, 20 Nov 2023 16:38:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5By2-0002N0-0L for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:38:09 -0500 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 1r5Bxx-0004WU-CC for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:38:05 -0500 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-32f737deedfso3157413f8f.3 for ; Mon, 20 Nov 2023 13:38:00 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id d16-20020adffbd0000000b003313902cef5sm12291345wrs.93.2023.11.20.13.37.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:37:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516280; x=1701121080; 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=UraS1TRuHZYl48d9Wxp+wjyyWyHIh0UIpS4MHa3Y4jk=; b=EMBorPeMlRr1txEOH2gF6Y2X6k8m5nwJHO2cE97N0IBuKfrGw6qCArNBVTLJa5tWo7 OwHA6UtPfeW3u6RsiBiIwwbR4o6XKiMTBLjRQZIhiiQSqIqCVNzVvI1wKBkIDtBYcKou xB8/JVrRaPmEBqMy58X6it2Tb8Z1qmZPvterG/f6in38nit0ttgDraeF+IGtzgz5G3ur 6Ph/QFd+iZoOP2+ZvbfhIw8qvFdQbd9XcfNpEIdMkTwqTFuET2ZnggYh/eY4w+M0P+Rf W5XUhDXCqEC8HlruRVB+2hYJFtOh+4fKECjkh6oTuVzN8+Q/ZcEbsD40Sz4VJ9wb/onM fTiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516280; x=1701121080; 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=UraS1TRuHZYl48d9Wxp+wjyyWyHIh0UIpS4MHa3Y4jk=; b=QzjSSSc2So31IYwUiLuy3+Q65GHnhRHqYFkhjuWaft1k/gpzfVRVaHLuwydfL2eqDw Qsicd1xVsKZkf4aei2MXEp8UKA3UzgDNRO68inexflStqUoZUfthzWqBrTKw2ZEf42Np Yr9vW7zpajGKjCCcJvBcOj/g/NlGQD7z2V4mCicy8IhRvMafeVmP/7+hekh/8zsHfscy BUS0aj/BoK2WpfK/xGPBGjcDW+7WeffdsCELYLvmegVlXoocDDBqdsTMDcD6DB9rwzoA NFawDA9uXcck2eLyNk8ENYzTue2JdsgSKWIFC2HnlN7odhQjPzS4VL9XhZI1YxAercNk 2sPw== X-Gm-Message-State: AOJu0YxA4VAgI+l3E4kX5zIM+qVr/TuB5dDscs8v5sV0yvgkwrJY3xMI ki8oUXrzTPptA0KI8c1ruJwVCWkWBzfY/AQ+5aE= X-Google-Smtp-Source: AGHT+IHflBalbLTcSpEJQEAQvMRHfmEnyQGY+PR0zSBuPt0JnWpgaSnexdgF77NL40SfRrfXafhNBQ== X-Received: by 2002:a5d:5f88:0:b0:331:3425:b84d with SMTP id dr8-20020a5d5f88000000b003313425b84dmr6763766wrb.12.1700516279757; Mon, 20 Nov 2023 13:37:59 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu , Andrew Jeffery , Joel Stanley , Jean-Christophe Dubois , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [PATCH-for-9.0 20/25] hw: Simplify memory_region_init_ram() calls Date: Mon, 20 Nov 2023 22:32:54 +0100 Message-ID: <20231120213301.24349-21-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516504639100007 Mechanical change using the following coccinelle script: @@ expression mr, owner, arg3, arg4, errp; @@ - memory_region_init_ram(mr, owner, arg3, arg4, &errp); if ( - errp + !memory_region_init_ram(mr, owner, arg3, arg4, &errp) ) { ... return; } and removing the local Error variable. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Andrew Jeffery # aspeed Reviewed-by: Gavin Shan Reviewed-by: Manos Pitsidianakis --- hw/arm/aspeed_ast2400.c | 6 ++---- hw/arm/aspeed_ast2600.c | 6 ++---- hw/arm/fsl-imx25.c | 6 ++---- hw/arm/fsl-imx31.c | 6 ++---- hw/arm/fsl-imx6.c | 6 ++---- hw/arm/integratorcp.c | 7 ++----- hw/arm/nrf51_soc.c | 7 ++----- hw/ppc/rs6000_mc.c | 7 ++----- 8 files changed, 16 insertions(+), 35 deletions(-) diff --git a/hw/arm/aspeed_ast2400.c b/hw/arm/aspeed_ast2400.c index a4334c81b8..0baa2ff96e 100644 --- a/hw/arm/aspeed_ast2400.c +++ b/hw/arm/aspeed_ast2400.c @@ -247,7 +247,6 @@ static void aspeed_ast2400_soc_realize(DeviceState *dev= , Error **errp) Aspeed2400SoCState *a =3D ASPEED2400_SOC(dev); AspeedSoCState *s =3D ASPEED_SOC(dev); AspeedSoCClass *sc =3D ASPEED_SOC_GET_CLASS(s); - Error *err =3D NULL; g_autofree char *sram_name =3D NULL; =20 /* Default boot region (SPI memory or ROMs) */ @@ -276,9 +275,8 @@ static void aspeed_ast2400_soc_realize(DeviceState *dev= , Error **errp) =20 /* SRAM */ sram_name =3D g_strdup_printf("aspeed.sram.%d", CPU(&a->cpu[0])->cpu_i= ndex); - memory_region_init_ram(&s->sram, OBJECT(s), sram_name, sc->sram_size, = &err); - if (err) { - error_propagate(errp, err); + if (!memory_region_init_ram(&s->sram, OBJECT(s), sram_name, sc->sram_s= ize, + errp)) { return; } memory_region_add_subregion(s->memory, diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c index b965fbab5e..3a9a303ab8 100644 --- a/hw/arm/aspeed_ast2600.c +++ b/hw/arm/aspeed_ast2600.c @@ -282,7 +282,6 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev= , Error **errp) Aspeed2600SoCState *a =3D ASPEED2600_SOC(dev); AspeedSoCState *s =3D ASPEED_SOC(dev); AspeedSoCClass *sc =3D ASPEED_SOC_GET_CLASS(s); - Error *err =3D NULL; qemu_irq irq; g_autofree char *sram_name =3D NULL; =20 @@ -355,9 +354,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev= , Error **errp) =20 /* SRAM */ sram_name =3D g_strdup_printf("aspeed.sram.%d", CPU(&a->cpu[0])->cpu_i= ndex); - memory_region_init_ram(&s->sram, OBJECT(s), sram_name, sc->sram_size, = &err); - if (err) { - error_propagate(errp, err); + if (!memory_region_init_ram(&s->sram, OBJECT(s), sram_name, sc->sram_s= ize, + errp)) { return; } memory_region_add_subregion(s->memory, diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c index 9aabbf7f58..b15435ccaf 100644 --- a/hw/arm/fsl-imx25.c +++ b/hw/arm/fsl-imx25.c @@ -299,10 +299,8 @@ static void fsl_imx25_realize(DeviceState *dev, Error = **errp) &s->rom[1]); =20 /* initialize internal RAM (128 KB) */ - memory_region_init_ram(&s->iram, NULL, "imx25.iram", FSL_IMX25_IRAM_SI= ZE, - &err); - if (err) { - error_propagate(errp, err); + if (!memory_region_init_ram(&s->iram, NULL, "imx25.iram", + FSL_IMX25_IRAM_SIZE, errp)) { return; } memory_region_add_subregion(get_system_memory(), FSL_IMX25_IRAM_ADDR, diff --git a/hw/arm/fsl-imx31.c b/hw/arm/fsl-imx31.c index def27bb913..1d5dcd51e8 100644 --- a/hw/arm/fsl-imx31.c +++ b/hw/arm/fsl-imx31.c @@ -208,10 +208,8 @@ static void fsl_imx31_realize(DeviceState *dev, Error = **errp) &s->rom); =20 /* initialize internal RAM (16 KB) */ - memory_region_init_ram(&s->iram, NULL, "imx31.iram", FSL_IMX31_IRAM_SI= ZE, - &err); - if (err) { - error_propagate(errp, err); + if (!memory_region_init_ram(&s->iram, NULL, "imx31.iram", + FSL_IMX31_IRAM_SIZE, errp)) { return; } memory_region_add_subregion(get_system_memory(), FSL_IMX31_IRAM_ADDR, diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c index 7dc42cbfe6..58f37e7c11 100644 --- a/hw/arm/fsl-imx6.c +++ b/hw/arm/fsl-imx6.c @@ -443,10 +443,8 @@ static void fsl_imx6_realize(DeviceState *dev, Error *= *errp) &s->caam); =20 /* OCRAM memory */ - memory_region_init_ram(&s->ocram, NULL, "imx6.ocram", FSL_IMX6_OCRAM_S= IZE, - &err); - if (err) { - error_propagate(errp, err); + if (!memory_region_init_ram(&s->ocram, NULL, "imx6.ocram", + FSL_IMX6_OCRAM_SIZE, errp)) { return; } memory_region_add_subregion(get_system_memory(), FSL_IMX6_OCRAM_ADDR, diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c index d176e9af7e..bb722fd46f 100644 --- a/hw/arm/integratorcp.c +++ b/hw/arm/integratorcp.c @@ -291,12 +291,9 @@ static void integratorcm_realize(DeviceState *d, Error= **errp) { IntegratorCMState *s =3D INTEGRATOR_CM(d); SysBusDevice *dev =3D SYS_BUS_DEVICE(d); - Error *local_err =3D NULL; =20 - memory_region_init_ram(&s->flash, OBJECT(d), "integrator.flash", 0x100= 000, - &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!memory_region_init_ram(&s->flash, OBJECT(d), "integrator.flash", + 0x100000, errp)) { return; } =20 diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c index 34da0d62f0..ac53441630 100644 --- a/hw/arm/nrf51_soc.c +++ b/hw/arm/nrf51_soc.c @@ -58,7 +58,6 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error= **errp) { NRF51State *s =3D NRF51_SOC(dev_soc); MemoryRegion *mr; - Error *err =3D NULL; uint8_t i =3D 0; hwaddr base_addr =3D 0; =20 @@ -92,10 +91,8 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Erro= r **errp) =20 memory_region_add_subregion_overlap(&s->container, 0, s->board_memory,= -1); =20 - memory_region_init_ram(&s->sram, OBJECT(s), "nrf51.sram", s->sram_size, - &err); - if (err) { - error_propagate(errp, err); + if (!memory_region_init_ram(&s->sram, OBJECT(s), "nrf51.sram", s->sram= _size, + errp)) { return; } memory_region_add_subregion(&s->container, NRF51_SRAM_BASE, &s->sram); diff --git a/hw/ppc/rs6000_mc.c b/hw/ppc/rs6000_mc.c index c0bc212e92..0bf9cb9c47 100644 --- a/hw/ppc/rs6000_mc.c +++ b/hw/ppc/rs6000_mc.c @@ -143,7 +143,6 @@ static void rs6000mc_realize(DeviceState *dev, Error **= errp) RS6000MCState *s =3D RS6000MC(dev); int socket =3D 0; unsigned int ram_size =3D s->ram_size / MiB; - Error *local_err =3D NULL; =20 while (socket < 6) { if (ram_size >=3D 64) { @@ -165,10 +164,8 @@ static void rs6000mc_realize(DeviceState *dev, Error *= *errp) if (s->simm_size[socket]) { char name[] =3D "simm.?"; name[5] =3D socket + '0'; - memory_region_init_ram(&s->simm[socket], OBJECT(dev), name, - s->simm_size[socket] * MiB, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!memory_region_init_ram(&s->simm[socket], OBJECT(dev), nam= e, + s->simm_size[socket] * MiB, errp))= { return; } memory_region_add_subregion_overlap(get_system_memory(), 0, --=20 2.41.0 From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516385; cv=none; d=zohomail.com; s=zohoarc; b=Chg50YtB2+Nr4Dylqz00hL2aiFAiTqVJATykbsT90FGfzBIh70FsKduwhWghrD/gP8s9h+vAfpaymh12/JI8yV8lLCezl3Cirt6b+5ZvRKxNv2cGUKXnfL1YgfKMsK5tME1IvQED6ijmCFrnyiiwsTKObIAATbJejnlUYynjNc0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516385; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3UqXJrP7Csw+EZpRSYWbaVbFeUsJSZVShG00VIsudqs=; b=USZ9ndYvTfmYIpgnX4u/ABCwErqb1YDzUi2Xjo4i0QXS8RWB9v2F1y6B2wHxaooXRBtbfw9Dm4ubuWWXDrZ18gRXChfW24h0/0hPZ0mb83qdSMkKTYg1506cUtIohRRgfzyW0IgmF5WdmLbVcoJshbwReBtlPcf7h2tqbEQYYuI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700516385406438.60321323523544; Mon, 20 Nov 2023 13:39:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5ByS-0002jE-FS; Mon, 20 Nov 2023 16:38:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5ByH-0002YJ-6x for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:38:26 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r5ByD-0004Z6-Iw for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:38:20 -0500 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-40a46ea95f0so22421165e9.2 for ; Mon, 20 Nov 2023 13:38:16 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id s15-20020adfea8f000000b00323287186aasm12332571wrm.32.2023.11.20.13.38.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:38:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516295; x=1701121095; 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=3UqXJrP7Csw+EZpRSYWbaVbFeUsJSZVShG00VIsudqs=; b=m0sVu+6mWbTSb3y7RENxTOq7Y65Ex7Ref2Sua35bbHUNhnSydXjpYMlBwRni/pnRnS DpkR9lP0caM3pNn5Qqbc2glVVBCeOVBhept1NmXBI0e/7/Xeb/laDoj9bnPV3rRP0A1v PegaPx26rjoFpqVXNqFfJxwki17r9yqDKQ1PkDlPjyxwmp0i88CH9CrhFPLttVU1l1c9 qDbJJu8GS0kL71b/p+uA7Ob8cocNM3l0S+tusTfM2qnyPuL8SNxS/d3AFu5bVSyzwU4d nx8n2kKGqqI04YoJR9SyVt/MocXC/r2TxP1zaANjlAQIHRwEvEKcyWYOoE8lQ0OW2JxN 1cjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516295; x=1701121095; 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=3UqXJrP7Csw+EZpRSYWbaVbFeUsJSZVShG00VIsudqs=; b=gX5l2Q8C/X9WZxSmXgddhkPHJW8XUpQieVqqo7hpLy5z0cJ5JPczdTv/szBab8qTqw lcMmyLvPkVLeh0mo8lFKUvKbrSPMigjbMwumIlqVqqSmE/EpKBk6hcTQzY9Q/NvU8//5 W64RbMt+22UhL32gLejBpZ9NNb7FtqyZ5Yap+cmUYOVhVAyuoxwj4l/P47qqqKzau/hF yewX47q3vg2WwklNHNHHg5bf4Uw9AoNdn5Cg3G/Cx8FuOzod63DAoBixxeABl8oq+Mda +s1cNEl/TZA22LJf4zCVNaCIYPJ7Oo3N2SbhjaV0qf9oqT8TXXSfx7bLCmhrfA+o/mDr DOvA== X-Gm-Message-State: AOJu0Ywhc3O4X9YEa84BTUx6g9VMhHUCOo4Uvc2dT0C+7b2VYCvGH3hj c3WHwNnlt3wc8Kt/V4aVMF+o+Eyamx0hpU4g+Rk= X-Google-Smtp-Source: AGHT+IH/HTfb8qthb84Bbah+CqNXTN5ijzceXsgsGeMfBJJDbXmgtirc0oJW9g0/8WbtfWUhVpi7VQ== X-Received: by 2002:a5d:54d1:0:b0:32f:b407:5b77 with SMTP id x17-20020a5d54d1000000b0032fb4075b77mr4653144wrv.64.1700516294438; Mon, 20 Nov 2023 13:38:14 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu , Jean-Christophe Dubois Subject: [PATCH-for-9.0 21/25] hw/arm: Simplify memory_region_init_rom() calls Date: Mon, 20 Nov 2023 22:32:55 +0100 Message-ID: <20231120213301.24349-22-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516385983100001 Mechanical change using the following coccinelle script: @@ expression mr, owner, arg3, arg4, errp; @@ - memory_region_init_rom(mr, owner, arg3, arg4, &errp); if ( - errp + !memory_region_init_rom(mr, owner, arg3, arg4, &errp) ) { ... return; } and removing the local Error variable. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gavin Shan Reviewed-by: Manos Pitsidianakis --- hw/arm/fsl-imx25.c | 13 ++++--------- hw/arm/fsl-imx31.c | 13 ++++--------- hw/arm/fsl-imx6.c | 13 ++++--------- 3 files changed, 12 insertions(+), 27 deletions(-) diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c index b15435ccaf..9d2fb75a68 100644 --- a/hw/arm/fsl-imx25.c +++ b/hw/arm/fsl-imx25.c @@ -81,7 +81,6 @@ static void fsl_imx25_realize(DeviceState *dev, Error **e= rrp) { FslIMX25State *s =3D FSL_IMX25(dev); uint8_t i; - Error *err =3D NULL; =20 if (!qdev_realize(DEVICE(&s->cpu), NULL, errp)) { return; @@ -281,18 +280,14 @@ static void fsl_imx25_realize(DeviceState *dev, Error= **errp) FSL_IMX25_WDT_IRQ)); =20 /* initialize 2 x 16 KB ROM */ - memory_region_init_rom(&s->rom[0], OBJECT(dev), "imx25.rom0", - FSL_IMX25_ROM0_SIZE, &err); - if (err) { - error_propagate(errp, err); + if (!memory_region_init_rom(&s->rom[0], OBJECT(dev), "imx25.rom0", + FSL_IMX25_ROM0_SIZE, errp)) { return; } memory_region_add_subregion(get_system_memory(), FSL_IMX25_ROM0_ADDR, &s->rom[0]); - memory_region_init_rom(&s->rom[1], OBJECT(dev), "imx25.rom1", - FSL_IMX25_ROM1_SIZE, &err); - if (err) { - error_propagate(errp, err); + if (!memory_region_init_rom(&s->rom[1], OBJECT(dev), "imx25.rom1", + FSL_IMX25_ROM1_SIZE, errp)) { return; } memory_region_add_subregion(get_system_memory(), FSL_IMX25_ROM1_ADDR, diff --git a/hw/arm/fsl-imx31.c b/hw/arm/fsl-imx31.c index 1d5dcd51e8..c0584e4dfc 100644 --- a/hw/arm/fsl-imx31.c +++ b/hw/arm/fsl-imx31.c @@ -63,7 +63,6 @@ static void fsl_imx31_realize(DeviceState *dev, Error **e= rrp) { FslIMX31State *s =3D FSL_IMX31(dev); uint16_t i; - Error *err =3D NULL; =20 if (!qdev_realize(DEVICE(&s->cpu), NULL, errp)) { return; @@ -188,20 +187,16 @@ static void fsl_imx31_realize(DeviceState *dev, Error= **errp) sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt), 0, FSL_IMX31_WDT_ADDR); =20 /* On a real system, the first 16k is a `secure boot rom' */ - memory_region_init_rom(&s->secure_rom, OBJECT(dev), "imx31.secure_rom", - FSL_IMX31_SECURE_ROM_SIZE, &err); - if (err) { - error_propagate(errp, err); + if (!memory_region_init_rom(&s->secure_rom, OBJECT(dev), "imx31.secure= _rom", + FSL_IMX31_SECURE_ROM_SIZE, errp)) { return; } memory_region_add_subregion(get_system_memory(), FSL_IMX31_SECURE_ROM_= ADDR, &s->secure_rom); =20 /* There is also a 16k ROM */ - memory_region_init_rom(&s->rom, OBJECT(dev), "imx31.rom", - FSL_IMX31_ROM_SIZE, &err); - if (err) { - error_propagate(errp, err); + if (!memory_region_init_rom(&s->rom, OBJECT(dev), "imx31.rom", + FSL_IMX31_ROM_SIZE, errp)) { return; } memory_region_add_subregion(get_system_memory(), FSL_IMX31_ROM_ADDR, diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c index 58f37e7c11..b2153022c0 100644 --- a/hw/arm/fsl-imx6.c +++ b/hw/arm/fsl-imx6.c @@ -109,7 +109,6 @@ static void fsl_imx6_realize(DeviceState *dev, Error **= errp) MachineState *ms =3D MACHINE(qdev_get_machine()); FslIMX6State *s =3D FSL_IMX6(dev); uint16_t i; - Error *err =3D NULL; unsigned int smp_cpus =3D ms->smp.cpus; =20 if (smp_cpus > FSL_IMX6_NUM_CPUS) { @@ -423,20 +422,16 @@ static void fsl_imx6_realize(DeviceState *dev, Error = **errp) } =20 /* ROM memory */ - memory_region_init_rom(&s->rom, OBJECT(dev), "imx6.rom", - FSL_IMX6_ROM_SIZE, &err); - if (err) { - error_propagate(errp, err); + if (!memory_region_init_rom(&s->rom, OBJECT(dev), "imx6.rom", + FSL_IMX6_ROM_SIZE, errp)) { return; } memory_region_add_subregion(get_system_memory(), FSL_IMX6_ROM_ADDR, &s->rom); =20 /* CAAM memory */ - memory_region_init_rom(&s->caam, OBJECT(dev), "imx6.caam", - FSL_IMX6_CAAM_MEM_SIZE, &err); - if (err) { - error_propagate(errp, err); + if (!memory_region_init_rom(&s->caam, OBJECT(dev), "imx6.caam", + FSL_IMX6_CAAM_MEM_SIZE, errp)) { return; } memory_region_add_subregion(get_system_memory(), FSL_IMX6_CAAM_MEM_ADD= R, --=20 2.41.0 From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516512; cv=none; d=zohomail.com; s=zohoarc; b=e3E5inhIe2SNigco40ZgJdpxK2Xt24QdGxuRv80lcLu9v/lwsIttS4PI+hkNis5jOuQe/+ErbRRbC/ZXYIDKSNUZnrXvHBB9tBvCEfgqHcQBk5uwlm8U6z+ARaVFxSWDR28ZkwBnrxjzpry8PMGIDHrU4R2W0CWxK8KODbSewEs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516512; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8LHC78QDU4+0JLufBJAoefD8kTg7PvgbK0ho9KjVegA=; b=V+KGb59plVBUUWHRGAYbAepK0QWmhI2V4e5L3HK9JHXQWJfc2kvD3ko5TJapMGuVyh6/JJ2N8OEMxQy3xVmK73K92aj80ICl5s+sWIHcaRlw/Kk3njmO0m2ugPwc4WZgTxDTOqpv+rsncPAJT3+j+QqunNgLXPjgwdi+oj2LODQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700516512328326.6583459693286; Mon, 20 Nov 2023 13:41:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5Byp-0003YA-7Z; Mon, 20 Nov 2023 16:38:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5Byo-0003XQ-14 for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:38:54 -0500 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 1r5Byl-0004gA-Bp for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:38:53 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-407da05f05aso17766385e9.3 for ; Mon, 20 Nov 2023 13:38:50 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id z17-20020a1c4c11000000b0040a44179a88sm18670392wmf.42.2023.11.20.13.38.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:38:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516330; x=1701121130; 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=8LHC78QDU4+0JLufBJAoefD8kTg7PvgbK0ho9KjVegA=; b=Qzi0CUJy5vFEW51MbnKXvOnzW1PbT8WAk6OB6U5ziwXRW5LgmhunKmofFAGb4RxRtZ Q3bQb3nmPKsPynLun2+eRtuR720M6Y7zwOACVWRQtNXHdaYq5b2o+OAGmHlISyQ+X2Su IXJKN950Je2wUUawN2gCFm3uXtu2YLeTJZz8hkClmUNZqGTZj2e10Ql5XAW/LOSlPVrM 0WF9qsT1SraZ7l3QxumhbgG27g2IvJAcX6n+rVKDPbL7Rc7kQf0HaGhRnqv+xObEAiUm bzl6E/xwxOukTNEEc7PhYp8kTz5eVIvCtXZXx38SvMPEIUQzLtOT/4LRJmAJuwztujYD 2tkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516330; x=1701121130; 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=8LHC78QDU4+0JLufBJAoefD8kTg7PvgbK0ho9KjVegA=; b=ni3DqRwVawUerfGZlSr3PtFLYu60C12Fyf2LdFNEKK3Ob5PRqZ2hqtXCSkSbEZ220H 3WyoWDdXIpu4HniA41r/cillpFMjaz5DfhGfbRFBVkZjypR82sCqqYgKq6Pzf0aCYA+I FI/usT7XSQk/VL8SWc1H5gzdC+Q7kIgIe5BF4R5M0rdhPHX9ryhooOYD/3jtDR4UkujZ XIG0g6Oe4FCSNmFQG8Ik0iVz9AXhPjDN9hrqjkw11cGM7/r65Kf3u/3eKCs0IKB3zjSX zX8zxhma97SsHMYLf4NbRMV1ZyTHOhhBWCKgUra/IhU1kNeV2zwLk4orC2x6FBDDb9r6 smlQ== X-Gm-Message-State: AOJu0Yzg4UHoZBemdzPGKfWLetM/LqfeahHfWAsJf7zQKGPl2Owe3nve INk8C2UA41wBEIIgaeb9Rbs7xGJ8k1nLHU6t424= X-Google-Smtp-Source: AGHT+IGR0AKBLTgs3rHMKqj6CjUak0fqxbSyoUYrHx04Buv84E5ejw85WoeVGxOVQ6/PSqi5hGLnOA== X-Received: by 2002:a05:600c:2246:b0:408:3975:e225 with SMTP id a6-20020a05600c224600b004083975e225mr7404513wmm.40.1700516329774; Mon, 20 Nov 2023 13:38:49 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu , Artyom Tarasenko Subject: [PATCH-for-9.0 22/25] hw/sparc: Simplify memory_region_init_ram_nomigrate() calls Date: Mon, 20 Nov 2023 22:32:56 +0100 Message-ID: <20231120213301.24349-23-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516514458100005 Mechanical change using the following coccinelle script: @@ expression mr, owner, arg3, arg4, errp; @@ - memory_region_init_ram_nomigrate(mr, owner, arg3, arg4, &errp); if ( - errp + !memory_region_init_ram_nomigrate(mr, owner, arg3, arg4, &errp) ) { ... return; } and removing the local Error variable. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gavin Shan --- hw/sparc/sun4m.c | 20 ++++++-------------- hw/sparc64/sun4u.c | 7 ++----- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index 17bf5f2879..fcf3782068 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -577,12 +577,9 @@ static void idreg_realize(DeviceState *ds, Error **err= p) { IDRegState *s =3D MACIO_ID_REGISTER(ds); SysBusDevice *dev =3D SYS_BUS_DEVICE(ds); - Error *local_err =3D NULL; =20 - memory_region_init_ram_nomigrate(&s->mem, OBJECT(ds), "sun4m.idreg", - sizeof(idreg_data), &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!memory_region_init_ram_nomigrate(&s->mem, OBJECT(ds), "sun4m.idre= g", + sizeof(idreg_data), errp)) { return; } =20 @@ -631,11 +628,9 @@ static void afx_realize(DeviceState *ds, Error **errp) { AFXState *s =3D TCX_AFX(ds); SysBusDevice *dev =3D SYS_BUS_DEVICE(ds); - Error *local_err =3D NULL; =20 - memory_region_init_ram_nomigrate(&s->mem, OBJECT(ds), "sun4m.afx", 4, - &local_err); - if (local_err) { + if (!memory_region_init_ram_nomigrate(&s->mem, OBJECT(ds), "sun4m.afx", + 4, errp)) { error_propagate(errp, local_err); return; } @@ -715,12 +710,9 @@ static void prom_realize(DeviceState *ds, Error **errp) { PROMState *s =3D OPENPROM(ds); SysBusDevice *dev =3D SYS_BUS_DEVICE(ds); - Error *local_err =3D NULL; =20 - memory_region_init_ram_nomigrate(&s->prom, OBJECT(ds), "sun4m.prom", - PROM_SIZE_MAX, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!memory_region_init_ram_nomigrate(&s->prom, OBJECT(ds), "sun4m.pro= m", + PROM_SIZE_MAX, errp)) { return; } =20 diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index c871170378..24d53bf5fd 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -454,12 +454,9 @@ static void prom_realize(DeviceState *ds, Error **errp) { PROMState *s =3D OPENPROM(ds); SysBusDevice *dev =3D SYS_BUS_DEVICE(ds); - Error *local_err =3D NULL; =20 - memory_region_init_ram_nomigrate(&s->prom, OBJECT(ds), "sun4u.prom", - PROM_SIZE_MAX, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!memory_region_init_ram_nomigrate(&s->prom, OBJECT(ds), "sun4u.pro= m", + PROM_SIZE_MAX, errp)) { return; } =20 --=20 2.41.0 From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516474; cv=none; d=zohomail.com; s=zohoarc; b=Ge+1G2Sfy0381XCGxfyTYA1Bnky4y7JEhP0nS5xqBj5lMmfowhv4bPk4Q1Agh5uBmC4hKi9SDPqFFlDcIxe+kJStn4kVqGzIIUq1eS0GrTXoFpdS6CAV0SJe26DLmjYyvYTRvoOPQlHdQkytlps0ruWYuI3bFPbwAo7ueQxFHz8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516474; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LccZbSfVbRBJBP3hDaCoexHeaPDYfSMKOISo4dOr+pE=; b=hdWp0XJe75RHqQMjs2o6cyKzxJfKyX25OVYtviOqxmIomNa5i7DL1TmGQHLaenknMlxYmOWcSLI65CvH44LjBUJYFEtvmvHNkd4PLL9JgczCSICAf7mc4hzFqX+GqItfaWpYTrHB97JTHGwqQ1AwJ3um1GPtg7tygGb0qIlhYeY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17005164745461.2546094913943762; Mon, 20 Nov 2023 13:41:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5Byx-0003Zh-SD; Mon, 20 Nov 2023 16:39:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5Byw-0003ZG-VU for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:39:03 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r5Byv-0004hC-DL for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:39:02 -0500 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-332c7d4a6a7so848313f8f.2 for ; Mon, 20 Nov 2023 13:39:00 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id z4-20020a5d6404000000b0032fc5f5abafsm12233916wru.96.2023.11.20.13.38.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:38:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516339; x=1701121139; 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=LccZbSfVbRBJBP3hDaCoexHeaPDYfSMKOISo4dOr+pE=; b=MADWJtaXVoHsCWOD+zESN/3a8CQwB8y6UkhtV7nLTVfXU3i2kP7GfweaI+eeaiQR3+ Frwu/P2NeKpWy9e4KUEAxvacAnGmHx1Q8+R4oNJh/nK8Vsm1Bz5sjCCXmbrkAUqpsUqk Ur19VJKguk4i8gqRs6TR8iyjj4PLZelZ0YKUJP/lQIIMty4mKWFdamF6egri1XG7bjy0 v9krfBWO3Zz1H9ACxpFWzMWCdbyauTAiarahT4BL8IxHDoDeKFeXkzh+Fm9aFhBcFvyA q0jYHHFpM6BRV824gmgzF3gvPhpucgOpZsnSocLyd0lpYktmZslluLmD2ZWbgYAOQLq3 nkCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516339; x=1701121139; 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=LccZbSfVbRBJBP3hDaCoexHeaPDYfSMKOISo4dOr+pE=; b=td6QJmM/cms23XynU+Qx2/oGR9TRez5uQ7LPgxEWeVUeW+7F0dV+zx0rG4llv7SCTk nYMNlfGQBRdXF3sH73EnWwvoSGl6t7w4lKaXCl3xnmFV5iAkTFK40YtvavdO1t1AkzDu j8jHc7CRtf2GCWhAdSnRMkDayZ3QYXOhiyQpiwvbNQSfMFa0GT8imos+S+iOq3JIGiYp K2risk8rprsgBelq4BQWNqypFqTlAT/yBLHsN7VktpQYtVmsTjaZbAjs5pfIXZ5KPIS/ j4NXOy4NeEhMkjjAKw6mFwI1dbBw+njYr54LV9NcegLvxpZ/3oli7nhQn8MMQi42ilje WyKQ== X-Gm-Message-State: AOJu0YzmxBLVQuwBbAWOPJoWQ1Y25e0xTVSmpsnyGH39b6F34V8G7Zz8 1e+RETGXiwYPUdyj3ev3XJbvi5/TKDmIaP4dI94= X-Google-Smtp-Source: AGHT+IFuC5KpbudFIGEI1t98ppu9xYnyNZcQbOHvVTAB0mfWOCjKv5jzgnanuXJ3VFe99/4jqBQgfg== X-Received: by 2002:a5d:59a3:0:b0:332:c4ce:5347 with SMTP id p3-20020a5d59a3000000b00332c4ce5347mr3132687wrr.48.1700516339396; Mon, 20 Nov 2023 13:38:59 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu Subject: [PATCH-for-9.0 23/25] hw/misc: Simplify memory_region_init_ram_from_fd() calls Date: Mon, 20 Nov 2023 22:32:57 +0100 Message-ID: <20231120213301.24349-24-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=philmd@linaro.org; helo=mail-wr1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516476316100003 Mechanical change using the following coccinelle script: @@ expression mr, owner, arg3, arg4, arg5, arg6, arg7, errp; @@ - memory_region_init_ram_from_fd(mr, owner, arg3, arg4, arg5, arg6, arg7,= &errp); if ( - errp + !memory_region_init_ram_from_fd(mr, owner, arg3, arg4, arg5, arg6, = arg7, &errp) ) { ... return; } and removing the local Error variable. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gavin Shan =20 Reviewed-by: Manos Pitsidianakis --- hw/misc/ivshmem.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index 0447888029..9a8b9e2fd3 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -476,7 +476,6 @@ static void setup_interrupt(IVShmemState *s, int vector= , Error **errp) =20 static void process_msg_shmem(IVShmemState *s, int fd, Error **errp) { - Error *local_err =3D NULL; struct stat buf; size_t size; =20 @@ -496,10 +495,9 @@ static void process_msg_shmem(IVShmemState *s, int fd,= Error **errp) size =3D buf.st_size; =20 /* mmap the region and map into the BAR2 */ - memory_region_init_ram_from_fd(&s->server_bar2, OBJECT(s), "ivshmem.ba= r2", - size, RAM_SHARED, fd, 0, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!memory_region_init_ram_from_fd(&s->server_bar2, OBJECT(s), + "ivshmem.bar2", size, RAM_SHARED, + fd, 0, errp)) { return; } =20 --=20 2.41.0 From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516518; cv=none; d=zohomail.com; s=zohoarc; b=TGiOtd6Npfm2Ys7MBeCYFk0AceXS5oeeLHuP1CL8p96Thn76rdzj0/6vU7AAKrg76voXX2VyBGiipzJ0SaVquR5ApYisv4hatG0sVmYcYFTxij57BdCL5ZHdMAZdLuehS2R0fDcVMem657KjNGmdFAQbicskHIlC1axhRT5rn9w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516518; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=drwtQoQ75QuwOSsjQYja6ApK0ZWyT5mWD40njjZhqyI=; b=l5+x2qt9tuy6Z3/Zyjn/OStpCYRP2enAaPs7eRGCmFtPEfB755WZ7e7UefFPE4LDk/GBRJkZvWGZQ6UgzQILIcnPJYhNFVHnep9cIygUnPwcXQhQh9mft9rT9L891Vtz2rhe2ACzaVkS7UxKr5533cn5SAjpPbG9SJ3+ZYWNHb0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700516518662381.5212718768347; Mon, 20 Nov 2023 13:41:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5BzD-0004Vo-5I; Mon, 20 Nov 2023 16:39:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5BzB-0004Px-Qh for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:39:17 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r5Bz9-0004iZ-5I for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:39:17 -0500 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-32ddfb38c02so3233970f8f.3 for ; Mon, 20 Nov 2023 13:39:14 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id r12-20020adfda4c000000b003232380ffd7sm12279698wrl.102.2023.11.20.13.39.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:39:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516353; x=1701121153; 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=drwtQoQ75QuwOSsjQYja6ApK0ZWyT5mWD40njjZhqyI=; b=OCPuesFLnTny55vzGzN+ysvm91sZbnROQwfte0JO5Gk66U7AKVXMKdtwt7N/OmkFys cv3pDJEiO/Y3u/ODWVguBZMdXICZHB8Gsl1V37ecb5anAE88UAcJoz45fODwVqBVqyu8 roMUyJ8vEZWJqHAi0UzqGwOQeRdUgGNL4RSOwoZ7rBMafuaespdfEehdZaTOcu0llogk iH9fSkyDBcKfjH9Xc15/AjTn2muCysSPwlaWnKLluoxinrfzRhcM8Qy0cPGE+ule24S6 1Z9oPYqK6ZwQnIdUPzWhOSPFFT/rZN1Rls4pQ+48xnkPJ5+KVd1igulUJdCc9DBAlrNi IIZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516353; x=1701121153; 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=drwtQoQ75QuwOSsjQYja6ApK0ZWyT5mWD40njjZhqyI=; b=hVYEnA+N0Xq1wEHmW+1JFa5tVArRlmQEUeHIP95nMvKgxhYiLrcWJqekW3/xMlbOp3 ubaZq7SBc8U3cOwn7YJFh7VSP9N6otrnEK7YMH1PF6VIsRK8vPcqLHWxXnwRR+xS7YVW 0olmh5X2sNHPK7bxQ/s5Pj/Km803hTFF7SDokAxkb/j+Ex9Nkke8qxojdkEbsYJfonZk fa5TM0Z2jzgOAi5wKARr3APkDJ0pv/OBOYQn86IyQ5VffKRa253ge8FZlBqFDPU3apeC Hxiu9hAAgQU7FHEhTo27gGq7KvdexYNyENymWWjjSOn4cfjvUZ0/KNF3+ZuUbrPdPMQ1 2L9A== X-Gm-Message-State: AOJu0Ywnyb11iKOsqRLHQduXdPYomCXTZaCPagmeKE10AmpDaFHPc6hY O1KPfz3HYCwzOIIO80fpsWcHxvD5PTEi3pyA9p0= X-Google-Smtp-Source: AGHT+IGlloYNr1MwxaUqoXnU7TSPDMnKBL9ArkwJvw2B9RG3kAN7W4RtNgtjSDXrqy/xPyUDAu+ODg== X-Received: by 2002:a05:6000:18ad:b0:32d:b06c:d30b with SMTP id b13-20020a05600018ad00b0032db06cd30bmr6850326wri.55.1700516353594; Mon, 20 Nov 2023 13:39:13 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu , Joel Stanley Subject: [PATCH-for-9.0 24/25] hw/nvram: Simplify memory_region_init_rom_device() calls Date: Mon, 20 Nov 2023 22:32:58 +0100 Message-ID: <20231120213301.24349-25-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516520459100005 Mechanical change using the following coccinelle script: @@ expression mr, owner, arg3, arg4, arg5, arg6, errp; @@ - memory_region_init_rom_device(mr, owner, arg3, arg4, arg5, arg6, &errp); if ( - errp + !memory_region_init_rom_device(mr, owner, arg3, arg4, arg5, arg6, &= errp) ) { ... return; } and removing the local Error variable. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gavin Shan Reviewed-by: Manos Pitsidianakis --- hw/nvram/nrf51_nvm.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/hw/nvram/nrf51_nvm.c b/hw/nvram/nrf51_nvm.c index 7f1db8c423..7b25becd49 100644 --- a/hw/nvram/nrf51_nvm.c +++ b/hw/nvram/nrf51_nvm.c @@ -336,12 +336,9 @@ static void nrf51_nvm_init(Object *obj) static void nrf51_nvm_realize(DeviceState *dev, Error **errp) { NRF51NVMState *s =3D NRF51_NVM(dev); - Error *err =3D NULL; =20 - memory_region_init_rom_device(&s->flash, OBJECT(dev), &flash_ops, s, - "nrf51_soc.flash", s->flash_size, &err); - if (err) { - error_propagate(errp, err); + if (!memory_region_init_rom_device(&s->flash, OBJECT(dev), &flash_ops,= s, + "nrf51_soc.flash", s->flash_size, e= rrp)) { return; } =20 --=20 2.41.0 From nobody Wed Nov 27 04:51:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1700516510; cv=none; d=zohomail.com; s=zohoarc; b=Y0o8hqfqKl8YW+WFaUj3VZi87PZqD6L5E9ADjVpIAUlWZOz6zWjYFbzSjr9kEWG3/VnQLz5gChizcCLmZLaBcy0gWlSZdc6jufbb3m//EFyRUeRV0wNTagM+2mQ8EPUCA96f2+oNQEUdxTJKne/B7WR8LCLSZ9HyjPNATlhR7sA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700516510; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Pno/XIMEfv6sc1E+e58IOA0UG1tXfCuf040vsihGJmc=; b=aKfYhvdwEDtS5R154S/3KuosRTbDkjMytB65U4k/6Zp2Vgei/G0YnHu8QGZlnB9xQyshbnprABG3+n1VjuUhkjDDj6OqubADKNn+S/ToG8yGdY0HceGZq7vTkLAz+a6b+Zgs6IzpcHc94dYzCP2dvK0nyklvqS5gz1r1CweAVf0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700516510246658.033703019122; Mon, 20 Nov 2023 13:41:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5BzM-0004ak-GU; Mon, 20 Nov 2023 16:39:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5BzL-0004YS-2C for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:39:27 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r5BzI-0004jw-Fp for qemu-devel@nongnu.org; Mon, 20 Nov 2023 16:39:26 -0500 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-32d81864e3fso3100388f8f.2 for ; Mon, 20 Nov 2023 13:39:24 -0800 (PST) Received: from m1x-phil.lan ([176.176.181.190]) by smtp.gmail.com with ESMTPSA id f10-20020adfdb4a000000b0032da35baf7bsm12234102wrj.113.2023.11.20.13.39.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Nov 2023 13:39:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700516362; x=1701121162; 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=Pno/XIMEfv6sc1E+e58IOA0UG1tXfCuf040vsihGJmc=; b=CF5RL0zUzCIFvd25ju57WC06acxPFagk0euQB638guaostgYaiLpfOgwgmAJRGdFZV 0oR4IYmsELKTWdHuvUVeKMVhfYq6bpOom/TUGX3rRKKX/Jr1gbqz8BFcm/MjtCGHSneA URwaSPLB4K8ONTDvNImP4UZ2oE3ps9RK5fWeZVVLrKX9XQ/qcvoeKDxHz8u+3KGgX9SK qcyk2ipAMYF7VHyQmn39y3cISyR72kYPFQgJZQOi+1IkHMTic/vh1eKFEz1wqfsOkvOT tvtYysFZGzWlvJZaO+vvoyesgoftXzVcdRaBLfEzn5G+DU8ZIiQsV753M9sEjDVG9S7z X7Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700516362; x=1701121162; 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=Pno/XIMEfv6sc1E+e58IOA0UG1tXfCuf040vsihGJmc=; b=Gr4oJsNRPNXnak3iPcY7dleugfFplQDJP54Ru/pdPMy6cFu0zCQePfCDDBamdH5c5V 3bPxcyOJzSZbqALewWU8mHvD3AejvxgTTNDemMdjD7GWpCdT1PP/t81o2/g/zswJOnSz 4i/hGUWDvyzEafxuKUMSAd871A1E1SpxUYV5YUfk7qQDnDCOgmDfV9i7Gkhxl+Q1B5aq awnE6/93pac+tQJJ4BialhMQZWo7f1PoDqIY/1VcyUzR6B3YL9Qai9SKkWXJlzN5WOhE tTKNB3uwwxB6uF+yTPb4qXTolbOD5b35Y19ytiDvkV47Pfm9I8+oc6GX2/f0DO2k3P3q lyKQ== X-Gm-Message-State: AOJu0YwI5sv8qwQ7dplgQTIJmK4g7cvwrM5r5BR+fv24dobGBvFbg3RO DZ0xNOGq3lva18YT2ESRuqcVHwONiA80Fp9OxIg= X-Google-Smtp-Source: AGHT+IFCM+02LF5oMUc1iksLuflOO0zjBgB07scFQdjSvIns9p2PzVI764WMyZ2ToevDwTE52mnYJQ== X-Received: by 2002:a5d:4012:0:b0:32d:8855:138d with SMTP id n18-20020a5d4012000000b0032d8855138dmr5261429wrp.66.1700516362036; Mon, 20 Nov 2023 13:39:22 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , qemu-arm@nongnu.org, Mark Cave-Ayland , Markus Armbruster , Paolo Bonzini , Igor Mammedov , qemu-ppc@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [PATCH-for-9.0 25/25] hw/pci-host/raven: Propagate error in raven_realize() Date: Mon, 20 Nov 2023 22:32:59 +0100 Message-ID: <20231120213301.24349-26-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231120213301.24349-1-philmd@linaro.org> References: <20231120213301.24349-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1700516512479100003 When an Error** reference is available, it is better to propagate local errors, rather then using generic ones, which might terminate the whole QEMU process. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gavin Shan Reviewed-by: Manos Pitsidianakis --- hw/pci-host/raven.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/pci-host/raven.c b/hw/pci-host/raven.c index 86c3a49087..e34ce47874 100644 --- a/hw/pci-host/raven.c +++ b/hw/pci-host/raven.c @@ -345,8 +345,10 @@ static void raven_realize(PCIDevice *d, Error **errp) d->config[PCI_LATENCY_TIMER] =3D 0x10; d->config[PCI_CAPABILITY_LIST] =3D 0x00; =20 - memory_region_init_rom_nomigrate(&s->bios, OBJECT(s), "bios", BIOS_SIZ= E, - &error_fatal); + if (!memory_region_init_rom_nomigrate(&s->bios, OBJECT(s), "bios", + BIOS_SIZE, errp)) { + return; + } memory_region_add_subregion(get_system_memory(), (uint32_t)(-BIOS_SIZE= ), &s->bios); if (s->bios_name) { --=20 2.41.0