public inbox for linux-ide@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ata: libata-core: get rid of *else* branches in ata_id_n_sectors()
@ 2022-06-09 21:06 Sergey Shtylyov
  2022-06-10 17:51 ` Sergey Shtylyov
  2022-06-14  9:04 ` Damien Le Moal
  0 siblings, 2 replies; 3+ messages in thread
From: Sergey Shtylyov @ 2022-06-09 21:06 UTC (permalink / raw)
  To: Damien Le Moal, linux-ide

Using *else* after *return* doesn't make much sense -- getting rid of such
*else* branches reduces the indentation levels and thus reduces # of LoC...

Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>

---
This patch is against the 'for-next' branch of Damien's 'libata.git' repo.

 drivers/ata/libata-core.c |   20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

Index: libata/drivers/ata/libata-core.c
===================================================================
--- libata.orig/drivers/ata/libata-core.c
+++ libata/drivers/ata/libata-core.c
@@ -1103,18 +1103,16 @@ static u64 ata_id_n_sectors(const u16 *i
 	if (ata_id_has_lba(id)) {
 		if (ata_id_has_lba48(id))
 			return ata_id_u64(id, ATA_ID_LBA_CAPACITY_2);
-		else
-			return ata_id_u32(id, ATA_ID_LBA_CAPACITY);
-	} else {
-		if (ata_id_current_chs_valid(id))
-			return (u32)id[ATA_ID_CUR_CYLS] *
-			       (u32)id[ATA_ID_CUR_HEADS] *
-			       (u32)id[ATA_ID_CUR_SECTORS];
-		else
-			return (u32)id[ATA_ID_CYLS] *
-			       (u32)id[ATA_ID_HEADS] *
-			       (u32)id[ATA_ID_SECTORS];
+
+		return ata_id_u32(id, ATA_ID_LBA_CAPACITY);
 	}
+
+	if (ata_id_current_chs_valid(id))
+		return (u32)id[ATA_ID_CUR_CYLS] * (u32)id[ATA_ID_CUR_HEADS] *
+		       (u32)id[ATA_ID_CUR_SECTORS];
+
+	return (u32)id[ATA_ID_CYLS] * (u32)id[ATA_ID_HEADS] *
+	       (u32)id[ATA_ID_SECTORS];
 }
 
 u64 ata_tf_to_lba48(const struct ata_taskfile *tf)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ata: libata-core: get rid of *else* branches in ata_id_n_sectors()
  2022-06-09 21:06 [PATCH] ata: libata-core: get rid of *else* branches in ata_id_n_sectors() Sergey Shtylyov
@ 2022-06-10 17:51 ` Sergey Shtylyov
  2022-06-14  9:04 ` Damien Le Moal
  1 sibling, 0 replies; 3+ messages in thread
From: Sergey Shtylyov @ 2022-06-10 17:51 UTC (permalink / raw)
  To: Damien Le Moal, linux-ide

On 6/10/22 12:06 AM, Sergey Shtylyov wrote:

> Using *else* after *return* doesn't make much sense -- getting rid of such
> *else* branches reduces the indentation levels and thus reduces # of LoC...
> 
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>

Suggested-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>

MBR, Sergey

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ata: libata-core: get rid of *else* branches in ata_id_n_sectors()
  2022-06-09 21:06 [PATCH] ata: libata-core: get rid of *else* branches in ata_id_n_sectors() Sergey Shtylyov
  2022-06-10 17:51 ` Sergey Shtylyov
@ 2022-06-14  9:04 ` Damien Le Moal
  1 sibling, 0 replies; 3+ messages in thread
From: Damien Le Moal @ 2022-06-14  9:04 UTC (permalink / raw)
  To: Sergey Shtylyov, linux-ide

On 6/10/22 06:06, Sergey Shtylyov wrote:
> Using *else* after *return* doesn't make much sense -- getting rid of such
> *else* branches reduces the indentation levels and thus reduces # of LoC...
> 
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>

Applied to for-5.20. Thanks !


-- 
Damien Le Moal
Western Digital Research

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-14  9:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-09 21:06 [PATCH] ata: libata-core: get rid of *else* branches in ata_id_n_sectors() Sergey Shtylyov
2022-06-10 17:51 ` Sergey Shtylyov
2022-06-14  9:04 ` Damien Le Moal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox