linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Julien Thierry <julien.thierry@arm.com>
To: Joe Perches <joe@perches.com>, linux-efi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: Re: [PATCH] efi/fdt: Indentation fix
Date: Mon, 29 Oct 2018 09:45:44 +0000	[thread overview]
Message-ID: <d7d0641b-f2a5-a51b-f52e-3db3b873f209@arm.com> (raw)
In-Reply-To: <61d7bd590527166c58670b4c0ab65a08710f81cf.camel@perches.com>

Hi Joe,

On 02/10/18 17:05, Joe Perches wrote:
> On Mon, 2018-10-01 at 11:29 +0100, Julien Thierry wrote:
>> Closing bracket seems to end a for statement when it is actually ending
>> the contained if.
>>
>> No functional change/fix, just fix the indentation.
> []
>> diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c
> []
>> @@ -381,7 +381,7 @@ void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size)
>>   			}
>>   			*fdt_size = fdt_totalsize(fdt);
>>   			break;
>> -	 }
>> +		}
>>
>>   	return fdt;
>>   }
> 
> Hello Julian.
> 
> [trivial style bikeshedding follows]
> 
> I think it better to add braces to the for loop so
> this stands out better.
> 
> Also, I would generally write this so the if test is
> reversed and uses a continue so the match block saves
> an indent level.
> 
> This is the only use efi_guidcmp with a == test in
> drivers/firmware, so perhaps remove that and use ! as
> the other uses have no == or != test.
> 
> Lastly, a direct return might be better and the return
> fdt could be removed and converted to return NULL.
> 

The suggestions make sense, I'll respin this taking your remarks into 
account.

Thanks,

> Something like:
> ---
>   drivers/firmware/efi/libstub/fdt.c | 29 +++++++++++++++--------------
>   1 file changed, 15 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c
> index 8830fa601e45..2d0b895e2f67 100644
> --- a/drivers/firmware/efi/libstub/fdt.c
> +++ b/drivers/firmware/efi/libstub/fdt.c
> @@ -366,22 +366,23 @@ void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size)
>   {
>   	efi_guid_t fdt_guid = DEVICE_TREE_GUID;
>   	efi_config_table_t *tables;
> -	void *fdt;
>   	int i;
>   
> -	tables = (efi_config_table_t *) sys_table->tables;
> -	fdt = NULL;
> +	tables = (efi_config_table_t *)sys_table->tables;
>   
> -	for (i = 0; i < sys_table->nr_tables; i++)
> -		if (efi_guidcmp(tables[i].guid, fdt_guid) == 0) {
> -			fdt = (void *) tables[i].table;
> -			if (fdt_check_header(fdt) != 0) {
> -				pr_efi_err(sys_table, "Invalid header detected on UEFI supplied FDT, ignoring ...\n");
> -				return NULL;
> -			}
> -			*fdt_size = fdt_totalsize(fdt);
> -			break;
> -	 }
> +	for (i = 0; i < sys_table->nr_tables; i++) {
> +		void *fdt;
> +
> +		if (efi_guidcmp(tables[i].guid, fdt_guid))
> +			continue;
> +		fdt = (void *)tables[i].table;
> +		if (fdt_check_header(fdt) != 0) {
> +			pr_efi_err(sys_table, "Invalid header detected on UEFI supplied FDT, ignoring ...\n");
> +			return NULL;
> +		}
> +		*fdt_size = fdt_totalsize(fdt);
> +		return fdt;
> +	}
>   
> -	return fdt;
> +	return NULL;
>   }
> 
> 

-- 
Julien Thierry

      reply	other threads:[~2018-10-29  9:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-01 10:29 [PATCH] efi/fdt: Indentation fix Julien Thierry
2018-10-02 16:05 ` Joe Perches
2018-10-29  9:45   ` Julien Thierry [this message]

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=d7d0641b-f2a5-a51b-f52e-3db3b873f209@arm.com \
    --to=julien.thierry@arm.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=joe@perches.com \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).