From patchwork Fri Jan 5 15:42:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 760212 Delivered-To: patch@linaro.org Received: by 2002:a5d:678d:0:b0:336:6142:bf13 with SMTP id v13csp108780wru; Fri, 5 Jan 2024 07:56:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IH/ZvB3zqzLKDKJ6eWFXmckO4RQnPutosIdB09OzsedaOZnMxYLMD/GtTud1U+yEFkinScK X-Received: by 2002:ad4:5aab:0:b0:680:53c:5e5a with SMTP id u11-20020ad45aab000000b00680053c5e5amr2499282qvg.114.1704470184674; Fri, 05 Jan 2024 07:56:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704470184; cv=none; d=google.com; s=arc-20160816; b=zLBY3MofmnPAc9PDC7X2/g8TV1+npjl4aPbYpfeN1qBYhFr86es7ZWZQzNcxb7e9YF 7B07SE1QFj84FZk6mAwm9LFcl0xPyAuIftgevKHIOSCx6Hk/kgwc6W4qPBNBG4aN2xp4 wAUxAJeYJ0MAH3eE91IMDyJOjNFEr6TecX4c2kzG85NB8kuEkLHl1dNzWIl62wcv5CHz uLXDWJpgB8liOk2uKyj3QUYOx/a2uD5vs2IP8ZvPwrg7j0xEsHbJkG710ahjwyiEyQc1 WZ0XBu0r3lajx6IPEzs+SXI258Tadgr77Z5xUlrpT+OZaBclVGOPlYzt04MXtz/CmndJ feHg== 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=/qHj/5uAdYCvRnDozLLxG4HVXbbh9wIM2eiBwuzcy8E=; fh=PC1N9TByiSiFL4HDhxWgbHq+kzV4suSQZA+CstPXMFM=; b=xB4s9SYVoJidpNJ//5whIt2UldhF+7aXcyZJl+VpfoLLAGQ9lGai+k7NSfaIGzZG8u HTkD1hIvVUqmQFlGt8IojnLR0sN8TK7JYl+NKB9tj4UF2g+3axOJhKugRnvmNYbUCx7n 7Kzd2LWf6t/91cqPW4frkw0bN8XTRnTG4SyfCZuSqUh6JnBfn8PYNy6w+O8dCI+FUjvV 9KePVmZ7pI2jyN6kPmXR++i2ZLnVd72KIPcBG//yAS+DJxlM+fRQwMSO8YCfVGUC5i7m 1fzPTaX7a3ieT7MvNZLWHR97GameDOGGGv8tzv8SmW+B3frwiUJ2VmFt+G4sSv+dZyow OY4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O6thLAWU; 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 w8-20020a0cdf88000000b0067f2c23a115si2025111qvl.163.2024.01.05.07.56.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jan 2024 07:56:24 -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=O6thLAWU; 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 1rLmTR-00034u-4i; Fri, 05 Jan 2024 10:51: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 1rLmS7-0007pc-HB for qemu-devel@nongnu.org; Fri, 05 Jan 2024 10:49:44 -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 1rLmS4-0000au-TP for qemu-devel@nongnu.org; Fri, 05 Jan 2024 10:49:42 -0500 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-336746a545fso411337f8f.0 for ; Fri, 05 Jan 2024 07:49:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704469775; x=1705074575; 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=/qHj/5uAdYCvRnDozLLxG4HVXbbh9wIM2eiBwuzcy8E=; b=O6thLAWUIs+mpGnt3fcHUY2d+6DiM5HlAlAv/iQ7Fr0KqxtaYdnmgujwU5LX4cOHnI TRBPVsIdGacvsdSE4JULGcXZ37MXJyoZMGi2J97hGoOGpnNnppIJbVsShplKGBxtE7K2 Ro+YfmT04YRZ5Oo4QY4PsWJ8Kxm+KywzbePWYvGxTzFUfJGTqeNtoHhiSg4pJqjGlK7r 7nTpn/8XYky0sGBDkaOBw2PjzQZUNNgxrcJt5UbWbUrHP6P2MKL0oypX11k2hMpg/VZP Z1pOnAzb9gCSA1gVhgFS8HM3IkswqKhqFwK4A7P7Fea/yRPYwZDmcjq2SV8bxaOym+io 5kFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704469775; x=1705074575; 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=/qHj/5uAdYCvRnDozLLxG4HVXbbh9wIM2eiBwuzcy8E=; b=QOwx7zbq9vj8smNJq0aXfB70+K+RYGNxmr25byXQzme0RPpWAFqXkyaMJLEGRsirhF FUBHv1irj60PzT+Q34+ITdIhB682nXH0GtpGI/PdtG+k2Sc4a2xtqcW4ccLpzCsNce6n SxPSUbBuKLdIpW+6rcmfpEuASF0FgO0hBHpQZabqobliaarE57ttmWEUL2g7rwpWb57X Znq333g/KDoWh1EM5hN0jN9WJHiBis9x/0M/bIlQlfMNjflnfMHIBcgv2siIt1bZYOhQ wWcXJ03VJCclx+D1DSITYP4g/v/T7SjpLri4atSdDzYvMkcNDSsxHqg213dCDG7K7W0h Fsuw== X-Gm-Message-State: AOJu0YybH2z+GqTm9FMBDNeJmVKR81heU/SxB+nYC0G9NsV0FgLm7HGq VOfd/m1UV/4LdkL35oRfTiymlOs+h5KjPk9oK6Yz8g7jjOo= X-Received: by 2002:a5d:42cc:0:b0:337:5c9c:2a52 with SMTP id t12-20020a5d42cc000000b003375c9c2a52mr361625wrr.20.1704469775442; Fri, 05 Jan 2024 07:49:35 -0800 (PST) Received: from m1x-phil.lan (juv34-h02-176-184-26-1.dsl.sta.abo.bbox.fr. [176.184.26.1]) by smtp.gmail.com with ESMTPSA id cs18-20020a056000089200b00333359b522dsm1615912wrb.77.2024.01.05.07.49.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 05 Jan 2024 07:49:35 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, qemu-arm@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , Andrew Jeffery , Gavin Shan , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Joel Stanley , Jean-Christophe Dubois , =?utf-8?q?Herv=C3=A9_Poussine?= =?utf-8?q?au?= Subject: [PULL 63/71] hw: Simplify memory_region_init_ram() calls Date: Fri, 5 Jan 2024 16:42:56 +0100 Message-ID: <20240105154307.21385-64-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240105154307.21385-1-philmd@linaro.org> References: <20240105154307.21385-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 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 Message-Id: <20231120213301.24349-21-philmd@linaro.org> --- 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 e602ca5e14..1830e1d785 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 b35f8ba112..e6ec4b4c40 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,