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 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 62C00C77B72 for ; Mon, 17 Apr 2023 20:17:22 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1E34385FFB; Mon, 17 Apr 2023 22:17:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.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=linaro.org header.i=@linaro.org header.b="TFFcbvCl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E9F2285FE8; Mon, 17 Apr 2023 22:17:17 +0200 (CEST) Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 394A485FAC for ; Mon, 17 Apr 2023 22:17:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ralph.siemsen@linaro.org Received: by mail-qt1-x82d.google.com with SMTP id ff18so4075500qtb.13 for ; Mon, 17 Apr 2023 13:17:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681762634; x=1684354634; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=F9QRytJvAn1l5KXXVNSYVapyPX1aGSEji23QUu223HI=; b=TFFcbvClyWf4EqExWRw3E/NNYScSgZw8+JIyAxZLKVLK3d3Fnp7JcrxtgTGMkoEDEv ZrXYHJbnex7ft8gVjh4BGQ2ThvjmGvEroxImscHA4LeIWTBp//uAzYS6eoV89oh3wPFF b6LPOPD1Kh9zy1RPkhXxQJ1cF6Qt8jymSxa0vHK571mgImqErxyP+xU6/gqJM8Cayi1q kOoZLbbUI+Ih6mI4sX7Od2T3Iv4R2lk9czzBblDwFJ2e+8a5HLb3RPZYA/8NqfX0OrO2 a3bhScKnw7XjJ5ftN5VMGVGGkMVMxR7TrFwjvt1V6a6hppsZkSJkZ6UF8AgSYP5nyoMA XiUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681762634; x=1684354634; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=F9QRytJvAn1l5KXXVNSYVapyPX1aGSEji23QUu223HI=; b=Ioy32ulUH+VqgfzzqiknEt7PTTX/JR37vUJJ4d4XPsXXJb+HD2NNkH7HbPBwIuGDuh 2O450/msj7sOrX8S3CASMegUCvXP/9rGB3BMkIBpruwdQ2vjCgzbv8PI+XUg3e1Svl0Q md6hoPGy+Fvw3cVeXQU9kPT1h18w6Ik2KTSXYEiyf3LuvnnZbtiewu0SGfQB8kigQECz BaUF90FC0/0PEDCHCS3sZqVzvNE9tEdNpKncHL1PxcYy073Aeh2g4mUs7eUja6FmzdNQ lKeANV0C9khalf7guyYYHK9SYa/BGBLvRxO2mq+78LDKjf+8cu/E4bLRycgVysJs8aqq eKuA== X-Gm-Message-State: AAQBX9e7Tsg9iL/a0VJYHp2HowrLy3AzOj6v3ZNeMabk9e7ZjC/qqTQk 88sZScWm0api0A68bNYM/3Kd9g== X-Google-Smtp-Source: AKy350ZC/Oq/8TWHa1xESfAlXIFDJBFMUgYcNVqVqBduCYnEtNuZzovqANqz6Vto4dChzHbL6a5BcA== X-Received: by 2002:a05:6214:4106:b0:5ac:fb9a:67a1 with SMTP id kc6-20020a056214410600b005acfb9a67a1mr18008436qvb.47.1681762633872; Mon, 17 Apr 2023 13:17:13 -0700 (PDT) Received: from localhost (rfs.netwinder.org. [206.248.184.2]) by smtp.gmail.com with ESMTPSA id ev12-20020a0562140a8c00b005ef42464646sm2864922qvb.118.2023.04.17.13.17.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 13:17:13 -0700 (PDT) Date: Mon, 17 Apr 2023 16:17:12 -0400 From: Ralph Siemsen To: Marek Vasut Cc: u-boot@lists.denx.de, Simon Glass , Andre Przywara , Heiko Thiery , Heinrich Schuchardt , =?iso-8859-1?B?Suly9G1l?= Carretero , Marc Kleine-Budde , Massimo Pegorer , Max Krummenacher , Pali =?iso-8859-1?Q?Roh=E1r?= , Philippe Reynes , Samuel Holland , Sean Anderson , Steven Lawrance , Sughosh Ganu , Weijie Gao Subject: Re: [PATCH v4 09/10] tools: spkgimage: add Renesas SPKG format Message-ID: <20230417201712.GG642444@maple.netwinder.org> References: <20230308202653.1926303-1-ralph.siemsen@linaro.org> <20230308202653.1926303-10-ralph.siemsen@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: 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 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(). >>+ 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: line[strcspn(line, "\n")] = 0; Ralph