git: 0bdcfb08f2d5 - main - usr.bin/units: use else..if to avoid calling the next branch
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 19 Apr 2024 23:11:41 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=0bdcfb08f2d5b80523275adcdd64facb102eedbc
commit 0bdcfb08f2d5b80523275adcdd64facb102eedbc
Author: rilysh <nightquick@proton.me>
AuthorDate: 2024-04-19 22:53:05 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-04-19 22:54:30 +0000
usr.bin/units: use else..if to avoid calling the next branch
Even if the first branch succeeds, next time it will still check for
the second branch (which will be false) as the first one was true.
Add an else..if statement to address this.
Signed-off-by: rilysh <nightquick@proton.me>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1165
---
usr.bin/units/units.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/usr.bin/units/units.c b/usr.bin/units/units.c
index 78b7e4020ed3..1b6d0ed90b4a 100644
--- a/usr.bin/units/units.c
+++ b/usr.bin/units/units.c
@@ -497,8 +497,7 @@ lookupunit(const char *unit)
}
}
free(copy);
- }
- if (unit[strlen(unit) - 1] == 's') {
+ } else if (unit[strlen(unit) - 1] == 's') {
copy = dupstr(unit);
copy[strlen(copy) - 1] = 0;
for (i = 0; i < unitcount; i++) {