From: Sergey Shtylyov <s.shtylyov@omp.ru>
To: Damien Le Moal <damien.lemoal@opensource.wdc.com>,
<linux-ide@vger.kernel.org>
Subject: [PATCH] ata: libata-core: get rid of *else* branches in ata_id_n_sectors()
Date: Fri, 10 Jun 2022 00:06:54 +0300 [thread overview]
Message-ID: <9490e8b7-e601-ecaf-dc94-d0f5fb63aa5f@omp.ru> (raw)
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)
next reply other threads:[~2022-06-09 21:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-09 21:06 Sergey Shtylyov [this message]
2022-06-10 17:51 ` [PATCH] ata: libata-core: get rid of *else* branches in ata_id_n_sectors() Sergey Shtylyov
2022-06-14 9:04 ` Damien Le Moal
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=9490e8b7-e601-ecaf-dc94-d0f5fb63aa5f@omp.ru \
--to=s.shtylyov@omp.ru \
--cc=damien.lemoal@opensource.wdc.com \
--cc=linux-ide@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