From: Alejandro Colomar Date: Sat, 27 May 2023 01:26:52 +0000 (+0200) Subject: xgetXXbyYY: Simplify elifs X-Git-Tag: 4.14.0-rc1~62 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d9f0246611aea527f21c15256a6340c618f22d73;p=thirdparty%2Fshadow.git 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 --- diff --git a/libmisc/xgetXXbyYY.c b/libmisc/xgetXXbyYY.c index 36b9a150d..c0782ff40 100644 --- a/libmisc/xgetXXbyYY.c +++ b/libmisc/xgetXXbyYY.c @@ -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);