mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <sha@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH master 1/3] common: machine_id: simplify early exit
Date: Mon, 8 Aug 2022 13:43:39 +0200	[thread overview]
Message-ID: <06be733d-03f6-4bc5-0b40-c1f763728e60@pengutronix.de> (raw)
In-Reply-To: <20220808114024.GH7333@pengutronix.de>

On 08.08.22 13:40, Sascha Hauer wrote:
> On Mon, Aug 08, 2022 at 08:20:08AM +0200, Ahmad Fatoum wrote:
>> We don't need the goto if we haven't done anything to clean up anyway.
>> also globalvar_add_simple("machine_id", NULL) is a no-op when we have
>> just called globalvar_add_simple above with an actual argument.
>> It doesn't clean the parameter, nor should it, because the code is
>> executed for the successful code as well and there is nothing that can
>> fail that late.
>>
>> No functional change.
>>
>> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
>> ---
>>  common/machine_id.c | 6 ++----
>>  1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/common/machine_id.c b/common/machine_id.c
>> index 6480806cd287..a530fdeb1da8 100644
>> --- a/common/machine_id.c
>> +++ b/common/machine_id.c
>> @@ -30,11 +30,11 @@ static int machine_id_set_globalvar(void)
>>  	unsigned char machine_id[SHA1_DIGEST_SIZE];
>>  	char hex_machine_id[MACHINE_ID_LENGTH];
>>  	char *env_machine_id;
>> -	int ret = 0;
>> +	int ret;
>>  
>>  	/* nothing to do if no hashable information provided */
>>  	if (!__machine_id_hashable)
>> -		goto out;
>> +		return 0;
>>  
>>  	digest = digest_alloc_by_algo(HASH_ALGO_SHA1);
>>  	ret = digest_init(digest);
>> @@ -58,8 +58,6 @@ static int machine_id_set_globalvar(void)
>>  	free(env_machine_id);
>>  
>>  out:
>> -	globalvar_add_simple("machine_id", NULL);
> 
> Without this patch we always created a global.machine_id variable,
> either empty or with a value. With this patch we only create this
> variable when it's non-empty. I think this change is ok as we also
> don't have this variable when CONFIG_MACHINE_ID is disabled.
> 
> Still the "No functional change" doesn't hold true, so we should remove
> it from the commit message.

You're right. I missed that. Can you replace the last line with:

  This slightly alters behavior: Whereas before $global.machine_id was
  always defined when CONFIG_MACHINE_ID is enabled, it's now only
  defined when it's non-empty.

Thanks,
Ahmad

> 
> Sascha
> 


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



  reply	other threads:[~2022-08-08 11:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-08  6:20 Ahmad Fatoum
2022-08-08  6:20 ` [PATCH master 2/3] common: machine_id: guard against digest algo being unavailable Ahmad Fatoum
2022-08-08 11:48   ` Sascha Hauer
2022-08-08 11:50     ` Ahmad Fatoum
2022-08-08  6:20 ` [PATCH master 3/3] crypto: restrict digest algos implemented in ARM assembly to 32-bit Ahmad Fatoum
2022-08-08 11:40 ` [PATCH master 1/3] common: machine_id: simplify early exit Sascha Hauer
2022-08-08 11:43   ` Ahmad Fatoum [this message]
2022-08-09  4:41 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=06be733d-03f6-4bc5-0b40-c1f763728e60@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=sha@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox