From patchwork Tue Mar 15 12:12:50 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: 551441 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp3410586mag; Tue, 15 Mar 2022 05:21:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeUgC7BgbY2aDYwes6GaPoKfJ05GJx1DhAFL1fhfFdDSxIrTVSrnuUfvVytbwkk8rgpjoS X-Received: by 2002:a81:a888:0:b0:2e5:7ae9:c91b with SMTP id f130-20020a81a888000000b002e57ae9c91bmr5690632ywh.400.1647346861740; Tue, 15 Mar 2022 05:21:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647346861; cv=none; d=google.com; s=arc-20160816; b=ET1cMhFOVEJHgbyHSY5r4JUfFlhcYR4ABJCzwrh8ddLanTyApVZ99L+nDzfXkD+A3l eSvBjOjEYJsSploLxUeqzKdWfzKy+yPtFnluAueldfEENcz46C8epBUNqQlQnFPu3Gxu FYco3YJM1Jo6nW+KGYLMFdm+EXrOu5A4Ahuabopg95kAmA7XgCwFaGJHja1ZpMdFUJ2e 5pL/CUWW6HZ0u5X8uWsOXxEMlo7zunBiGJAjrmi8h0XUql/vVYfYKqqbqj69wMf1Zeiy 4WNmlZxpZVYHc7jhxA3k9hjxvc2y5tevbA7vAyVtexqfdNnQ4VP87GSJn+uzZ8ArZEm+ JROg== 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=n4AELCoGsLjX+oRgyXcZMzmt/98I/pjWm2s8I0CPR0o=; b=WbUbju6iGfC1cRix3lsoWimJilax0S2H9rG6cjtz8s5wdUMkpQy5orL6G9aymxvfMs fAkEe5Xj527Rp5LrX5RTJhvhacYOhnDwvculXNmZd0sQ90MoP4f0B0bLK3Z7+osYpY43 IdUjPhTO4Pw7KuBHqciDwtUja4yaV97+yn6Uw5g1GyClGsL1qVa7ZXU2pjjynG8jH3Hw zEGMZuIfoyozOCWm7Dz6EwigF9l4Z7x+eA//W5efPBlxz+cn5rhDeFr590RaqEZ+xfQj lU6Pe9WwyV9fBO0bM62ujSIl0/tKl+1AJ+eYFtMR/e0fzAfB/DKA7HO0v6GNwitZLRvm ztJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=x1E6wvxV; 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 b66-20020a0df245000000b002d035ccf9basi11094546ywf.94.2022.03.15.05.21.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Mar 2022 05:21: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=x1E6wvxV; 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]:38324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nU6Af-0005AY-7b for patch@linaro.org; Tue, 15 Mar 2022 08:21:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nU630-0005wv-1g for qemu-devel@nongnu.org; Tue, 15 Mar 2022 08:13:09 -0400 Received: from [2a00:1450:4864:20::532] (port=38877 helo=mail-ed1-x532.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nU62y-0000bP-5h for qemu-devel@nongnu.org; Tue, 15 Mar 2022 08:13:05 -0400 Received: by mail-ed1-x532.google.com with SMTP id h13so23904881ede.5 for ; Tue, 15 Mar 2022 05:13:03 -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=n4AELCoGsLjX+oRgyXcZMzmt/98I/pjWm2s8I0CPR0o=; b=x1E6wvxVO1ilXSwrleQtwxCERK0dObRa5MWC+dRKWAhLEJdTPoZAJga48ZphhAVolq fu7UcQEMAaSh1UHpor8M5OW/IBX16XJ/A0PQOk7rGJ/9XNaC4kuorvQaevQpg/N54NHX l8tuHz+TFHUkBVeuqJcMMORyv7m1I5M8ruEZUV1rHq5a5xNLXPt/lJt5nIeAh5yJ+Ens WDNZI8YizgAHkzNSp2tpWnWPfW01Wf1rWa4BMbnyYD00kWTcgxGFMw5oKfCGZWG6ByTw P6mAoaIrTLygiHB1K0QtGL+2QRk5WeMqiYE3MYaPSxbyyXTej0jTTvrhrrt48XVFOZ45 3FyA== 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=n4AELCoGsLjX+oRgyXcZMzmt/98I/pjWm2s8I0CPR0o=; b=ZVw9g8r4n0C/bR7VRUrxKZfZcnGdnnWasAxmrbXf++RDdt8pkuuKsNl9o/WPelDS9u wmZwcbla4U+aOZ2X5je0k/DihLL+8ISVhexOnoIPM7H4VIngtyLQ4oIm44vpVljepFos +jediL0ID4T5UMP6TwEy7zM64o9Rsos0h8pl1LCBC71NigObz5wMnxYxTj1Dj3iEMjrg SsHnkoRKP90r8cVJbb7bv5oNo+6g6kwGdz2e3+0Pq+9z/6JuOBJBi1Ev6wUienlDGygP uWYE/sPqlq0eohyXZUNJFKk19w6PSViYZ3PYM3vfVyrBKPMsu9MYcWYSu0Gg5ZBkF88l HU0g== X-Gm-Message-State: AOAM533ivPgq8NttDkhDiblxYZyTfzbh7Jrj3YtD5V8ZNfteFa/3qcTs iKvnyNcNTaClcXMv5nvVpy0SBA== X-Received: by 2002:a05:6402:4396:b0:418:d776:14c1 with SMTP id o22-20020a056402439600b00418d77614c1mr337996edc.127.1647346382827; Tue, 15 Mar 2022 05:13:02 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id qa44-20020a17090786ac00b006dbe1ca23casm1817451ejc.45.2022.03.15.05.12.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Mar 2022 05:12:58 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C02601FFBF; Tue, 15 Mar 2022 12:12:52 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 7/8] semihosting: clean up handling of expanded argv Date: Tue, 15 Mar 2022 12:12:50 +0000 Message-Id: <20220315121251.2280317-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220315121251.2280317-1-alex.bennee@linaro.org> References: <20220315121251.2280317-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::532 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::532; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x532.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: fam@euphon.net, berrange@redhat.com, sw@weilnetz.de, richard.henderson@linaro.org, f4bug@amsat.org, qemu-arm@nongnu.org, stefanha@redhat.com, crosa@redhat.com, pbonzini@redhat.com, =?utf-8?q?Alex_?= =?utf-8?q?Benn=C3=A9e?= , aurelien@aurel32.net 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é --- semihosting/config.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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;