From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C5BAC433F5 for ; Fri, 5 Nov 2021 11:24:48 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5DE2360240 for ; Fri, 5 Nov 2021 11:24:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5DE2360240 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E31FF836A7; Fri, 5 Nov 2021 12:24:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="aUvQ7130"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 31067836E4; Fri, 5 Nov 2021 12:24:43 +0100 (CET) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E86D08365C for ; Fri, 5 Nov 2021 12:24:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kabel@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id 9896A6124F; Fri, 5 Nov 2021 11:24:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636111478; bh=TomDNMsIXTYJXEZ8cxLSBG90H3dF1l5tvGqHBnu2nwg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=aUvQ71302AtsyINVYMLj3NjkkX6Ci2HVtzr9j0n5rxpeHowHlscOexP8lnRMBxrYq 2bDUQWjhjZOBnC02aqt4oTscP/v2ADj09bjSLeKosMV5a+CFXuiqAxZT/1izkZhQXn OJzVmgEJG7Gdkv+lWZsmknjrUb8840RADh+3/ebfxS/LuU0QTRfq96Kw8kxztKskI5 8J1T0JHHApTVD/a3wL5hC35LHNX/FUwq7TTlPRkPSAnpgmnSy8/lBUEdE3VZPj/Kk3 UHCJDGHl7m86PZfJHA5wkHcj1hW77BJoYv5dzO8ujyGi1nY7jHZ4fGmVSXCQ+cK7Wo s7R6N4q1qqY5g== Date: Fri, 5 Nov 2021 12:24:34 +0100 From: Marek =?UTF-8?B?QmVow7pu?= To: Simon Glass Cc: Pali =?UTF-8?B?Um9ow6Fy?= , u-boot@lists.denx.de, Marek =?UTF-8?B?QmVow7pu?= Subject: Re: [PATCH v2 08/12] sysinfo: Add support for iterating string list Message-ID: <20211105122434.69da4c7e@thinkpad> In-Reply-To: References: <20211103232332.2737-1-kabel@kernel.org> <20211103232332.2737-9-kabel@kernel.org> X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On Thu, 4 Nov 2021 20:02:29 -0600 Simon Glass wrote: > Better to make iter a struct sysinfo_str_list_iter, I think and > require the caller to declare it: > > sysinfo_str_list_iter iter; > char str[80]' > > p = sysinfo_str_list_first(dev, i, &str, sizeof(str), &iter); > ... > > Do you need the iter? > > If you want to support arbitratry length, I suppose that is OK?? But I > don't like allocating memory unless it is needed. Well if I am iterating through default environment variables overwrites, they can be basically up to ENV_SIZE long. There may be some long commands stored there. Another solution would be to redesign sysinfo_get_str() and introduce sysinfo_get_str_list() so that they won't fill a buffer given by user, but instead have their own buffer in implementation and return const char * pointer. Marek