err/err.c: improve readability.
authorAndy Polyakov <appro@openssl.org>
Wed, 16 Aug 2017 21:08:03 +0000 (23:08 +0200)
committerAndy Polyakov <appro@openssl.org>
Fri, 18 Aug 2017 07:24:52 +0000 (09:24 +0200)
Reviewed-by: Rich Salz <rsalz@openssl.org>
crypto/err/err.c

index 8d0da79f3015bec26f3621d8aa821bb2a587647b..eec071236eb1a5e4b27b70a1a799aa9fd19596b8 100644 (file)
@@ -800,9 +800,7 @@ int ERR_pop_to_mark(void)
     while (es->bottom != es->top
            && (es->err_flags[es->top] & ERR_FLAG_MARK) == 0) {
         err_clear(es, es->top);
-        es->top -= 1;
-        if (es->top == -1)
-            es->top = ERR_NUM_ERRORS - 1;
+        es->top = es->top > 0 ? es->top - 1 : ERR_NUM_ERRORS - 1;
     }
 
     if (es->bottom == es->top)
@@ -823,9 +821,7 @@ int ERR_clear_last_mark(void)
     top = es->top;
     while (es->bottom != top
            && (es->err_flags[top] & ERR_FLAG_MARK) == 0) {
-        top -= 1;
-        if (top == -1)
-            top = ERR_NUM_ERRORS - 1;
+        top = top > 0 ? top - 1 : ERR_NUM_ERRORS - 1;
     }
 
     if (es->bottom == top)