From patchwork Mon Nov 20 21:32:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745383 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1533247wrt; Mon, 20 Nov 2023 13:35:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IFu//ykRJ6aZNPCdGvN6UHc2Pt5n9PAUknWyQKKKfqN44gmfIzY8uGXHonx1lKLQSPdW5hB X-Received: by 2002:ad4:5bcf:0:b0:672:20c0:ac08 with SMTP id t15-20020ad45bcf000000b0067220c0ac08mr10775170qvt.48.1700516150230; Mon, 20 Nov 2023 13:35:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516150; cv=none; d=google.com; s=arc-20160816; b=lFdp5FXgc0O3QjgzObZs+ZXFjnOxAQm9foWXcARsqG6tdhMu7wbdnCXY7bAktLtG3A j+ktmtdTRUAj/VffM1cYhSTpmGM78+p7O3ByaEYUVpS3RbItFF/EmZmab1Y7/1wBFvJu avlhB4MxGc6LqHmhMr3tGKUSb/ezsa2etTyKiX6Txxa1Ey2gChjYGDLbA120AlxIbtyp bnDBhKAUJ6VcXRQ3v/9p+cqTPk0f/W6fgY4KIMilk6MStdsnfvyTtJFsULe//8qzkXwr OILCMD9I90vys9f9pxF+tw0U12jNqcbxeU4Y8tbpOeuO77KcXYEAk5IKSWsyTVRO9QHn 3PXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yy1snK9B+SCgWiCxmQTHuCxjH+9ISs/0CoWZHoMFEnQ=; fh=toXMQ9nuJ3L4CLQ8EKaTQ8L/ltDlD3GauRZSJpgYVzU=; b=QBuiMkBfp8AvTXJoB3iakgXFDLfD/EHKX4eYmN+Ew2bIW/3D/hOYAqpe9JgPLSpL81 VRkXxYW4we6WSUkXJYluFmNLrDEDY8AjyNmSqUv8Pt/yR+ujTHzbiXgD2UboLfHFlw0t ovg/q/zCm5gISz3EdRf19IHISosctnGhR9WAgsvMFoA4nKkgCHNrNylveHly7n+b61ui 1pgmSFzX2QiY/D4uRs2po7bWX3EO7HmhXWeWEh2b751SZv/ua70ZBCm/zww3I1uRgOs+ eMc6Llx1C67AxTWZgXzisbpWs/arkC7R/rZE1q+ctdFuxyxJyoGwVvIkX9eqtqzYXFFp 7E2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="nBb/tg7v"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g11-20020a0562140acb00b00679da424d47si2921580qvi.211.2023.11.20.13.35.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:35:50 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="nBb/tg7v"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Manos Pitsidianakis Reviewed-by: Peter Xu Reviewed-by: Gavin Shan --- 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 caller. + * + * 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 *mr, memory_region_init_ram_flags_nomigrate(mr, owner, name, size, 0, errp); } -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(MemoryRegion *mr, mr->size = int128_zero(); object_unparent(OBJECT(mr)); error_propagate(errp, err); + return false; } + return true; } void memory_region_init_resizeable_ram(MemoryRegion *mr, From patchwork Mon Nov 20 21:32:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745386 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1533431wrt; Mon, 20 Nov 2023 13:36:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IH7DwFIxYk1oNMp4jJnTP94IQk8gQW6vO2p1pvUcbQwSKzE6+Tm0fYwK1nBxfLIFuBkuUmI X-Received: by 2002:a05:6830:1302:b0:6d7:daa5:3ec2 with SMTP id p2-20020a056830130200b006d7daa53ec2mr2964127otq.12.1700516178388; Mon, 20 Nov 2023 13:36:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516178; cv=none; d=google.com; s=arc-20160816; b=wriFrKQ+zxhCqJyCm9gNR3dFW2drWSPohsYoS/elrDLOYOr/Ny6b49qcvhq7Draqy1 lnO5H2TL7LKAhxslSxiMcqreJp7jJSGYgzxgfDdkUNiugvjJK97mh9IcEqBb8KSxJJmD gOIAaqVoQdPGHuAud51sJ2+8UEwOTgkKzYW8bq7+IE0Gbp0yVVgjSR+IMZW78eE0SSmf XOV5diF7ddd6BIn3lsla+KO3kG4kxFzhm3DyX6mx/BX2LhNhxYDt8hQJMjcNumXUVqPl QFFzIzWdkdvP2o6NThRoXf6jUlfsn8N1797irSC9mnJC3V+Livq/2b7Thz6yWWbc+BL9 j4WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=a3R2bk2+TIy0U91qpyefgUOXYaNCg17GUPUMA/PpOZ0=; fh=toXMQ9nuJ3L4CLQ8EKaTQ8L/ltDlD3GauRZSJpgYVzU=; b=E09nlwWyJaJvTkWhkP1MEcN3BA4Q8mjjRb0yfKzp0z4d+zyKihZcEzw4lotZa3Gm7v Pp7rrOPQ2UxAsT8pjw9ALo1Ro+JoN77Z5QMSccAro80gqvy1qDQjCXyud5kgV5OUtjwf vklpN/Pj0Xlf/B9m7hKtSBN5hwFR+gaTOf9tnapqK7RqYrt+ZGXnNHCEHk7nUy3h7n+x hEjNt3bpGrhVCUwPbruJIhg0sI3XQpb7jYXtO9LiSLfZD2ZxKd9tIoDAXiUyobfX3xUJ h51y5LiUNEWoSUT6DImpKrollYhT7Txx9unRQT9VxacLTVyK4KxGuqktStoKR2fj9shK 89Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wjdo8LXT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id pv17-20020ad45491000000b00679df339975si2019885qvb.426.2023.11.20.13.36.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:36:18 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wjdo8LXT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Manos Pitsidianakis Reviewed-by: Gavin Shan --- 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 caller. + * + * 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 = true; } -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); } bool memory_region_init_ram_flags_nomigrate(MemoryRegion *mr, From patchwork Mon Nov 20 21:32:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745382 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1533134wrt; Mon, 20 Nov 2023 13:35:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IFn7X00f9kuN2aBAmyI0pXSThkJoxPvZtHaG7EeyX6yL4cAJYBZ5f/l9E3Wab5vs+asImtK X-Received: by 2002:a05:6358:7248:b0:16b:c487:7028 with SMTP id i8-20020a056358724800b0016bc4877028mr7920414rwa.29.1700516136007; Mon, 20 Nov 2023 13:35:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516135; cv=none; d=google.com; s=arc-20160816; b=wVpVp8PWlYfxwU6FoxElK2dhXzvoBQYI+gI19y0nbQ9NHZnMPNjNawF0NQpsT2+eqO FnrJmZqaG8CfJOHHt7+Rs91FoYBjxUpT4Mgrzn0RFWQi1Nln78fFlUfsiRYu4jw+uVwW QwaKVl6WEiIruruqZZZC5IK/U8z/57FBbR+KTk1xCvWQjN3c59YXnMtnzTNDa99N+miT qJ0FUVGdRvOj0H7GQofwSrqPSOmB0EILKawR5vGlG0dbYbsxGILjcqORWkL//IfRwrgT ni9lR1fYaG2ImRkk+6ESDaLDOHNPcXzzomN28W9w106KMZa/1JS6DzUqh32Lp4uMcrNf rrYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LbDA9YGRe7qNIe50oT0Ny26RZPp0o8gVGjIEnbyILZM=; fh=toXMQ9nuJ3L4CLQ8EKaTQ8L/ltDlD3GauRZSJpgYVzU=; b=HUz6HpD8Lh2G+U/oB2z0vddEuAacowXD5lydBv8xt6NBfs+4Gc6ztCK70TWA0pwfSP fn4oey4WreCf2RmRqONIs9ZSuWt4arRa7s+VPm/ucKW405mXhmMtiV4+xTV2ZpVaBj3p Q1Febn4q48E4wcHjwbwEVdm6Ncg15zPwDftngNpyjedMM/PYJ6bdnmRmNfwuUJxmtJsP cA28/mJVfQNX+vjDnNroQggDgSC9mxnW029ITYOZwsBgZ/RMZ+aYSi8FGi7qnl67wu7V 6rpcPETm0wEiTqe9opQ1eXrQQi2/duHlywPrrp011UFAhzGX1iOwVtDdUSOoBE/YXyqT Q4NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cAxnqNxG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f16-20020a05620a409000b00773b364bd64si7959346qko.391.2023.11.20.13.35.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:35:35 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cAxnqNxG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é 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 = offset; } -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 = memory_region_init_ram_flags_nomigrate(mr, owner, name, size, 0, errp); mr->readonly = true; + + return rv; } void memory_region_init_rom_device_nomigrate(MemoryRegion *mr, From patchwork Mon Nov 20 21:32:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745378 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1532744wrt; Mon, 20 Nov 2023 13:34:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IHbuZMlyjybIWPN4H+wo50ll8eZzjXNzFvxRtqb5ke1g7+a+ZRMIUAi8HeCPCQHryEjSKTH X-Received: by 2002:a05:620a:51ce:b0:778:8cce:dbf3 with SMTP id cx14-20020a05620a51ce00b007788ccedbf3mr9695303qkb.46.1700516066704; Mon, 20 Nov 2023 13:34:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516066; cv=none; d=google.com; s=arc-20160816; b=k6ztOEwzvQGjpRkIWVPUfCwsMztV5KJWe740BUqxOeEw3jztYyFioGg6UeoCEc9g35 wZEbyNDMneVtgOQ9kgLxMgG6tMrxy823eEc0Q24YYWw2FqSVZ7BD821yWyO4zEVOMeWK juMKO6GybFlYwnBSUSuRtMVQ6BRmm5090YMvlnJy4H3Mydz5o9TwXH1nIKLAyEWtCD1i PyCB6FWakwUTZX+8wYJBtNz12bcTI66CFXxB4W1UKfQBQJMlU7mcG3NDT0ysqlUBpydL 7yaF3fuQJOXVwSdcyK89IRlz6JzIofAesQuqYlCifscAMWEaWOmjwSZQVjrcnPecZqjE fPbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fonaudvT/zI6eYgx9UtSiLdTbmVbD2gVa6JY6eKabgU=; fh=toXMQ9nuJ3L4CLQ8EKaTQ8L/ltDlD3GauRZSJpgYVzU=; b=EjzEmSH0Vu/bJtsScSM/e9XlbgzK5GkU7J3XloSLdwEmjtHcnFXWgey7ObiA/P0PxE gaRoWtk5RYMt3SvkK8R2VjPwFI8sX4Cg/C+EPOPltBloNpKN+c58IVajqvCb9BH2ZY5Q owRLB611o8ugElYVVU8I+ir3JSrvDjAZTmBfe0CtkcsGeOaimutqbjzMtCwt+J4RvwcX M9gAk2jdtv3GYapHllDbvzgLd/ppQuzqIK1pj112xhnCzTBh2Ox98esSxFmdgBsWlzE7 5g4sNwepAt4FAxrIC4tXziCDIX8vEO0Zt38mRMtNpuI4P2JolZCXixSHCZNdYTUFZbzo enWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=INOhgKhi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x10-20020a05620a258a00b007683ee37758si8265758qko.86.2023.11.20.13.34.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:34:26 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=INOhgKhi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Peter Xu Reviewed-by: Richard Henderson Reviewed-by: Gavin Shan --- 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 = NULL; - 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. From patchwork Mon Nov 20 21:32:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745388 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1533540wrt; Mon, 20 Nov 2023 13:36:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IFss39kZvv0aKxiTSfyf8LkJHbi/0n+vDVuC3BfkKQMXCM0ihH8AanAuXDT1FTC8pYfm7Fd X-Received: by 2002:ac8:5986:0:b0:419:5b6c:be62 with SMTP id e6-20020ac85986000000b004195b6cbe62mr14172924qte.4.1700516196666; Mon, 20 Nov 2023 13:36:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516196; cv=none; d=google.com; s=arc-20160816; b=TGJoIg6Y2AB5gqdmHbN0YXjtr/q7GHguNQ8HVY5bXnWVEt2h56q0GyKx6Q+gjCnusA Ch4G+MVk79/pT5zZo8sgxEnByjlKFgXbDemLYuIitk/r1dQE+34G6cOv+eocserGlUkr OEzwRHA9ndRoay2/UdNz0aeTRenmZkR+xLJSlezPtMShkh7zONbyMmw1aKBk4lgA6ufQ v0sPLmvepV/F/k+fxdqOO2dZBcQRR4T9FQXLWfKksDjQfQRropICfbC0QkR9+VoxHIUF BV5w+NAss89NR/H24OQ+GhJwyAcXJfbBFIJPzjnek77a8FwvG0oTA3SYzJvRXDzkWxsl +vng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Q5q8QrKQWuc5ZJauQIVd7Hh9PAH4SP4rAcWXs3pwmqE=; fh=toXMQ9nuJ3L4CLQ8EKaTQ8L/ltDlD3GauRZSJpgYVzU=; b=0OmZUc9NdraMKe9a060n2a7/zCnx9j4pqqpAnXiQOdPxK1xuBE03nXS4P6yLP6/Tvb 7IelY02HSryP09vfmi2vMLmuFzO1D3KnNvueV4q/XbtR2Q9yvTEAnwNmZgdiNkL4TMaV yQuVdQ2vrjdsCGADFNYruIe/xj/nYe3pf5VtAF5k4Z3fWIIvA1vlDUAgIkZltErW5cmF IAtEPknt+Nft9dG2+miO81jbQELRQocpUkbx5SKVnTW5Bsnz8jWGMunRNE+7PKYcRlJt ZvpgS1zp9hu15YLIP1AUQTOs6yeGk/ScfgfpITGoX5suj+VA4NKqoKKs2zdMgxVDHIIK 8YZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jCWV1wbk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w20-20020ac87e94000000b00420f1b907adsi7967623qtj.200.2023.11.20.13.36.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:36:36 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jCWV1wbk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Manos Pitsidianakis Reviewed-by: Gavin Shan --- 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 = NULL; - 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. From patchwork Mon Nov 20 21:32:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745380 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1532745wrt; Mon, 20 Nov 2023 13:34:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IHmA9LZDQiJffBvjpzS5QS1W5NbOwF0uVlkADxXnRHg5kkBkkbhoXl8S70Z4YcL/QDeD4/h X-Received: by 2002:a05:6214:5809:b0:63d:580:9c68 with SMTP id mk9-20020a056214580900b0063d05809c68mr1022596qvb.32.1700516066699; Mon, 20 Nov 2023 13:34:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516066; cv=none; d=google.com; s=arc-20160816; b=hkSREIMoB9zVdFROCNY870XW15oGfd4XeXuCeI9olDi02QmQ2zMIgjZLtLX3qbSn91 l9rfRfBAX5ImE30cVOySPapcI5A8HXZThBkLeSYASGVdtESg3s6J/F7RTBBww5jc52HD 1Pp8f0ivyd7lSMd1/h7xFqdoTK82OynplUuv2djDKGyGPCSs8qvAjYvo5wRb9qjVopau 0Y/7vJHJtRmQxKJkMqZUvkL6bfkZ103QZBIOgewZQuYf2qlIRDaWtSX+fIglLmk46HIC CPGPpfD6TNeJGTL69aCFI/BeW+BVWKGql2Yvq6iwMw261NIHvYtjfiHYsz3TRhWZU5VW BMeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QBwxNmvGLLiXqhul31X+YfHhcCHLwXIU2jAo+ECLv+g=; fh=toXMQ9nuJ3L4CLQ8EKaTQ8L/ltDlD3GauRZSJpgYVzU=; b=HCsWzkmlO4oyXBA1j+myqRRTj/0MywQQe+ccmYVmXG6qSKlSbrC68T/7IiRf8mdxAc jF57MPkYnDWKB4+h6AX+Rf0JfJyuNlSjVEe6kpPPJLhi5bsNL+dhkGJzBuLTXYVLU6QA LYQpGXDHnIT+81GPgs6tB34dM5Jz167P1GgBvPYBjMLDcORhFUx4+tEeKHJsZt73h7r4 PxoyDKnscc8oPm0QtwgnwIASlxxtIhULD4ym6QJm4ApEH4WCYWhaSeHjNaB/RyHRR1sp A0Eplfu9NPKljC8BzXFIe3JiMg0LOW137cxLf2dRu56UzSwQ+k7pHEES+/DAUFPhLxpr UcPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B9ioF4l8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g10-20020a0cfdca000000b0066db3467946si7928859qvs.461.2023.11.20.13.34.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:34:26 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B9ioF4l8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Peter Xu Reviewed-by: Gavin Shan --- 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, bool owner, bool disabled) } } -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; 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 = DEVICE(owner); vmstate_register_ram(mr, owner_dev); + + return true; } void memory_region_init_rom(MemoryRegion *mr, From patchwork Mon Nov 20 21:32:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745381 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1533100wrt; Mon, 20 Nov 2023 13:35:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IGSvX911kHIajXq1tnRwvkQcnzZ1LT3K/6qUWDHlSp0ymGxjh61SsyTCvqRO4JppBQffGl7 X-Received: by 2002:a05:6871:207:b0:1f9:539b:e9f with SMTP id t7-20020a056871020700b001f9539b0e9fmr2871560oad.44.1700516131257; Mon, 20 Nov 2023 13:35:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516131; cv=none; d=google.com; s=arc-20160816; b=SSZhBUhJEOYdzPo7ndk59uSaYU+/07h3/HBxTjkXpEyrKn7oJjCaRoG+5bftpN8NSZ g3iIMqTzLQoJ+F21Gi1pjQadKXvrLXr43eY3SU32sWinEi2UrQHujI6+CJPkG/O0zoAL VwiM2C6RRJzIsxRng+g5OddoUTWjn9qUM/l/RPwQhyhn1sZjpe91px9TwXSxdtbY+k+j iKjbMZLS5vTuej6OIEjkBSjOVj0HTH64OO8yhaUg+m9CFhMxBUOrIJinXAIK7ysBaTgB WT/tv50W+hoLtgb/0xciWRXewDmLM7+dzRfWFPY3r/YmXyDVe5b0Se6QlbM2fL+8YIIs 4EJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WK6ixy1lWz865bxFpaXwaNdgjrdvugwCVDt1SZLip8M=; fh=toXMQ9nuJ3L4CLQ8EKaTQ8L/ltDlD3GauRZSJpgYVzU=; b=UjNol+4xNNrwqfPSWSpn4ZBg1uggqMGI/jEDxzFs2DvM5INvEXl2fTvWtOvEKUTeZX xzNzqBUSoevsysvR3LoZbbSC5FdZaQap0sQkRIh07coURuo0KnPK/cOpN+z99UXVy7ea EY3t7SsIeYJBG9Jx5gdyeQsFqFvRBwnNnkl+h04FtNmxtdwGVIv7FJYuYvTWZg2xRnnr 8GTL2WgKOpxkg5xddXtnRSI2sabBK0h3AZug7z47n6lZWc731JKPn1q2VG4sVwE1RHN9 A0OLEY+ucY4yysHFAv928SQJZW+nCmyQGB+zezhcg4NADXodSAIQR+4KIOi9dXSAsFr+ Y7bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OfYtZD1h; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c16-20020a05622a059000b00419628da454si8272628qtb.177.2023.11.20.13.35.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:35:31 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OfYtZD1h; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Manos Pitsidianakis Reviewed-by: Gavin Shan --- 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; } -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; 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 = DEVICE(owner); vmstate_register_ram(mr, owner_dev); + + return true; } void memory_region_init_rom_device(MemoryRegion *mr, From patchwork Mon Nov 20 21:32:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745403 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1535264wrt; Mon, 20 Nov 2023 13:41:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IFcCXUsfpmsHzFmuDpxYYx3/srWIcgT6YWVF5fxt57SwwqyPrCWU/fN4KDTDC1uzxuvVsnG X-Received: by 2002:a05:6214:27eb:b0:66d:6526:d605 with SMTP id jt11-20020a05621427eb00b0066d6526d605mr10197873qvb.63.1700516519678; Mon, 20 Nov 2023 13:41:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516519; cv=none; d=google.com; s=arc-20160816; b=w1jkFQLTmkQxl6JQpeU+Bt21jK1iY35KjT6DtAVWxE52Ush3aT1KirVQAmh7KRipji 9fpnVMvQ3oRNMo/722Lknkyz2PiGCGSQaaq+tRwizNnatdtEJeLdS0eC/iqPRRAMpLDc 6w6gE4M+7E+II3ICxaWgDqz+YUFwdSEVmhJ6xSyk6e/ofERcs5Mh8NNgYEEyUE1B+dVp eBXtd4owCIGnQp3TW6ZO4n+knC4NOyq8WL749uNvmI21l4lKLQtax/9zPhXK04sSDs/N Cpm8WexvTPqSBK3hQJq/5vQDftOrcczBQIaPCJEz3C87cXetv55LTNtzMJ/TM40qnzot FRPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7Db5rVC7IYaMSjFIzhw37gGhb/kt8tXVyhffbU+sslQ=; fh=toXMQ9nuJ3L4CLQ8EKaTQ8L/ltDlD3GauRZSJpgYVzU=; b=z3A75SUduywgKkgV15yRE5N42XjkQcnfFAWh4sylUmYQvabPpojENuHfCGBsFKrGZJ 1tK79vehPPHYhrHV+jzv7DhU2zi66OiQHCdLAN+T0tp/H2PWqhHdK/OLd/rFs2q/6Agb p6QMWNGFHS9p1DhtYcbg84i7/NO8QfmRSFMNrg8OvqMCuKF7T22Qr4PRMYsfQDXFgB2g 8xTuSYchvYkHyh5NGcIrJ3udqgqPOn9ob1nudS9qbMl9XeHqwthBz+EjRualZ0bNC9L7 rS4l5h+qIygVQrIwHuszLa1IOwDLYmPfk01zKznURMaQXE7gAY0gqx5XKA8MWlqs7UNg 7B0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eqWZvHHq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a13-20020ad45c4d000000b00679d94cded2si3131946qva.166.2023.11.20.13.41.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:41:59 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eqWZvHHq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Peter Xu Reviewed-by: Gavin Shan --- 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 *mr, return rv; } -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(MemoryRegion *mr, mr->size = int128_zero(); object_unparent(OBJECT(mr)); error_propagate(errp, err); + return false; } + return true; } void memory_region_init_iommu(void *_iommu_mr, From patchwork Mon Nov 20 21:32:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745393 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1534791wrt; Mon, 20 Nov 2023 13:40:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IFHHVJoR0Ur6B3TTt7zQERdBVG/lYFtfEu6+YKnr2NyE9Cy9vvjvSYKObskhPsU1wL1JhOZ X-Received: by 2002:a05:622a:612:b0:421:c864:1f7c with SMTP id z18-20020a05622a061200b00421c8641f7cmr9943402qta.36.1700516440097; Mon, 20 Nov 2023 13:40:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516440; cv=none; d=google.com; s=arc-20160816; b=PutcMwusAsp7WTeUYrDCuk9IcB9+JgcpXXutTl9vVkA8cqOgxGP4mragOSRwfvw4Kk 0o29kQnwHecO74fTuCv57fDg0ZT/jRsmApeIBqiuWbGgyU2ntHMGDHnsYXBxGVpwf5bq cK/8GPLRBlg7B6hAt90RsYG3+qtZ0U8yyWK179qQk/HFEUnmAcjEiJ7dcm86zVUDvv+U d81Vl4VJQ9Bu1KQFVJSIZKyhhGcIwTJyCqjOarWGm3qC/WyuXK8kQnB7Wza+3CMmS1Il XUmDfOLgUeXFC95Ln3QcbVggOK8oFZe63N8s67NARFc6PuORmC9w8Sv6ZzQs4tUE88C+ WELA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DIex8QjcVHMzUQGfRlZtiLonUpnm8G6I3FWEQ6zYP+4=; fh=toXMQ9nuJ3L4CLQ8EKaTQ8L/ltDlD3GauRZSJpgYVzU=; b=rDY1PwDRnwttsG91XPRp/xXqmEFa5U0q0c9sePyyuuIAjOTTpsLbeZpRVTrtVlxLhP cEDuTKxjC55Ui6Na7pHAFW1Ym+tWz4rccbpmE/wVSzxogykpkIaKSEbq7TJfD2MCwNu9 maVGQ0M3+q+xLBXS2818g3oT+REpxjnTeeGDYxkjRCMr3yspj3WA/kBMdb/QYYaKlHE1 MVtAIiJCm+tIMxDvXgRnalLUSFcSG/tZ38JoJy2bsQ+EIRToh3dmrYGyWPRQ3qdn2Pkk 9bnhGSF+cn691FwBOgrcStQM4yP88BPsoU1uJEuG4kuyFrFMg0T1mAGm93N9Ryyqi9Qo l5Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CFXuIQns; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v25-20020a05622a189900b00419a6207c03si8158477qtc.81.2023.11.20.13.40.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:40:40 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CFXuIQns; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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, arg6, &errp); if ( - errp + !memory_region_init_rom_device_nomigrate(mr, owner, arg3, arg4, arg5, arg6, &errp) ) { ... return; } and removing the local Error variable. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Xu Reviewed-by: Gavin Shan --- 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 = NULL; - 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. From patchwork Mon Nov 20 21:32:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745385 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1533413wrt; Mon, 20 Nov 2023 13:36:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IFC7LIpVxnAL83iMjlITLeFhk+3KPAgB6qW0pNM2swDcHH+ldbVOLkFuonO8/EkGDtqp9I+ X-Received: by 2002:a05:6102:3f4f:b0:462:768f:db2d with SMTP id l15-20020a0561023f4f00b00462768fdb2dmr5946259vsv.10.1700516175763; Mon, 20 Nov 2023 13:36:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516175; cv=none; d=google.com; s=arc-20160816; b=U7DDKWbLZCGn28RrAOUwoAJE/CmeGT1xi12Gu0xtQ+YIBRUURMas7T/02ZWQs4Agvp EBWv+w4YOdJZGd/zsMm6sxkRTAP2cuYJ19RTg21oUwqmBXz7MWEd3Y07uiVC+meHxmj2 ok5mE0d+vRivCgT5g3ZWydJ//IBhcx6xqCUwY4AcLThMupIUGWjUmEn75C2f3Whff5cj aYZFlgvEwhPKNwF6O0OFCU46yUZzJdHsWELLajATEq7WlU9yKQOzRVOLenQG8We/WcPt qlxWoVAnA5/LZur5dy+r1tk5GQKs6uZkMr3frgX9+CTtWPHXLJFTbznwEA/kFjn/as/B FGcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Fn2fBz5vRqFzHrFrTMPe8dy33731H5v7e4n8L1UYY2M=; fh=toXMQ9nuJ3L4CLQ8EKaTQ8L/ltDlD3GauRZSJpgYVzU=; b=P6Dz5HKeS2WBlkK1vr90KQV9fpSoUeVJItKdn59Nl1mVeEf+deqLuKN5NZbbebiT32 pQUCoyiXtDt8HeCDO1GjudCYaIo4Vrn0lVd4qdQIi9d+FulOpPG43JJY/R/QmqAkPLM1 evwJ/FW/SmoPgmfGp26L5K81ulXNDU2BVfY1BHeyaCD8jesmMwiIrIj0HNJrUTc/FWG0 M6KeWvZPYefc/Lnw6J7BM08FpI837+Z2g/rnLl+XycEG6RbdDtjEHaN3XlMcrPma9HUw 9ERX7542zXwnEIXpLC9CBo0B8QkmDPo9O86lH06GvNKngO3gHASNZ6pQHSxRNG1tKiB1 hvpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=efL7PO8r; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q6-20020ad45ca6000000b00679d900a257si3372180qvh.44.2023.11.20.13.36.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:36:15 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=efL7PO8r; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Peter Xu Reviewed-by: Gavin Shan --- 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; } -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, 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 = DEVICE(owner); vmstate_register_ram(mr, owner_dev); + + return true; } /* From patchwork Mon Nov 20 21:32:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745394 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1534823wrt; Mon, 20 Nov 2023 13:40:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IFujPJhzQkvQiahLszUvbQ2LslEvmDEmCMAJ/KfseFRR+PVUtRWFIryMspdjfSbjcT8zKe9 X-Received: by 2002:a05:622a:1707:b0:41b:7773:ee56 with SMTP id h7-20020a05622a170700b0041b7773ee56mr10678146qtk.50.1700516445686; Mon, 20 Nov 2023 13:40:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516445; cv=none; d=google.com; s=arc-20160816; b=aCFG1TG08qr2xAbsgbHRJbbahhyj6eppdKsoFr2vVwnvcs104Vj8lQLTH8d+oOBoFu PS5n/8nCCdQRpSprLwx8qyFW7R7YfTdwwk/Q5vIKIqXIASb5rZEgYbu9yOI+CGSwYEC4 mzZ0uAivlE98XJINHNOVrLmbNQGDLpE3RFTm9X39DgBdHBXgGreItoKEU+aI5mzz2W/l DpyQi7+/l1tLLHPavjqgDaSINBXkelL1nVQHD0wGrFQC9qQUxed8dU55XugKQtl45VEq ChFHXfta4RIIoZxYdy0glWWFALjsNOUnwuuFfj5GocWegJucgTCisRVRyXsjOTeTFFNC z9Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=srROQw79PZz9736kD+JTLPR9CRLssrTQx2X8yf5dBJc=; fh=toXMQ9nuJ3L4CLQ8EKaTQ8L/ltDlD3GauRZSJpgYVzU=; b=j5JgZJDKMYg8zcd+vwxn7du6+8dw0+zumIVeic7w5cGBfXKsL+H15AN1MXcGA143Wl xuCTLGy8w1OZG2G2Vn7rbNisPeL1EK29yveFwnuKI+D2AMGtJktbRe+eB4x+n5PUgy4m ABpphqBq7+Jw6jF2DqaKHlL4pTgSOKIPw7X+9BYMrfhyexBIS/2A1cTl9MvYRzrpWVWw hZgimC5ZnfzY63Xkd5SP2MgFNj9iRiDaDqSk8c7SD3Dk6A9cmXEaEk3BPL0ded+jb7D0 Pa3Kd9nBsRDu8S1qsp9ElRyEJxHe9U31jFlGjcNIwpfXtXJcL48yGGwAn2oa9TD3S8OI JzpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mr7IOdsd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s8-20020a05620a254800b0077573396927si8422257qko.260.2023.11.20.13.40.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:40:45 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mr7IOdsd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Peter Xu Reviewed-by: Gavin Shan --- 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(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 caller. + * + * 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(MemoryRegion *mr, return true; } -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 = int128_zero(); object_unparent(OBJECT(mr)); error_propagate(errp, err); + return false; } + return true; } #ifdef CONFIG_POSIX From patchwork Mon Nov 20 21:32:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745384 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1533257wrt; Mon, 20 Nov 2023 13:35:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IHxJyfT3axC9xp60omWdU+wOhA7BUTMu3MsTUNM8PXtTBXkgnsFIacnwND9wEeE0u+ZJrqG X-Received: by 2002:a05:622a:38e:b0:41e:1c0d:35f9 with SMTP id j14-20020a05622a038e00b0041e1c0d35f9mr10814138qtx.30.1700516152394; Mon, 20 Nov 2023 13:35:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516152; cv=none; d=google.com; s=arc-20160816; b=SfevSIh1I0Uy9l5/ABPbYVZLWpfaYiri+ZgVxfIkZtJzBWNftaD87vPaP8ViSy396p GbvHDZIAI4I8/Raw2hGlMwEOaoYE+XNYj2gYROZr4HFWZf734oVUc3W3+CMHWlXpBbP/ I8KAzClQMlXptXxBnHFW4TTWKNu42gzddAdV9El1sBPrE/iQEpQ/pAt5a7oYVXWI0Ppv 0vYHi5Ksto0xN56maXzYeGN2VgtmlneJkxxmQetnm52rnuQWHtIg/x8MGJm4FFPWZcBm zaJwnqH3G7sN7zknN3DnVbobxg9p9KnaX0XuOV/3H3he1eWOuY93ItXiY/T2CCUQFi58 0lZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fJ1tGChnS+y/+vqRU30qRdlKveuA7pm7ifWNUTeCbQ8=; fh=toXMQ9nuJ3L4CLQ8EKaTQ8L/ltDlD3GauRZSJpgYVzU=; b=SI4iHTKdRE30u5drZ3PGtDVsxe+5c1YEtK6nYAK4jAgEfAS6pMpDPpKDOAHryce3Sn 0gINOjGO4WzTalYzqW9Kdri4LHaLqR5KriJJe3p8jCVqsNdJ6R1VNtDWOtwBIkDv2GaV Cm5d1WHByOos1gBm5uPPSu5hUI350ewI9FKPBFuN+HWSuAsB2xtVs54Ib8ltSQ6/55CC 7IyBt7X1bcNTLNoNq4m9JBpT/XVdL7iuvspV4ATrqN6SJogQKKjnRbtuEj1jWWmFHvpr 8dE8YyI6qxgmMbvxPmK6HNPbTbzDP1/Usk/xSddgRqgEBRW3016rEwzVp9HzjJiSBCgX T2gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LbtoaCYO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e11-20020ac85dcb000000b0041514842260si8045370qtx.256.2023.11.20.13.35.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:35:52 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LbtoaCYO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Peter Xu Reviewed-by: Gavin Shan --- 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 caller. + * + * 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, } #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 *mr, mr->size = int128_zero(); object_unparent(OBJECT(mr)); error_propagate(errp, err); + return false; } + return true; } void memory_region_init_ram_from_fd(MemoryRegion *mr, From patchwork Mon Nov 20 21:32:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745389 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1533572wrt; Mon, 20 Nov 2023 13:36:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IELhQ+5/SnZK7W3kUvzfOSC0I4S+51totbQ2heC3+4U+fqer/iAiM99Itk/P608v72sisQ5 X-Received: by 2002:a67:c10a:0:b0:462:8f85:7833 with SMTP id d10-20020a67c10a000000b004628f857833mr3973070vsj.5.1700516200666; Mon, 20 Nov 2023 13:36:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516200; cv=none; d=google.com; s=arc-20160816; b=q0DlmeAKG92pWTUpN47ZiMdWs5wWKE7l0H5c83Y/7VsG4Cz9rzbxiGp21u9j6UdrZK r9s8Cs8b7mzxsP6UY8LH3H+Gs58FDqVYvYnLT74Tf23DobmCy+Yb2fk0pXL0JXnMyuPJ KxVt+bEC9AnDVAHn6f5hqmKR6XyaeW3wIJjbxAd9jKx2QSXBOx9VZO7WCTSUb8c8+hF2 EggikROH7NCfuvGOGw/VwOMNJ5Al4zJ3kDtKJ8jk5XdgkxSE2/s1BJMduHNdz1lSkhQd gbKikMlnXbWo6x9UfgxL4XInVjhy5AhttR1cK6gyxwD/7UhvgULjHpEP4YvM5ub4jANl 7Olg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=M7/Bz5MtMeHpeaKi/bqx4so110l8AvikzKIx6tOl8A8=; fh=toXMQ9nuJ3L4CLQ8EKaTQ8L/ltDlD3GauRZSJpgYVzU=; b=TXWriSfk48icJb3iiKTSaLjO+EwPjumfs053RFCCJkok61Lla/LefPsvgNMhLY/7BM bRQZj5QnvQTqqWAbQhasGnrqzDM6I0sydUP2ELJ1y5ddVOotHtkpQFzJ4kHxBeRoqjUQ fpBSrjPc2dCXAmqtcBW01Z93aajKU/Myr6ml3/iFxV7FzG6LRrbEIuyvjThbKWEErlVC 98NMgam/b3avNjmQD+XScrvT/3SGTCGFXjEdDMci3lhkh7mu0aavfgfaQymf/rJ/LOvz Wk54q/FQS1M1K/3cMH6pXb9rD4IEdEHKxYTiHkFsDfBnXV7xS8SAcWMrKBcGXoxVJil8 c4uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nh8AX2v4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id df12-20020a056214080c00b0066d1ffebccdsi8182953qvb.342.2023.11.20.13.36.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:36:40 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nh8AX2v4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Peter Xu Reviewed-by: Gavin Shan --- 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 caller. + * + * 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 *mr, return true; } -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 = int128_zero(); object_unparent(OBJECT(mr)); error_propagate(errp, err); + return false; } + return true; } #endif From patchwork Mon Nov 20 21:32:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745396 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1534905wrt; Mon, 20 Nov 2023 13:41:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IFgbdQmudYTCg/YBxDfWAtpUBmWiuXhoRw+0WDfBjLysmhsLi1I2y0+aqyPzhCzSi9bsJ0t X-Received: by 2002:a81:fd14:0:b0:5c8:7269:b8b2 with SMTP id g20-20020a81fd14000000b005c87269b8b2mr6870269ywn.0.1700516459921; Mon, 20 Nov 2023 13:40:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516459; cv=none; d=google.com; s=arc-20160816; b=qYADWTiY286X6wb6rFuMPI6PPkSaTKgvA4spMYIVNlOUJ89qJZBj6rAIm1sZomM7UA HMWqqPEXFRnXciXieiQwmRf3TzEloiEvKLM7XevXLrXqOMayQp3RLDdAQQwVuB0eqqcE /mQS+Eyjv19oFr2vlbTl0i40Jppfaj7xl9GdNgtKEpoWBwkNcCsN5WrLvJqJfsYRdz4Q 4iY3PtSCkUB4B0/BXd8On+WOjcRq3HdMTzfMSGUuzaKyPwKiENEyAvpvA5Vja8GmiXDR 1yK3PL8yZd8KrkkMqtX7hYKtiMmXTNjScT2XQFIODo4MUakrkTSrOhLlOSzSOv1dYcXB R5mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3MTfYspIRofl2d+GaSi2n8kVPRZkUBrCgY4w5h7qsWI=; fh=toXMQ9nuJ3L4CLQ8EKaTQ8L/ltDlD3GauRZSJpgYVzU=; b=qtvNfAg69uwcangI46dYvyUhG4THuzJ9Tuid+cOPHSI2cefin2M4eGSy5d4fuzG5yS RMnYnRZWtmqqOFMbO+9944cAcLKnED5dyl3I03J34eeTjnd6AIfOY4FGsn0bsIxwrSdy cJPMXayzWVCM8FsQp8/QIwfq0Sf0LpQ7PcUFCUCURw8KfEBt5BJg/yfHbUp83fuaAwe/ 980EkT3PIsfo28hqNBNx4j1pgrZbVEpgtTD8RFb2zYjkEBz8IOA2iY29xFFGcxLYO25o UmTOZDT2Jnyvr+iLOVBn/lCi6emTR049uunj+v6SDj2YpgOFS2T/f4YoUCLh/CauoXRn BmYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rHCisfkl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y1-20020a0cec01000000b0065b1df3e3fbsi7856239qvo.6.2023.11.20.13.40.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:40:59 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rHCisfkl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In preparation of having HostMemoryBackendClass::alloc() handlers return a boolean, have them use g_autofree. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Manos Pitsidianakis Reviewed-by: Gavin Shan --- 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 = NULL; uint32_t ram_flags; - char *name; int fd; 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); } 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, Error **errp) object_get_typename(OBJECT(backend))); #else HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(backend); + g_autofree gchar *name = NULL; uint32_t ram_flags; - gchar *name; if (!backend->size) { error_setg(errp, "can't create backend with size 0"); @@ -89,7 +89,6 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **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 } 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 = MEMORY_BACKEND_MEMFD(backend); + g_autofree char *name = NULL; uint32_t ram_flags; - char *name; int fd; if (!backend->size) { @@ -57,7 +57,6 @@ memfd_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) ram_flags |= 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); } 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 = NULL; uint32_t ram_flags; - char *name; if (!backend->size) { error_setg(errp, "can't create backend with size 0"); @@ -32,7 +32,6 @@ ram_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) ram_flags |= backend->reserve ? 0 : RAM_NORESERVE; memory_region_init_ram_flags_nomigrate(&backend->mr, OBJECT(backend), name, backend->size, ram_flags, errp); - g_free(name); } static void From patchwork Mon Nov 20 21:32:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745387 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1533465wrt; Mon, 20 Nov 2023 13:36:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IGbAHyn9C5b0PvN9paoMNq/oTnFd3PN3c5eE1tKWHRgparrEXC64E8qxnDxi0PwfGqZSQzv X-Received: by 2002:a05:620a:2086:b0:77b:bdbd:972e with SMTP id e6-20020a05620a208600b0077bbdbd972emr900769qka.36.1700516183541; Mon, 20 Nov 2023 13:36:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516183; cv=none; d=google.com; s=arc-20160816; b=isTKtWocW58GZzYVlrIxpZUQ3dwj22R33e2jsz8rFDviTIx9OsCNwfyfXajBqHabAm KNud0Q+vg03U4jGqn328CbsN32VLvF6t+e+vRATWBlm94gqFEPaffQ0xSN60YgZJuEQK MQbhe6Fs6YipzMZ0UbfSUc/8Zqu537IhKupr8SspcRR/P/Ta4h1EZcUGe/gnG6LR1TJL kgh9FnUQaKqQtAhKaSL29Qperynem9uV3xTfAvmsl+klU394hRQ727JsF7nkEazHc+Fo 2nsyMSKzhBwbZ+Gcl7QG+vslYjjLuKTkXAoSis9cazRLTCqcgsRrttmv0DbrC7lyQX1v mxbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bJsPtTyJ8AvLk2JmJxbXP+WyZeZtfo9yWUZ/XM9f5N8=; fh=toXMQ9nuJ3L4CLQ8EKaTQ8L/ltDlD3GauRZSJpgYVzU=; b=PBf6nEW3P5pOZVZpiXzpWQMyMIA/5cB4klB1GzfWA6i8TNzyLezWWBKiQRqWTgwl15 RLvxWY4o+1f7shJtuaowrD3h1Q0skmSuoJIy/1zYG7uENWPRXn0lQCgBx4fD0kPcFN+n oDCG4ajbLqyvynZYbKIvJnVBqY1vPnqNtaAQq0Dhiw5OnIlNmz/tY6nfOzYWH8GbHoAp TQIAze4uj0UXYR3NLrXNzNOlA9fKKZ6Kl9k8fC1KW1i5EkWlKZLAbgY0qjnfGvZnUL8L sRLVGLYAZGhys6KKNR08XvdTtyYR7hBYS+ME/LxfiSYyty2R8zdePL2Ljugl8cmA/oab 97FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oP3wfeLp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bi13-20020a05620a318d00b007771d46fd50si8123677qkb.111.2023.11.20.13.36.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:36:23 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oP3wfeLp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Return early if bc->alloc is NULL. De-indent the if() ladder. Note, this avoids a pointless call to error_propagate() with errp=NULL at the 'out:' label. Change trivial when reviewed with 'git-diff --ignore-all-space'. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Manos Pitsidianakis Reviewed-by: Gavin Shan --- 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; - 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; + } - ptr = memory_region_get_ram_ptr(&backend->mr); - sz = memory_region_size(&backend->mr); + ptr = memory_region_get_ram_ptr(&backend->mr); + sz = memory_region_size(&backend->mr); - 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 = find_last_bit(backend->host_nodes, MAX_NODES); - /* lastbit == MAX_NODES means maxnode = 0 */ - unsigned long maxnode = (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 = MPOL_MF_STRICT | MPOL_MF_MOVE; - int mode = backend->policy; + unsigned long lastbit = find_last_bit(backend->host_nodes, MAX_NODES); + /* lastbit == MAX_NODES means maxnode = 0 */ + unsigned long maxnode = (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 = MPOL_MF_STRICT | MPOL_MF_MOVE; + int mode = backend->policy; - /* check for invalid host-nodes and policies and give more verbose - * error messages than mbind(). */ - if (maxnode && backend->policy == 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 == 0 && backend->policy != 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 == 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 == 0 && backend->policy != MPOL_DEFAULT) { + error_setg(errp, "host-nodes must be set for policy %s", + HostMemPolicy_str(backend->policy)); + return; + } - /* 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) >= - BITS_TO_LONGS(MAX_NODES + 1) * sizeof(unsigned long)); - assert(maxnode <= 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) >= + BITS_TO_LONGS(MAX_NODES + 1) * sizeof(unsigned long)); + assert(maxnode <= MAX_NODES); #ifdef HAVE_NUMA_HAS_PREFERRED_MANY - if (mode == MPOL_PREFERRED && numa_has_preferred_many() > 0) { - /* - * Replace with MPOL_PREFERRED_MANY otherwise the mbind() below - * silently picks the first node. - */ - mode = MPOL_PREFERRED_MANY; - } + if (mode == MPOL_PREFERRED && numa_has_preferred_many() > 0) { + /* + * Replace with MPOL_PREFERRED_MANY otherwise the mbind() below + * silently picks the first node. + */ + mode = MPOL_PREFERRED_MANY; + } #endif - if (maxnode && - mbind(ptr, sz, mode, backend->host_nodes, maxnode + 1, flags)) { - if (backend->policy != MPOL_DEFAULT || errno != 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 != MPOL_DEFAULT || errno != 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: From patchwork Mon Nov 20 21:32:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745390 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1533750wrt; Mon, 20 Nov 2023 13:37:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IEpYwy3ACz+RoCtiYaheclrfpo6m0cKpzScAYTi4chApe71erSaiQAxMsmj8hiAA2ngLheM X-Received: by 2002:a05:6830:2099:b0:6b9:a6ef:2709 with SMTP id y25-20020a056830209900b006b9a6ef2709mr9609066otq.8.1700516239267; Mon, 20 Nov 2023 13:37:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516239; cv=none; d=google.com; s=arc-20160816; b=Id/n1wkqCBRhuJcMnkKqeFPRMp2iShndLBikSWVKaenVNnZjDYQELXp16a6/IGgnFK tYDZJsyXlmIRsYmt1kwRyFlNEulOBStOCefpKf3iyNhBSPNVJPe40/2gb8TZFbysNEEe cq6YsPcWquaW80v3ucUTDecdGfK/0a8Pwzqo2/tDbL1x8/kRemGecDtT0a0naV58pjRs Bsk/uk3v0iJfIgkCi7gPh4YY4KYPzBdc4SUq4ZBE2SaWxaYIoUB3kjb7Bm/4/MrpTmoI LY1tM6S4lZk4ZuBmfeDSmFZMOVU8jvrShIs7PVR4xiQIsyOE1iyNPNOWph35s2ODlRUz kBvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0dlpM+IXDv7rbEXsFyB/MgTxRgvBWVHr070iMACWqDk=; fh=toXMQ9nuJ3L4CLQ8EKaTQ8L/ltDlD3GauRZSJpgYVzU=; b=NdtpFJfFbEfx38qNbGY+t9vZSoJ0kmiKIox90HyFbfpXSciBdTCbY3T7QZbPXFFPTs LSiIWqFx8xk0UovuVrX3v6S15wb6UQ1v9hulIhvW7PPkhEo5zREpZu+IkrITaw6M/AJK pCKpmgQrvqJad6K+a2ItwouatXRdVOgYRyELNbx3dVAyNPoeBoWSdiuQtgd2VSN8BMoc 0+eoQMmr5HHu50AcFkgDwO6KHYbrUKhCUZutzijPAqPqGz0v11o2hYPSxNIQFsPGt2CN KmiufIAZvQ8wQZn7J9fRknixl1vt3Yi1ebcB2uZs0/NtuH+So1PQlcXHZmc3DgzE/RlS T1rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K81jkTwo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ql10-20020a05620a890a00b00778916b8652si8278717qkn.536.2023.11.20.13.37.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:37:19 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K81jkTwo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Manos Pitsidianakis Reviewed-by: Gavin Shan --- 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, HostMemoryBackendClass, struct HostMemoryBackendClass { ObjectClass parent_class; - 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); }; /** 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" -static void +static bool sgx_epc_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) { g_autofree char *name = NULL; @@ -26,21 +26,20 @@ sgx_epc_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) if (!backend->size) { error_setg(errp, "can't create backend with size 0"); - return; + return false; } fd = 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; } name = object_get_canonical_path(OBJECT(backend)); ram_flags = (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), name, + backend->size, ram_flags, fd, 0, errp); } 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; }; -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 = MEMORY_BACKEND_FILE(backend); g_autofree gchar *name = NULL; @@ -49,11 +50,11 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) 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; } switch (fb->rom) { @@ -65,18 +66,18 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) if (!fb->readonly) { error_setg(errp, "property 'rom' = 'on' is not supported with" " 'readonly' = 'off'"); - return; + return false; } break; case ON_OFF_AUTO_OFF: if (fb->readonly && backend->share) { error_setg(errp, "property 'rom' = 'off' is incompatible with" " 'readonly' = 'on' and 'share' = 'on'"); - return; + return false; } break; default: - assert(false); + g_assert_not_reached(); } name = host_memory_backend_get_name(backend); @@ -86,9 +87,9 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) ram_flags |= backend->reserve ? 0 : RAM_NORESERVE; ram_flags |= fb->is_pmem ? RAM_PMEM : 0; ram_flags |= 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 } 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; }; -static void +static bool memfd_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) { HostMemoryBackendMemfd *m = MEMORY_BACKEND_MEMFD(backend); @@ -41,7 +41,7 @@ memfd_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) if (!backend->size) { error_setg(errp, "can't create backend with size 0"); - return; + return false; } fd = 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 == -1) { - return; + return false; } name = host_memory_backend_get_name(backend); ram_flags = backend->share ? RAM_SHARED : 0; ram_flags |= 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), name, + backend->size, ram_flags, fd, 0, errp); } 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" -static void +static bool ram_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) { g_autofree char *name = NULL; @@ -24,14 +24,15 @@ ram_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) if (!backend->size) { error_setg(errp, "can't create backend with size 0"); - return; + return false; } name = host_memory_backend_get_name(backend); ram_flags = backend->share ? RAM_SHARED : 0; ram_flags |= 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(backend), + name, backend->size, + ram_flags, errp); } 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; } ptr = memory_region_get_ram_ptr(&backend->mr); From patchwork Mon Nov 20 21:32:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745399 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1535171wrt; Mon, 20 Nov 2023 13:41:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IHw1GFNVSjVNPckGzA3x7SPAfOEPn1pM4Qxc0qn6Qj/6Acq6X5ye2A+sqIlouq1x+ZtTrae X-Received: by 2002:a05:6214:2424:b0:679:e710:c9d8 with SMTP id gy4-20020a056214242400b00679e710c9d8mr2499044qvb.49.1700516502364; Mon, 20 Nov 2023 13:41:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516502; cv=none; d=google.com; s=arc-20160816; b=eyqsw8cXpakX05lzHs1tL07Lr9FEpvOVMA7/G/9zgtB8Jrh4VFA+AdvVu7bs3vzpwi 7ZWC3/msCF/9LtWYn5J66+OhetKuHxpoTrAstE2zXkSkeQ1D3prajuAt8pGr1VaTNQto ePHlfv/I8gdc6YwmBOZ7Rs8uNUsLpw+nApkSpLcqhqSPuxR/4ClxBKQP2hxW8I741GXM WSzkHNln59OpOm0eSWvXaqPmdrdVf329pFzXNs2KFzAoauo7lRGrSP3ochNTuEk5Q2Dq Az5eFk59Yz0QnYiWqrOFC4shdBbuvNS91KftYhJzxQ1clYT06CI0w9coX/nRNyU/ncdP BtMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hOzYF2dzBcuolmQzvvXqLCwUi3E1rapeqqZCPtHm/3E=; fh=toXMQ9nuJ3L4CLQ8EKaTQ8L/ltDlD3GauRZSJpgYVzU=; b=09eTRFCdUbWHrmWSLphopjUc8OE/Cx9QMpUCtot84JgGfgNJDKp/CXOovGkk8/DqK3 DpXF/Ft3NH0D/3AAvPCuQGa/93wJyMwVrrLPwTIOTvi6Ak9kgcGA2IccTUn2e0Xu2F0h J9/gUR9J839TnaRNUewCfmAWFb1xL8g+ygpDG+11J9daG3a/gSvSxGPrIvQk/xob1ihi tQtBBUstPCiAafuJWGGfafb4ZhifZKSVLRH0fWiFkmYywPqrnNrDz/Z9Z7T1dGaDXZJC FO+YaB8J7ngU9hYMP/Mrsjmj9gESNvi9Pc47CIrODpdHq205EH5qQVBqj5pvt4Xr0Qkt 7tXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nU4SQtss; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u20-20020a05621411b400b0065b1c33dfcfsi7768221qvv.352.2023.11.20.13.41.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:41:42 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nU4SQtss; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reduce the &local_err variable use and remove the 'out:' label. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Manos Pitsidianakis Reviewed-by: Gavin Shan --- 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 = MEMORY_BACKEND(uc); HostMemoryBackendClass *bc = MEMORY_BACKEND_GET_CLASS(uc); - Error *local_err = NULL; void *ptr; uint64_t sz; @@ -400,15 +399,16 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp) * specified NUMA policy in place. */ if (backend->prealloc) { + Error *local_err = 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); } static bool From patchwork Mon Nov 20 21:32:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745395 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1534876wrt; Mon, 20 Nov 2023 13:40:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IGqYVoPr8MdLObn6SRThKJerHyU3vCvjlr1Jg7mxErdHNM9kH1e/G/SWp2ysNVUkpoI0M8g X-Received: by 2002:a05:6870:4c05:b0:1f9:5efd:7207 with SMTP id pk5-20020a0568704c0500b001f95efd7207mr1829468oab.40.1700516454883; Mon, 20 Nov 2023 13:40:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516454; cv=none; d=google.com; s=arc-20160816; b=wlgVFKKGusIknJwCgZ25k+29nujPb1rXpWXBQUP9dgZxLPBWvESaqT7RrPNVtsGRFO Gpbpasv3w1urvbPi8bjK2BI8NA5cvy5rl/5WBmPXQaCEkWov5GuZ9eteaBTrfAebIahO VP+VJztvPJ5+R+T1+pcASOSBuElvDjYbJrQ1OnJol43FWF204sPJ0hsP/YeNf830m9ax 2Sn2ZGJko7BJW7dRcxZfCuAFsuvdiBscyECbVSL6K+EZfiYsXMOXHfXG2PMKV4Mhh+4X qQ2vMtm7gkXXzn+kM5SkFbIe7UcxRQV65TXtuPicxdI1ew/IhFcW1fO/gvCHnyHvZkFL FuIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JQm9clEeaAsqfkXJ+UfY2CLg9Wh2rq/brUmgmj9iQWU=; fh=+TurtUsHIdF/4xSdnHQWj5edECWDRYwYAQ9W5oDsKf8=; b=eISLtzIF2CFgTZQVfi0EgOBnaXUAkzbunh21BG+yXIC3KiGSmoCaRRMmp2Z9bakyZ4 nNsWvRujStHAzntpBzYzS6AzxQ7I8QwhoHD0YDiT3xO9n+h7XuU4KICnUn0RBu+Ll7iO ZGLELn8djL9dkxFaqGxSMQ3X0C9mmimnhSck9iNnJdGj11MtM17WPztgiELEbPcR1OgN vy7fDm1R9AUzSlJjRHmYfFAsCGXC0id69dfwBBJUtrFKVFMZuL1Xr7plmo0pnFXzS1fk kAQCrOKBa6eXbkZc5Mywxg6+ZUf0s85HSrcat+kokOdy0IqqJuseb2bbZh0xBijKnfRQ s16A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pfEXiHS4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s33-20020a05622a1aa100b00410a3b28d66si8052422qtc.538.2023.11.20.13.40.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:40:54 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pfEXiHS4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Peter Xu Reviewed-by: Gavin Shan --- 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 example, * 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); /** 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, size_t pagesize) errno != EINVAL; } -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, int max_threads, size_t numpages = DIV_ROUND_UP(sz, hpagesize); bool use_madv_populate_write; struct sigaction act; + bool rv = true; /* * 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, int max_threads, qemu_mutex_unlock(&sigbus_mutex); error_setg_errno(errp, errno, "qemu_prealloc_mem: failed to install signal handler"); - return; + return false; } } @@ -544,6 +545,7 @@ void qemu_prealloc_mem(int fd, char *area, size_t sz, int max_threads, if (ret) { error_setg_errno(errp, -ret, "qemu_prealloc_mem: preallocating memory failed"); + rv = false; } if (!use_madv_populate_write) { @@ -555,6 +557,7 @@ void qemu_prealloc_mem(int fd, char *area, size_t sz, int max_threads, } qemu_mutex_unlock(&sigbus_mutex); } + return rv; } 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; } -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, int max_threads, for (i = 0; i < sz / pagesize; i++) { memset(area + pagesize * i, 0, 1); } + + return true; } char *qemu_get_pid_name(pid_t pid) From patchwork Mon Nov 20 21:32:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745391 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1534371wrt; Mon, 20 Nov 2023 13:39:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IHHiq3n2eLzm+tzsC+lYKSSAXvOX6dGia0ytGzAcEwkKytQ8tkWxPXTgUbJtwbV63t0qGE6 X-Received: by 2002:a05:6902:142:b0:d9a:fd15:82a3 with SMTP id p2-20020a056902014200b00d9afd1582a3mr7670624ybh.24.1700516354577; Mon, 20 Nov 2023 13:39:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516354; cv=none; d=google.com; s=arc-20160816; b=gn1gyNPnfRmI2ABxyaZT3+xlXT/Hb9zLoGvrfYDPFdXbV4aR8B4HxN4jgQUhmV83wX dU0+Q5xZFtuX30tzn3UVfmxeXkaa8DRGV3H1eS0gOd6BJ6tRDkbu0XE8CkcGw13Aq7oX kwuAYTJ7PKHgs95WNlQ1ZugSaEXUOJVhNizXEbC/mOfFGU6mVFudaz1gQvp8SRmGu+HZ RVLpinn+DiA9Uy0pDGJjtrxpKS5Ki6nZMAUy0o/FMzjNYcES/6RQxMpJcLkCRg1uLDpj YS5J7IZML04/0C2G0dUxSIjiir5q62yBoi3RxR5VKSs9zhGiT5nAzKfMNSEUFSecDffW BGMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=p/MsY2VFHgbOiPtWRWKtDZy46HK6KETJnE5K0HuwqNo=; fh=toXMQ9nuJ3L4CLQ8EKaTQ8L/ltDlD3GauRZSJpgYVzU=; b=lZGu8eK5n1DRmL7TsAN86o8wU27N9dL40J/okSRctQB96tV1M15fC0PbHFREEpN3DO blC873Juxuw0r4R+R7S0f2LLYXlKH6X5+2I1U4G72u33JHa8H7sjVXJBLfnBHu7RgIWl BvSSs7RJi26wjNpakSyBy4XaBMlkPIZMJ1YXQAWWMF7k6i+B8JQsykFMBCX6hnHssEVa lS3HmFSVNf1sv0Ev3nmP2mfYXRq2I8YXCjTDDq1F6VRxvCQw5hD02s2hw6vBIRm2l6eD NYYzdwSg1GhZ9ZJpq3kQ9NUVh/agMi2r172P8XTGC4wogye8TN7GXjFOkRxsYeKn/NNC 170w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O5RQUENC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v13-20020ae9e30d000000b007772e76ffb3si7586376qkf.549.2023.11.20.13.39.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:39:14 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O5RQUENC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Manos Pitsidianakis Reviewed-by: Gavin Shan --- 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 *obj, Error **errp) static void host_memory_backend_set_prealloc(Object *obj, bool value, Error **errp) { - Error *local_err = NULL; HostMemoryBackend *backend = MEMORY_BACKEND(obj); if (!backend->reserve && value) { @@ -237,10 +236,8 @@ static void host_memory_backend_set_prealloc(Object *obj, bool value, void *ptr = memory_region_get_ram_ptr(&backend->mr); uint64_t sz = memory_region_size(&backend->mr); - 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 = 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 = 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(&backend->mr), + ptr, sz, + backend->prealloc_threads, + backend->prealloc_context, errp)) { + return; } } 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 = memory_region_get_fd(&vmem->memdev->mr); Error *local_err = NULL; - 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; /* @@ -1249,8 +1248,7 @@ static int virtio_mem_prealloc_range_cb(VirtIOMEM *vmem, void *arg, int fd = memory_region_get_fd(&vmem->memdev->mr); Error *local_err = NULL; - 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; } From patchwork Mon Nov 20 21:32:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745398 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1535165wrt; Mon, 20 Nov 2023 13:41:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IG72mT2DhNIslnLbm1v/olVatEbFshG0w3YTbLA1G3hbmn+qi6lPcP+FEql3b/tXbzrpzh6 X-Received: by 2002:a67:e356:0:b0:45f:675e:e13f with SMTP id s22-20020a67e356000000b0045f675ee13fmr7557406vsm.23.1700516501755; Mon, 20 Nov 2023 13:41:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516501; cv=none; d=google.com; s=arc-20160816; b=sMpc/Jah+8KXLv41LOm4qGX/BeD6P2tDJyUJKj14lUn+S0WDzDgr8RyXVv+UEljbdg YhUfnx1rga/tHuILdnOhbWSpOERQ1xqOl0ijeJM4r40bUy46Rt0+ZoFWL/rQsOSQppsS buSHdqufeysn6rFZorOW+Gyw1Vcoa/XhRMgOx2MEM2t4y15JqtSRd3khDiO9vZLycSRd IC3SkHUqeJUZGb7TQfmXBtLiuNFJyntS1cLosHCbvfi0lpnT5GIQARRQzlac2wH7XaKk b0/+KDarPCsU9869l2h6Q0O7F84rExjY8ZGe4wpo42Y2MXkYS2HpKSCq9Vz+lb/JwED6 KL1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UraS1TRuHZYl48d9Wxp+wjyyWyHIh0UIpS4MHa3Y4jk=; fh=rUszpa2YpjdvUAMKOD3mDbyHjgGDQouMV1c9PSiGDnY=; b=qzfzwJ63hCBlXDyvgif7Hf3WW27cIpbxjTuWfShaFoQ9vNXgGZ6F3M4HEPajps4i3H xi58jKrWQg+u32MovTgX/nia6gbOeDKeabmZMhsfR5h0GYXVDKxOp3dn+GG5LMGtJOge V1sdIkbuD6/GecnWFwp4qtGIH9Uyo82RaVEC/3UKnARf3HMHCv/3PZj48EttckDgyX1z lSKiataDIu2yx+JkfEAX+6suAI/brJkuKQ1GvrlqKC4FM3pZwUMxzo4x2S7Y2gMpChNR ixuWJ6Y0EqHohzQcJLNe+P0BZutJ9haL3oqM4fr/sg7SGm1oVHcxkaFr7k5MmZDiazDT TmfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EMBorPeM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v5-20020a05620a440500b00775902632ffsi8235981qkp.279.2023.11.20.13.41.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:41:41 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EMBorPeM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Peter Xu , Andrew Jeffery , Joel Stanley , Jean-Christophe Dubois , =?utf-8?q?Herv=C3=A9_Poussine?= =?utf-8?q?au?= 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Manos Pitsidianakis Reviewed-by: Andrew Jeffery # aspeed Reviewed-by: Gavin Shan --- 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 = ASPEED2400_SOC(dev); AspeedSoCState *s = ASPEED_SOC(dev); AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); - Error *err = NULL; g_autofree char *sram_name = NULL; /* Default boot region (SPI memory or ROMs) */ @@ -276,9 +275,8 @@ static void aspeed_ast2400_soc_realize(DeviceState *dev, Error **errp) /* SRAM */ sram_name = g_strdup_printf("aspeed.sram.%d", CPU(&a->cpu[0])->cpu_index); - 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_size, + 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 = ASPEED2600_SOC(dev); AspeedSoCState *s = ASPEED_SOC(dev); AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); - Error *err = NULL; qemu_irq irq; g_autofree char *sram_name = NULL; @@ -355,9 +354,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) /* SRAM */ sram_name = g_strdup_printf("aspeed.sram.%d", CPU(&a->cpu[0])->cpu_index); - 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_size, + 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]); /* initialize internal RAM (128 KB) */ - memory_region_init_ram(&s->iram, NULL, "imx25.iram", FSL_IMX25_IRAM_SIZE, - &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); /* initialize internal RAM (16 KB) */ - memory_region_init_ram(&s->iram, NULL, "imx31.iram", FSL_IMX31_IRAM_SIZE, - &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); /* OCRAM memory */ - memory_region_init_ram(&s->ocram, NULL, "imx6.ocram", FSL_IMX6_OCRAM_SIZE, - &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 = INTEGRATOR_CM(d); SysBusDevice *dev = SYS_BUS_DEVICE(d); - Error *local_err = NULL; - memory_region_init_ram(&s->flash, OBJECT(d), "integrator.flash", 0x100000, - &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!memory_region_init_ram(&s->flash, OBJECT(d), "integrator.flash", + 0x100000, errp)) { return; } 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 = NRF51_SOC(dev_soc); MemoryRegion *mr; - Error *err = NULL; uint8_t i = 0; hwaddr base_addr = 0; @@ -92,10 +91,8 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp) memory_region_add_subregion_overlap(&s->container, 0, s->board_memory, -1); - 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 = RS6000MC(dev); int socket = 0; unsigned int ram_size = s->ram_size / MiB; - Error *local_err = NULL; while (socket < 6) { if (ram_size >= 64) { @@ -165,10 +164,8 @@ static void rs6000mc_realize(DeviceState *dev, Error **errp) if (s->simm_size[socket]) { char name[] = "simm.?"; name[5] = 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), name, + s->simm_size[socket] * MiB, errp)) { return; } memory_region_add_subregion_overlap(get_system_memory(), 0, From patchwork Mon Nov 20 21:32:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745392 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1534535wrt; Mon, 20 Nov 2023 13:39:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IHeRtGLJrdFyE7zLLKoA9CIpfOiqAbAU+krAoQ8j0lje/hWohTmWS+qX8UvgskPEIfzRGsH X-Received: by 2002:a05:6358:c8d:b0:16d:bba2:e365 with SMTP id o13-20020a0563580c8d00b0016dbba2e365mr9507961rwj.12.1700516385114; Mon, 20 Nov 2023 13:39:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516385; cv=none; d=google.com; s=arc-20160816; b=Tw3X72pz22YeFo1LqBfrAzdeP9iy0JXBx7WW/3fd9IrQdk1GYOeEjkt00K2qFtlA3S L2WdnaWCCZ8vmPDyf9UFXqNQBVBdoT790t8kNlRn8RZKi+IKI5Tf1jimlXYEu8k+4q98 +NG34S46Am4vW0gG7UE2zbb3Bh146hFVwHbZCXzbIY2jp2lz1aVGOIT0rCIOhPb1cuwj I1WTnNM0RWX/AhSkBJmvUaT3yPoqOeQui/BQLQtofUcDK/nZkSGjf51qmfsj62EeNeja mLA3HXiNiB+iQp40Oytzs+rYWG1ymjl3KW12Yf64OuFuawXj8soGOqTS8vQ84/tggQVa 2hmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3UqXJrP7Csw+EZpRSYWbaVbFeUsJSZVShG00VIsudqs=; fh=1qD3b4sFO1oDZwkrl7cLi3jOgcr+jywazXyW37wM0YE=; b=nNPiEKUrotdE+ZVNIK2rr9XGPlOUV4BvRvywKrQTC87fFlE+2XV3px7qQ8Aky2ULgQ 9O3be3Mrvx+i4Yntt8X0ofx/j9W2qrBRkWPJbXlyIZCqxusz1ttyJpFdzBXwvXF+rZM7 7lX3le+qZaXcilhPF/6HoPq4ViuzUl/qcpWgEMAVUDCbE4Mf1K4lgkAR7rdH8NuyZYf1 sPks1xLg20RXv14b6dy890uIyjfZlvkLLvjI5/qgmrv0uIaXQuq8QstdpCC0yEfuQLaI shyApk5THPgQl9I3o6FCzIF2kfLIT9AdzFpVuvNhGPo8lCIn0bWJkxbGGbIZZcC4kO75 xlsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=m0sVu+6m; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y16-20020a05622a121000b0041e20752c5csi8383363qtx.735.2023.11.20.13.39.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:39:45 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=m0sVu+6m; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Manos Pitsidianakis Reviewed-by: Gavin Shan --- 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 **errp) { FslIMX25State *s = FSL_IMX25(dev); uint8_t i; - Error *err = NULL; 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)); /* 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 **errp) { FslIMX31State *s = FSL_IMX31(dev); uint16_t i; - Error *err = NULL; 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); /* 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); /* 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 = MACHINE(qdev_get_machine()); FslIMX6State *s = FSL_IMX6(dev); uint16_t i; - Error *err = NULL; unsigned int smp_cpus = ms->smp.cpus; if (smp_cpus > FSL_IMX6_NUM_CPUS) { @@ -423,20 +422,16 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) } /* 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); /* 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_ADDR, From patchwork Mon Nov 20 21:32:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745401 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1535231wrt; Mon, 20 Nov 2023 13:41:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IF6Q6v+EVxoXtwKpEPy+9tvwTGA3UHipPw+4GYZYCGp2ZYHGAvOpXpvaMUv0ZazTqmRNciO X-Received: by 2002:a37:e109:0:b0:779:859a:5ef8 with SMTP id c9-20020a37e109000000b00779859a5ef8mr8157936qkm.31.1700516512290; Mon, 20 Nov 2023 13:41:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516512; cv=none; d=google.com; s=arc-20160816; b=uJ1mJEJJsiLQuuxJSrZktVX+NJbQc5y2nHVwitLGyefDMD7i14G+LjHgVen+o3fdwC xyFQ9CNY6C6/prg415dxKRtioPZhanzVz2F3HcHKh6GIik6jJLc1cmpO1P086L9B1mOx BxhbVfcuYLUHa7hw1HDBGu8wiuGnC782NqN6gkW0PLiYAEuo1IjaewnOCAj+SPpsHY6S MXPWRhFFEahYLLfRxjK5+fIBL++aXeZRRp9Yh8tTutDI7fosGIOvwFQTnT0Xj8kJrlJz v3lPPsTZgXxUNz5PPeUPTge7V883oWAb7//mS4CZT3AFVa80f0L0on8b60mF9Al3C+ha d8Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8LHC78QDU4+0JLufBJAoefD8kTg7PvgbK0ho9KjVegA=; fh=s6i+mAokLmqoXWCAhv1lYNsf7BrryeHt5KKeg2phT8I=; b=qLTRj1tv39dPgRvoxu+yEKpSQ44MMrtMKpoZd8nzT/wEldtIn4HGpx7in7eVUmBYwR PMlIqxb5Rm2xaxDFU353sMz3NyvitdD5PZZcwnrr/xnqQHDOfcgMVoaimbZc4Z+rIgFY ya1X1+RGotbcgXJ2ykhWDBjl5FWAEBOp/lM/rRG7h14sSxZ/WhESAplurfE/cCcHw2B7 uRcGOnkiN29eQn+j47mAc5zDQs/xt3jm40Zm6hlc2HKMo/XOAPHt9KR1ChFFjxVuKPPu 1sgyYyGdbd9u+Dlcqz58frDdd64pm2OwHbD13mxGbEMhsSz0TEtqK3Vvwr2fCuYVKetI k2mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qzi0CUJy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id de16-20020a05620a371000b0077bd6ce177bsi8365325qkb.690.2023.11.20.13.41.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:41:52 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qzi0CUJy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é 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 **errp) { IDRegState *s = MACIO_ID_REGISTER(ds); SysBusDevice *dev = SYS_BUS_DEVICE(ds); - Error *local_err = NULL; - 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.idreg", + sizeof(idreg_data), errp)) { return; } @@ -631,11 +628,9 @@ static void afx_realize(DeviceState *ds, Error **errp) { AFXState *s = TCX_AFX(ds); SysBusDevice *dev = SYS_BUS_DEVICE(ds); - Error *local_err = NULL; - 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 = OPENPROM(ds); SysBusDevice *dev = SYS_BUS_DEVICE(ds); - Error *local_err = NULL; - 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.prom", + PROM_SIZE_MAX, errp)) { return; } 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 = OPENPROM(ds); SysBusDevice *dev = SYS_BUS_DEVICE(ds); - Error *local_err = NULL; - 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.prom", + PROM_SIZE_MAX, errp)) { return; } From patchwork Mon Nov 20 21:32:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745397 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1534994wrt; Mon, 20 Nov 2023 13:41:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IG7ikLrYWZD/IgYnE4U1i4NHbmlmOWB+dxK+HBxsMsT2W5rKW4JmSWeJepZ9JaqMg5xy7Df X-Received: by 2002:a05:6870:a451:b0:1ea:eed:fd02 with SMTP id n17-20020a056870a45100b001ea0eedfd02mr10499991oal.45.1700516474383; Mon, 20 Nov 2023 13:41:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516474; cv=none; d=google.com; s=arc-20160816; b=GIDf/INP1xIU6oj614enXTJoAPYk8D9JwDqLcbwpcC67O6j/0z3XFRED+BKUStNzKi izCzPjt99gXTEsKjCX5c4wNJmoCfwk32YI+5iI/Yb58pzwctPtnyksYBVsfjazsTqquB E//zgdRlKH5RuX0cPdOawzo9ww11eDCTpFPXREmJiY1oJR1AP2824z1I2+8WuYFdzQL2 xZsYISA5fAh3XuxUoPhF0jiARouV48XnPdwo6pLOJTMMHsuyrkF7BYAWziBictRO0oVm D+icxhAlh8UYpLRFYv0ViMQ8yBqWiIPXtDrRxl7/QUV1LwzUn5OdCyaKI8cxmtfUkl1M 0WxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LccZbSfVbRBJBP3hDaCoexHeaPDYfSMKOISo4dOr+pE=; fh=toXMQ9nuJ3L4CLQ8EKaTQ8L/ltDlD3GauRZSJpgYVzU=; b=yfXkMFvX55ycCNHdl8SRdyu6RC3BsgmHnfv0IG05ffd2Ny8dhO3dCUd70LsaGAl/DI aiJ570TGByjpa1eI/QrFWLD0Rn2VPWRAPQ0JztcQtERVzAnQVmCrnKwmdFomF+5cT+7P odLIoAYeOJ1lIVJ1A47QOn9ule2wL+2WYtT4cNxKC0s170CVggZDasw3hLdZQY1yA9Yy 2KQ+QHME8j2ppJotXIGsESqabJ9q+nVe5FVqcB2lojNzpPT0Ka1W0JwK7oHtK4JlccI9 OzmM3KWtMkFN+f4aRDODsIy6uzPiKNYjn8jxNZXQ+pBI21Kyf4gTo5fUke4zxO8JKXMH Gqiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MADWJtaX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ew10-20020a05622a514a00b004236f259ac3si128039qtb.15.2023.11.20.13.41.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:41:14 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MADWJtaX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Manos Pitsidianakis Reviewed-by: Gavin Shan --- 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) static void process_msg_shmem(IVShmemState *s, int fd, Error **errp) { - Error *local_err = NULL; struct stat buf; size_t size; @@ -496,10 +495,9 @@ static void process_msg_shmem(IVShmemState *s, int fd, Error **errp) size = buf.st_size; /* mmap the region and map into the BAR2 */ - memory_region_init_ram_from_fd(&s->server_bar2, OBJECT(s), "ivshmem.bar2", - 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; } From patchwork Mon Nov 20 21:32:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745402 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1535262wrt; Mon, 20 Nov 2023 13:41:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IGyBxKHX5NrSCsPVo7jKaWdNGOIfynKEB2a8aXQ/1eLul+EHXYc4J7G+Cj9dq4J12krso/X X-Received: by 2002:a05:620a:6505:b0:775:9e64:f5be with SMTP id qb5-20020a05620a650500b007759e64f5bemr11313659qkn.55.1700516518376; Mon, 20 Nov 2023 13:41:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516518; cv=none; d=google.com; s=arc-20160816; b=X30sPDLq3O5re+sOkeYNcx+yeu2d9FLF7EpMNPW9ZzW2h7VuNbGBey7DeuD+Haale5 Du6n6VZqTIIYtzdz4LckAb0rLdh4nKZZ9p93tp2oUSU8Bccn46UDkIrLxijhtGEiVguX dWA3oYeYzc52XXaaU6kot63q8/Bh3+UELqYZFZhufHQe9JAnOt+6rzrfkm/QojWCiFZ3 czVX55TIVk0lyO7aV9BDSYPxPTTfuw/pYzqotaieutoP0MaOmz6ajThm0RbSWhzdSRuE TsXSwxrUuCzOLbqs5c+iVy8IELlI1uak/dVM1/RYeeH6GMLzOlA3Ry6FxWQ179XPSZv2 47bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=drwtQoQ75QuwOSsjQYja6ApK0ZWyT5mWD40njjZhqyI=; fh=AVTfbHsPJGg1WFQV1X+Bul2rECWTr55QornV8gS+Ss0=; b=jakEOezG0uGh9beGp/sVy7f64ElMWESoB1biW8MBlofKF5bewof4QTElSC0hGs5cg0 g612gAc3dQrKycA+szOc5paVXd1iMpWi/yUU5+vzeAa7gAah6yT2fDbYAOkG+ga5WlZY qPs/4aNNsVm9OZOBPIILq9uHbO9r+Fo8BHjeU9YPcQRvc9wSKA4p5wxej/OXSTEXUSqz YoZxs/3ayGYYHzDbhoAXK4xVOOnvIkQJcP3WDzw0SvE+Gt/gPX8fbWmwoeKJ+Sd8joVj iww0oKWUlnJCc3OWgQexlYFi4GbARoJOe+aN+IkWJ26bSdZXQlYSB0hgPRA5bXSN5ZFp ZlFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OCPuesFL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bm14-20020a05620a198e00b007740f1c2b49si8323619qkb.328.2023.11.20.13.41.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:41:58 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OCPuesFL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Manos Pitsidianakis Reviewed-by: Gavin Shan --- 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 = NRF51_NVM(dev); - Error *err = NULL; - 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, errp)) { return; } From patchwork Mon Nov 20 21:32:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 745400 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1535217wrt; Mon, 20 Nov 2023 13:41:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IFT5ctnM/uivE5oEsV1nx6/YSyiL1L1Wb56LN5an7akGSlXnWseLxfT7HuZoUU3bBPTnfXg X-Received: by 2002:ad4:5f0a:0:b0:677:f200:a1b7 with SMTP id fo10-20020ad45f0a000000b00677f200a1b7mr11406838qvb.51.1700516510073; Mon, 20 Nov 2023 13:41:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700516510; cv=none; d=google.com; s=arc-20160816; b=gvtEGu0Bnfsx0daIiqQwjbS5SSYAm5z/MW8ABTzJ3zdj1lsP/y63Z//wEluhBmuYtJ VKjtEdlO6sapxARoo9Sc1rjeJCX8MJj3ScdJq2dwyDDT+W3Suo2qk4AwtU0BS9JGxsYZ B+lCj+na7ejQ9UnhirolGAodqOqSb7JQV7EvZ1XCAPKwPuBenk92IO84ZRWyM9x2tKMN QMb6nnbhW1qE2Et4uaSmIvJkY70Njsi1BHBWWWSNHEty8IWb2XaQo/S0QKKMzdxwHQBf /VML724E7JDiKSBepiWo4f0bIRf0smfK3XqUFpddJlgqiBd4IiL41IhjfpccBr6GSSAC Oq/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Pno/XIMEfv6sc1E+e58IOA0UG1tXfCuf040vsihGJmc=; fh=Ljpz67KUguUCIBLeiOnmYlxWTfvg6mMKNzxYzt1oXKw=; b=zv08kl3qS0lG0HuCxHXaYilPWZWkKFR2a5GbFHsuRsbb9JQdFwx5sK9k/SMQ4ArgM/ QpFQ6syfHJA5rNXTDERXprT/beS40prARuTh8NY/1AQnyJcakKnq7QhnCF2zhRkk+U7n H2585wegEdriCmllExUR1RTkHw7hFOCdNCh8j5Wf3ZIn4Gfj2Nk6I1buTGPVr4vyazqw P4w/YkVG9MJGOywlD97tSvHy+4i6JT7kTp3M3CyYjLdpTCBMuynEIDpTMkMPa2I/eGAV UV401O8L8EFI+wfDI6PBG4qui2xUsT5KoafGfqkk7agWDQYAIBdYV0MvRDwjLjXbCEeH K/MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CF5RL0zU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id lw11-20020a05621457cb00b00679d93b2daasi2883305qvb.304.2023.11.20.13.41.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2023 13:41:50 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CF5RL0zU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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=A9?= =?utf-8?q?dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Peter Xu , =?utf-8?q?Herv=C3=A9_Poussineau?= 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Manos Pitsidianakis Reviewed-by: Gavin Shan --- 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] = 0x10; d->config[PCI_CAPABILITY_LIST] = 0x00; - memory_region_init_rom_nomigrate(&s->bios, OBJECT(s), "bios", BIOS_SIZE, - &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) {