From patchwork Tue Jun 28 04:53:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 585543 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5036:0:0:0:0 with SMTP id e22csp506235mab; Tue, 28 Jun 2022 00:23:23 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vGg6gtqD4+NH9M5SDJ4xoWta/KXAbhdJlXLrOb7M/6TsMXiOIv6w1Qp9nr1McUyDUQgS/+ X-Received: by 2002:a05:6214:16cf:b0:470:5178:ccc3 with SMTP id d15-20020a05621416cf00b004705178ccc3mr1172231qvz.13.1656401003788; Tue, 28 Jun 2022 00:23:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656401003; cv=none; d=google.com; s=arc-20160816; b=lTtblRXJMEb1MM0AndZruQXTRK/U5TCxMtZjO0WFVHIjWK0M9Trrmlx/YF6q3xG2EX yUvKEhg4SA3X8hnhp25H6AIMoGOSU/+7yD+tQ+6STCR5ru4nopAGyPHRkRs0wU0/Ud5V RyNnBU+I9//wKXo5s5SH/bysQWMr+nt5LbmYU/yt3n9iELGOAmUrpRxABf5k0xldwU24 +5Bg4Z2Qbu3NttNIx8LfNlYtCOcaW7X/4iJyVjj9BMSS8U/xjl/psKMA5Q3aGQZ1dl5L YJPTXnfg+yuN33xP07v5c7amLPyym9GVrR3yY4L5hnHdcWV+vMV42c0jf7ZuDXtOJpYp KazA== 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=S8Pjs5cOqk+oGTnK7FdV4C/Z/WLlWltx0dBsRwUkzCw=; b=tkiUoGJtFNM8KK0kYIhyWb7oSFwZJscLzTNYMEt1ag87XKz8jLmKG4cSsGOA2joqpO Y0sN3uXehOQ5P/iXMy042nWlCKCpyyEd8DRYW4wYZn9g5sMyS3zxyBgYxGScMc6GQywA bwBaLGSB8C7t9zZA73RkYbLdNka93iRjX+j8mCrVmc+CzD6WuHI7cKaWpf7Ba6dYKMen bvm3YhOKvpWaQjex8pfii7oS/FmgGkXLQz7vYvHm7TryIILVP1HspO0hbDH56dRZG7U8 z028M8G95xVo073+01JA6IbljZmWZHgEPZzg3yE4w93YOaRbBDmWLvbI0Lzo+NSjx1Lo /BTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Nggt7Fqb; 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 h11-20020ac85e0b000000b00317ac568363si7833997qtx.532.2022.06.28.00.23.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Jun 2022 00:23:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Nggt7Fqb; 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]:35722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o65ZD-0003AG-9Q for patch@linaro.org; Tue, 28 Jun 2022 03:23:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o63FG-0002nT-0x for qemu-devel@nongnu.org; Tue, 28 Jun 2022 00:54:38 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:33883) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o63FE-0008Jt-BZ for qemu-devel@nongnu.org; Tue, 28 Jun 2022 00:54:37 -0400 Received: by mail-pj1-x102e.google.com with SMTP id a11-20020a17090acb8b00b001eca0041455so11321501pju.1 for ; Mon, 27 Jun 2022 21:54:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=S8Pjs5cOqk+oGTnK7FdV4C/Z/WLlWltx0dBsRwUkzCw=; b=Nggt7FqbmwGySBd6EoF1AsxLfQWei/HVcjh6YuzAckI99FcmRmM38KF5OUjL/BLuQw 9lIjBp+r3fdx+bC2YLI8IultRc/35/VMBOUlZ5E6EdcE5X4gUbf1elbuWr3HTSitxGZN 4YiEJGU7dUK5PKkVpk5OWpniD0YNaio8lBEVe3tiQVCtqSgnNfwAV03FZr82Gojr/kw6 +YoIzXomFB8yqSi8335TlWIydPUAFLceCjQTAhTC+Bx4FaOTIaTSw2zn5f8ZJ436BKMl +N/AEoTdNiN35ET3B5qYwG/QM0OiLBlWufNmCZyLiABlJkqmx+JuYdYJhDaqPIMA2Lo2 shoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=S8Pjs5cOqk+oGTnK7FdV4C/Z/WLlWltx0dBsRwUkzCw=; b=k7HfBndfH+Tfx0FHggOI5nxEvz1VfrDszrlSuef/Z1F0fO+izrykAcTmrXpWPHDgHg DG11435hSqMHbeF0hI5uYLw0UwYkibSzOYt9wtz9saW1eUDWHgCe18/2YzVuNGUPD0lj GzFmvq1qdgiKeUu4V3S07hqgJztbVT8XFQtqicWm0irQHfJE+/rJD/rRvWfSEB8eeZek z+qy9egJDs3T63+XQpDM9J64aPjk5Dte0EZ0jCTCyKV27j5M1RV8ExtYfN2H8Io9BVYS qsWjwsc6BHH9FtvhYoyVpjJBCsvRcFkFQuTgbwpaQgsGx3dVdJf4QlB1wtNwZZJakfE3 bvOg== X-Gm-Message-State: AJIora97Vjl3kMlcToELA4mA8aYpACYwdOltDb7DJy0r+mCB08gHm0If DPipcIH5OGNrKyKdZlP0Vwpp+IMnOFabeQ== X-Received: by 2002:a17:90a:ac04:b0:1ec:81d2:739 with SMTP id o4-20020a17090aac0400b001ec81d20739mr24846127pjq.171.1656392073904; Mon, 27 Jun 2022 21:54:33 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id w8-20020a1709026f0800b00168c523032fsm8073735plk.269.2022.06.27.21.54.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 21:54:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 11/60] semihosting: Clean up common_semi_flen_cb Date: Tue, 28 Jun 2022 10:23:14 +0530 Message-Id: <20220628045403.508716-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220628045403.508716-1-richard.henderson@linaro.org> References: <20220628045403.508716-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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" Do not read from the gdb struct stat buffer if the callback is reporting an error. Use common_semi_cb to finish returning results. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- semihosting/arm-compat-semi.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index 88d6bdeaf2..cc13fcb0ef 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -346,15 +346,17 @@ static target_ulong common_semi_flen_buf(CPUState *cs) static void common_semi_flen_cb(CPUState *cs, target_ulong ret, target_ulong err) { - /* The size is always stored in big-endian order, extract - the value. We assume the size always fit in 32 bits. */ - uint32_t size; - cpu_memory_rw_debug(cs, common_semi_flen_buf(cs) + 32, - (uint8_t *)&size, 4, 0); - size = be32_to_cpu(size); - common_semi_set_ret(cs, size); - errno = err; - set_swi_errno(cs, -1); + if (!err) { + /* + * The size is always stored in big-endian order, extract + * the value. We assume the size always fit in 32 bits. + */ + uint32_t size; + cpu_memory_rw_debug(cs, common_semi_flen_buf(cs) + 32, + (uint8_t *)&size, 4, 0); + ret = be32_to_cpu(size); + } + common_semi_cb(cs, ret, err); } static int common_semi_open_guestfd;