From patchwork Wed Mar 23 11:27:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 553742 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp3307017mag; Wed, 23 Mar 2022 04:37:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZvgCot+W4Wd5mVYkMnglRDltWFeewgqZDZrDyrdhgfKAkkXMYnUpTXxV6CHosJ0TP5ez8 X-Received: by 2002:ad4:574d:0:b0:438:63d:1813 with SMTP id q13-20020ad4574d000000b00438063d1813mr23219370qvx.117.1648035421010; Wed, 23 Mar 2022 04:37:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648035421; cv=none; d=google.com; s=arc-20160816; b=MOFs4kYMQ3zwO6Kl44FTQUvrmZNAUZ+7lV7H5vRh4QY241peUyj7zoFksTHJJurDPU 8OKEJkHKhu2WrLBZTyrhAEeACZsyxWpdqr9O2nwluxePTpA8qqE7M7LmAcL7G54ArxdX YRKGvjXkJWZDqPhiUBYChQfDLmXYQdD39fCbXSRVxlJqczu2bOjJQwfI411CPsk1DTbs E3IPnOabzEAvuqLjpNDgvUvJ1JTN7g4Knl6M8P7/uLYyveOCzPpzA+yTU3BMW+blBmqO M4bxvWpwDBgVA424M3z4G9B9FfFB/5Jp1VyCVjg2sJNj5zYAi/1EAFrG/zu6HQZHEaJY X6dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dkim-signature; bh=JTAHdHlMlH0xEXpmrIT2kxqzPVJkLuBJDngJ0VV9eHg=; b=mBAToDdMs3Mrn0OxAAl1XUJoh6aAzHf1IbUw/i0P7n6ZaCocIUwcmbKnucrLEOfB2d NMPcTjtUsC11o3ecbUSLmTdseoZ0e/OCqQ0OKmM8t3DF/3ebmFPP1dGojglLM6No3N+H wkTCzNhCzrxjuiU17+T9H43DpgJb7H6E/NoaWAJGO1W2Qvyb4VpG2IBLfMA/vbbHxui5 Ugww1TEHJmJAQ/WY+DtmGuGTmb9BrieGdaARqj7D/Rv7/5hYn224VXGmW18NYXkG5VZJ iEO5dr6L4rVLdBUW2HAr1Ic74eSObgPA608NbqBRvH630ORO++Hl0okMO+7drhN+d6aU 2wAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GG+HpQdW; 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=fail (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 y2-20020a37e302000000b0067e4be239c6si3421589qki.523.2022.03.23.04.37.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Mar 2022 04:37:01 -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=fail header.i=@linaro.org header.s=google header.b=GG+HpQdW; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWzIS-0001tI-JT for patch@linaro.org; Wed, 23 Mar 2022 07:37:00 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWz98-0001vx-0y for qemu-devel@nongnu.org; Wed, 23 Mar 2022 07:27:22 -0400 Received: from [2a00:1450:4864:20::42d] (port=38890 helo=mail-wr1-x42d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nWz96-00064g-MY for qemu-devel@nongnu.org; Wed, 23 Mar 2022 07:27:21 -0400 Received: by mail-wr1-x42d.google.com with SMTP id t11so1655766wrm.5 for ; Wed, 23 Mar 2022 04:27:20 -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=JTAHdHlMlH0xEXpmrIT2kxqzPVJkLuBJDngJ0VV9eHg=; b=GG+HpQdWyqYxIhIkyQr3KsF3XRCqX52f2nF7oK76fEAxtRNifPbXd0TJQwY4PzyIVJ 8NZ5lLsrYfyDbTdwxdqrltv9irztqxokZtRnjKqWVjRuV5TbAQfbHrsQxIIIgUmXuEeW l1gnNapnXAdbgmFaR/sCJgXWHaimwhCPt5oXohiwbDMs8zjlfFsAvF0hoeuqxYHtvUxW SNB/uUfMgP1TMVP+CEQS93FYDHHIS/6+UdyQYaRMHtIdDeNY7nZWLkDUeKmL2pKB4X8Z 1X8dDDb1zXhP5McCstMgVw+eewXML14c/iS9veuMH3xxifHdG1bxjfNhbL6nZpj1ESQF SebQ== 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=JTAHdHlMlH0xEXpmrIT2kxqzPVJkLuBJDngJ0VV9eHg=; b=XaeR//r2Ib4Rz3xucGck2LVa/Z9zgVVA+OQyHCL02WYPzG0EoKszxT+7LAHeq5Msqw mJPN16GPsS4GI7axQSHcKx5WfIT9Hf05fv/8/0CbcVh9kiLBmrDga7vI5XxQz+BJ2030 5bRqXKN+nyVp8QfyO2IYKNGDW2PHt96RNBGqFgEvLhoZJkwTmDecKm5SsJIZaupx3MZa CEl/uwqrY5ditjHKJqBmo8Jm+2nxd6CI/iWr2Fng3rhk2EPKKQq/Roda2Dfg/2mMmwzx wq6MZx+NneMb6OheHBqNCCLeBl+J0B4bkGYxBjFnPqEuvJqOXJoUVInCO0lh2Jq0k+cv cN4Q== X-Gm-Message-State: AOAM530pjGz/HRxGJzsJLd/mFqkZYsLeqzlIMnt14hTOVB5/aVo2XeUj I3X2+6ORJMUICgt1qtVk6JfIFQ== X-Received: by 2002:a05:6000:144c:b0:204:1cc6:7194 with SMTP id v12-20020a056000144c00b002041cc67194mr9442474wrx.255.1648034839090; Wed, 23 Mar 2022 04:27:19 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id p8-20020a5d59a8000000b00204178688d3sm7065025wrr.100.2022.03.23.04.27.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Mar 2022 04:27:17 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E68D61FFBD; Wed, 23 Mar 2022 11:27:11 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 5/8] semihosting: clean up handling of expanded argv Date: Wed, 23 Mar 2022 11:27:08 +0000 Message-Id: <20220323112711.440376-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220323112711.440376-1-alex.bennee@linaro.org> References: <20220323112711.440376-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42d (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42d.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Another cleanup patch tripped over the fact we weren't being careful in our casting. Fix the casts, allow for a non-const and switch from g_realloc to g_renew. The whole semihosting argument handling could do with some tests though. Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20220315121251.2280317-8-alex.bennee@linaro.org> diff --git a/semihosting/config.c b/semihosting/config.c index 137171b717..50d82108e6 100644 --- a/semihosting/config.c +++ b/semihosting/config.c @@ -51,7 +51,7 @@ typedef struct SemihostingConfig { bool enabled; SemihostingTarget target; Chardev *chardev; - const char **argv; + char **argv; int argc; const char *cmdline; /* concatenated argv */ } SemihostingConfig; @@ -98,8 +98,8 @@ static int add_semihosting_arg(void *opaque, if (strcmp(name, "arg") == 0) { s->argc++; /* one extra element as g_strjoinv() expects NULL-terminated array */ - s->argv = g_realloc(s->argv, (s->argc + 1) * sizeof(void *)); - s->argv[s->argc - 1] = val; + s->argv = g_renew(char *, s->argv, s->argc + 1); + s->argv[s->argc - 1] = g_strdup(val); s->argv[s->argc] = NULL; } return 0;