]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: buffer: Simplify convoluted condition
authorPeter Krempa <pkrempa@redhat.com>
Thu, 24 Oct 2019 06:06:21 +0000 (08:06 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 24 Oct 2019 17:35:34 +0000 (19:35 +0200)
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>
src/util/virbuffer.c

index 04c8fd72916108008a9afee45d762d3fbf3803fa..a58481430a4c965ff0e0c0093d85e49ed9446f4c 100644 (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;
 }