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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 52BF1C77B72 for ; Mon, 17 Apr 2023 20:28:30 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6234585F7B; Mon, 17 Apr 2023 22:28:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.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; secure) header.d=mailbox.org header.i=@mailbox.org header.b="PADHOwfX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B555385EA1; Mon, 17 Apr 2023 22:28:26 +0200 (CEST) Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [IPv6:2001:67c:2050:0:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7BF27856E5 for ; Mon, 17 Apr 2023 22:28:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4Q0dsy536Nz9sjL; Mon, 17 Apr 2023 22:28:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1681763302; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=laNY8V6VSxAM9R3XA3nbAHR5kGWYGZeYNcst7FTXO3g=; b=PADHOwfXSD71Mp8VzQMevcoeEgO78ksEj3nTnuDdZb6hzzPaEFIIMJp/T6/e1nrqC2a5jt jVRn8/ucucqQy7WL3UAVeRr73ZRkhF9Q1aw98FnzdxQYak2lqB56oOAv9JQ5ec93sVx6td 8IJrWolVPGJRFqJq/zDNMqMOw+O32WAMp9Upvhll/LWSF6OtI0ylg9TCs9AG/rWtJDIrAj ruFZGyW6X2iOuPMAn53X5UCotvyjfpYIdWoINAXARntXTHixRBGPs3xd2FiK7ig5dAoj3c 77WhLvHZkwk0fUSLVrqNa4c/3XqgMbYP1wCTy/OuCuIbd7/uqoLO7oXVyt0W7w== Message-ID: <5e4bd65b-3e2d-107d-aa8b-87237349f3f0@mailbox.org> Date: Mon, 17 Apr 2023 22:28:19 +0200 MIME-Version: 1.0 Subject: Re: [PATCH v4 09/10] tools: spkgimage: add Renesas SPKG format Content-Language: en-US To: Ralph Siemsen Cc: u-boot@lists.denx.de, Simon Glass , Andre Przywara , Heiko Thiery , Heinrich Schuchardt , =?UTF-8?B?SsOpcsO0bWUgQ2FycmV0ZXJv?= , Marc Kleine-Budde , Massimo Pegorer , Max Krummenacher , =?UTF-8?Q?Pali_Roh=c3=a1r?= , Philippe Reynes , Samuel Holland , Sean Anderson , Steven Lawrance , Sughosh Ganu , Weijie Gao References: <20230308202653.1926303-1-ralph.siemsen@linaro.org> <20230308202653.1926303-10-ralph.siemsen@linaro.org> <20230417201712.GG642444@maple.netwinder.org> From: Marek Vasut In-Reply-To: <20230417201712.GG642444@maple.netwinder.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-MBO-RS-META: nsd6nmdqu3ud965o5a9xj3nisce1n7h4 X-MBO-RS-ID: d816d6fe872ff876ce7 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean On 4/17/23 22:17, Ralph Siemsen wrote: > On Mon, Apr 17, 2023 at 07:23:46PM +0200, Marek Vasut wrote: >> On 3/8/23 21:26, Ralph Siemsen wrote: >>> +            spkgimage.o \ >> >> Maybe just call the file renesas_spkgimage.o so its clear which >> SoC/vendor this file is associtated with. > > Okay, will do. > >>> +static struct spkg_file out_buf; >>> + >>> +static uint32_t padding; >> >> Is this padding here and the padding in struct config_file below >> different padding ? Can we get rid of these static global variables ? > > I will give it a try. > >> >>> +static int check_range(const char *name, int val, int min, int max) >>> +{ >>> +    if (val < min) { >>> +        fprintf(stderr, "Warning: param '%s' adjusted to min %d\n", >>> +            name, min); >>> +        val = min; >>> +    } >>> + >>> +    if (val > max) { >>> +        fprintf(stderr, "Warning: param '%s' adjusted to max %d\n", >>> +            name, max); >>> +        val = max; >>> +    } >> >> There is a macro clamp() which implements range limiting . > > Thanks for pointing that out. However I think there is value in the > diagnostic print when the value is clamped. Ideally it should help the > user to fix their invoking script/binman/etc. > > Of course, I could call clamp() and check if the value differs, but that > seems just as complex as the check_range(). ACK >>> +    while (fgets(line, sizeof(line), fcfg)) { >>> +        line_num += 1; >>> + >>> +        /* Skip blank lines and comments */ >>> +        if (line[0] == '\n' || line[0] == '#') >>> +            continue; >>> + >>> +        /* Strip the trailing newline */ >>> +        len = strlen(line); >>> +        if (line[len - 1] == '\n') >>> +            line[--len] = 0; >> >> Use len - 1 here too to avoid confusion ? > > Old habit. I always try to update the length in sync with modifying the > string. If done as a separate line/statement, it is more likely to be > lost during subsequent modifications. > > In this case I do not need "len" at all, so I could just do: Nice