Message ID | 20240704073544.670249-3-sughosh.ganu@linaro.org |
---|---|
State | Superseded |
Headers | show
Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp1042003wru; Thu, 4 Jul 2024 00:36:29 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUzKOQ6ZWxrFh6MtmpX8IVe3e8Q9DOt3Sjq2M/+HxFF2ox5N0ZGMfclxlvVkS1p8NH5oJgoOkpOvUl2p0dQquFf X-Google-Smtp-Source: AGHT+IHte67GTCcJh0igtxICehNEROcAYLPhQS8DLX6rk/SIdw04vhZ6rse2ZdmM8r2oQ8HCeh+t X-Received: by 2002:a17:906:ad93:b0:a77:c071:a2b with SMTP id a640c23a62f3a-a77c07124a9mr18057066b.71.1720078588811; Thu, 04 Jul 2024 00:36:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720078588; cv=none; d=google.com; s=arc-20160816; b=J/96zB129SAWD6GTzruxR1omZm1urP8Fa9txOyZNRREqc82ki7hl23IpqNRjQtsRDv b5UiH10KBY6bLMYOJXzEqUnl0OxxjSJXYfWzyQDlDsN7fNb3SwCc8c7roeVC75+UcZd1 mUNct+p59JMBJSUa0d5cWmP8vMgG5fzpPR6nAofZ2S2f0+7tFl6HP/RL7TuS8TfsYBpt zMVefaTg3I7w4Y75qMjTIQdvJSFSpnPtjWlgukNH7YBxX92oGIR7q6YBT/A0/QorIyMD sWMvO+jdkXxgT3IcumwAtsmFvoOWT/rs24ht4TRXm3reQ9sRQsJ4M+gF8zhG7Xz8/C7A Lqtg== 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; bh=p0BG8pFOrXYRqX1LnNUe0C7PL1AgkeMEZFJeVM/0Jrs=; fh=ez1zzjhC0XWyqTp7tWutqrA/nFdALDnQKrnQnXYhk5Q=; b=QrYeDOphUJedo3BWze4ubLEHcIx3NV75st1ghEDQPorjVTmIgvBk8CCOKT9tV3fYYV C9aWnkKHhjL2D1+RhiWDm5uaSdlP17RIj5g5f9q/hmxkkVNjcGAbkp7IJHdXfp/8K6Pv nZrBY6mcm6ADfTrTAjsp0XPy5W3mrBcEKV5hBjX4o8nxkjr+DP3DeW7cBroTM1fweAl2 ZcbTaPXj/8yzkTU5NOwlFjWL9xX7Gd58wjQy0mcg76amaijNG2LC4hQBTF2hRpWUTVXO XC7yqpmipiz5s51iuOp55Fz7vSoRuMHZRvbN9w0FuXKTxfLV6Abwv7xUU8UZdU/5pnBG 5Mrw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: <u-boot-bounces@lists.denx.de> Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id a640c23a62f3a-a751edd1666si464089066b.595.2024.07.04.00.36.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jul 2024 00:36:28 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D9290888B0; Thu, 4 Jul 2024 09:36:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 82453888A7; Thu, 4 Jul 2024 09:36:14 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id CC633888AD for <u-boot@lists.denx.de>; Thu, 4 Jul 2024 09:36:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 58D2C367; Thu, 4 Jul 2024 00:36:36 -0700 (PDT) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3518C3F762; Thu, 4 Jul 2024 00:36:07 -0700 (PDT) From: Sughosh Ganu <sughosh.ganu@linaro.org> To: u-boot@lists.denx.de Cc: Tom Rini <trini@konsulko.com>, Ilias Apalodimas <ilias.apalodimas@linaro.org>, Heinrich Schuchardt <xypron.glpk@gmx.de>, Simon Glass <sjg@chromium.org>, Marek Vasut <marex@denx.de>, Mark Kettenis <mark.kettenis@xs4all.nl>, Fabio Estevam <festevam@gmail.com>, Michal Simek <michal.simek@amd.com>, Sughosh Ganu <sughosh.ganu@linaro.org> Subject: [RFC PATCH v2 02/48] lib: Handle a special case with str_to_list() Date: Thu, 4 Jul 2024 13:04:58 +0530 Message-Id: <20240704073544.670249-3-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240704073544.670249-1-sughosh.ganu@linaro.org> References: <20240704073544.670249-1-sughosh.ganu@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion <u-boot.lists.denx.de> List-Unsubscribe: <https://lists.denx.de/options/u-boot>, <mailto:u-boot-request@lists.denx.de?subject=unsubscribe> List-Archive: <https://lists.denx.de/pipermail/u-boot/> List-Post: <mailto:u-boot@lists.denx.de> List-Help: <mailto:u-boot-request@lists.denx.de?subject=help> List-Subscribe: <https://lists.denx.de/listinfo/u-boot>, <mailto:u-boot-request@lists.denx.de?subject=subscribe> Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" <u-boot-bounces@lists.denx.de> X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean |
Series |
Make U-Boot memory reservations coherent
|
expand
|
diff --git a/lib/strto.c b/lib/strto.c index 5157332d6c..f83ac67c66 100644 --- a/lib/strto.c +++ b/lib/strto.c @@ -236,12 +236,14 @@ const char **str_to_list(const char *instr) return NULL; /* count the number of space-separated strings */ - for (count = *str != '\0', p = str; *p; p++) { + for (count = 0, p = str; *p; p++) { if (*p == ' ') { count++; *p = '\0'; } } + if (p != str && p[-1]) + count++; /* allocate the pointer array, allowing for a NULL terminator */ ptr = calloc(count + 1, sizeof(char *)); diff --git a/test/str_ut.c b/test/str_ut.c index 389779859a..96e048975d 100644 --- a/test/str_ut.c +++ b/test/str_ut.c @@ -342,9 +342,7 @@ static int test_str_to_list(struct unit_test_state *uts) ut_asserteq_str("space", ptr[3]); ut_assertnonnull(ptr[4]); ut_asserteq_str("", ptr[4]); - ut_assertnonnull(ptr[5]); - ut_asserteq_str("", ptr[5]); - ut_assertnull(ptr[6]); + ut_assertnull(ptr[5]); str_free_list(ptr); ut_assertok(ut_check_delta(start));