summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSami Kerola2017-05-29 19:39:22 +0200
committerKarel Zak2017-06-14 12:22:54 +0200
commit35e82b2926537c0e7264f84b38045b522fa82003 (patch)
treeeb290eb520bd52ab015ce416da8c3f313b62c940 /lib
parentmisc: remove stray semicolons (diff)
downloadkernel-qcow2-util-linux-35e82b2926537c0e7264f84b38045b522fa82003.tar.gz
kernel-qcow2-util-linux-35e82b2926537c0e7264f84b38045b522fa82003.tar.xz
kernel-qcow2-util-linux-35e82b2926537c0e7264f84b38045b522fa82003.zip
lib: simplify cpuset if clauses that return
There is no need for 'else' when 'if' will return. In same go move call of tolower() to last possible moment in char_to_val(), a lot of time hex values should hit 0-9 range, and it can be omitted. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'lib')
-rw-r--r--lib/cpuset.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/cpuset.c b/lib/cpuset.c
index 6d82522f5..011b6882b 100644
--- a/lib/cpuset.c
+++ b/lib/cpuset.c
@@ -29,23 +29,21 @@ static inline int val_to_char(int v)
{
if (v >= 0 && v < 10)
return '0' + v;
- else if (v >= 10 && v < 16)
+ if (v >= 10 && v < 16)
return ('a' - 10) + v;
- else
- return -1;
+ return -1;
}
static inline int char_to_val(int c)
{
int cl;
- cl = tolower(c);
if (c >= '0' && c <= '9')
return c - '0';
- else if (cl >= 'a' && cl <= 'f')
+ cl = tolower(c);
+ if (cl >= 'a' && cl <= 'f')
return cl + (10 - 'a');
- else
- return -1;
+ return -1;
}
static const char *nexttoken(const char *q, int sep)