util: buffer: Simplify convoluted condition

Spare a few more lines rather than having a condition with a nested
ternary.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2019-10-24 08:06:21 +02:00
parent 27bab9cac4
commit a5217cd7c0

View File

@ -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;
}