xgetXXbyYY: Simplify elifs
- Use SIZE_MAX rather than (size_t)-1, to improve readability. - Move the only branch that breaks to the first place, so that we remove an else. This reduces nesting while parsing the code. - Now that we only have a 2-branch conditional where both branches assign to the same variable, rewrite it as a ternary, to shorten. Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
committed by
Serge Hallyn
parent
89c9427087
commit
d9f0246611
@@ -79,13 +79,11 @@
|
||||
break;
|
||||
}
|
||||
|
||||
if (length <= ((size_t)-1 / 4)) {
|
||||
length *= 4;
|
||||
} else if (length == (size_t) -1) {
|
||||
if (length == SIZE_MAX) {
|
||||
break;
|
||||
} else {
|
||||
length = (size_t) -1;
|
||||
}
|
||||
|
||||
length = (length <= SIZE_MAX / 4) ? length * 4 : SIZE_MAX;
|
||||
}
|
||||
|
||||
free(buffer);
|
||||
|
||||
Reference in New Issue
Block a user