From: Peter Krempa Date: Thu, 24 Oct 2019 06:06:21 +0000 (+0200) Subject: util: buffer: Simplify convoluted condition X-Git-Tag: v5.9.0-rc1~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5217cd7c04497056f535dc6e6938fea0f6a5865;p=thirdparty%2Flibvirt.git util: buffer: Simplify convoluted condition Spare a few more lines rather than having a condition with a nested ternary. Signed-off-by: Peter Krempa Reviewed-by: Jonathon Jongsma Reviewed-by: Ján Tomko --- diff --git a/src/util/virbuffer.c b/src/util/virbuffer.c index 04c8fd7291..a58481430a 100644 --- a/src/util/virbuffer.c +++ b/src/util/virbuffer.c @@ -64,11 +64,19 @@ virBufferAdjustIndent(virBufferPtr buf, int indent) { if (!buf || buf->error) return; - if (indent > 0 ? INT_MAX - indent < buf->indent - : buf->indent < -indent) { - virBufferSetError(buf, -1); - return; + + if (indent > 0) { + if (INT_MAX - indent < buf->indent) { + virBufferSetError(buf, -1); + return; + } + } else { + if (buf->indent < -indent) { + virBufferSetError(buf, -1); + return; + } } + buf->indent += indent; }