]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/, tests/: addsl2(): Rename addsl() to addsl2()
authorAlejandro Colomar <alx@kernel.org>
Sat, 6 Jan 2024 01:25:21 +0000 (02:25 +0100)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Tue, 16 Jan 2024 15:58:18 +0000 (16:58 +0100)
This is for consistency with addsl3(), and in preparation for the
following commit, which will unify the interface into a single addsl()
macro.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/adds.c
lib/adds.h
tests/unit/test_adds.c

index d442b7541252370afa7729fe57d4461be7cfb685..b5ea3bb6651ef0aa9f552ca29bd7984780256258 100644 (file)
@@ -7,7 +7,7 @@
 #include "adds.h"
 
 
-extern inline long addsl(long a, long b);
+extern inline long addsl2(long a, long b);
 extern inline long addsl3(long a, long b, long c);
 
 extern inline int cmpl(const void *p1, const void *p2);
index dde5b5c72ff786366f9eb8278bcd9a4166c1009e..107e64e24cde0e3ed2b377b2570312be589be53c 100644 (file)
 #include "sizeof.h"
 
 
-inline long addsl(long a, long b);
+inline long addsl2(long a, long b);
 inline long addsl3(long a, long b, long c);
 
 inline int cmpl(const void *p1, const void *p2);
 
 
 inline long
-addsl(long a, long b)
+addsl2(long a, long b)
 {
        if (a > 0 && b > LONG_MAX - a) {
                errno = EOVERFLOW;
index 1435bd4e0953482c697c2fa54dfb8ee9ed88d050..72790a59307cda54240ee0a8e8f98634af48661a 100644 (file)
 #include "adds.h"
 
 
-static void test_addsl_ok(void **state);
-static void test_addsl_underflow(void **state);
-static void test_addsl_overflow(void **state);
-static void test_addsl3_ok(void **state);
-static void test_addsl3_underflow(void **state);
-static void test_addsl3_overflow(void **state);
+static void test_addsl_2_ok(void **state);
+static void test_addsl_2_underflow(void **state);
+static void test_addsl_2_overflow(void **state);
+static void test_addsl_3_ok(void **state);
+static void test_addsl_3_underflow(void **state);
+static void test_addsl_3_overflow(void **state);
 
 
 int
 main(void)
 {
     const struct CMUnitTest  tests[] = {
-        cmocka_unit_test(test_addsl_ok),
-        cmocka_unit_test(test_addsl_underflow),
-        cmocka_unit_test(test_addsl_overflow),
-        cmocka_unit_test(test_addsl3_ok),
-        cmocka_unit_test(test_addsl3_underflow),
-        cmocka_unit_test(test_addsl3_overflow),
+        cmocka_unit_test(test_addsl_2_ok),
+        cmocka_unit_test(test_addsl_2_underflow),
+        cmocka_unit_test(test_addsl_2_overflow),
+        cmocka_unit_test(test_addsl_3_ok),
+        cmocka_unit_test(test_addsl_3_underflow),
+        cmocka_unit_test(test_addsl_3_overflow),
     };
 
     return cmocka_run_group_tests(tests, NULL, NULL);
@@ -38,39 +38,39 @@ main(void)
 
 
 static void
-test_addsl_ok(void **state)
+test_addsl_2_ok(void **state)
 {
-       assert_true(addsl(1, 3)                 == 1 + 3);
-       assert_true(addsl(-4321, 7)             == -4321 + 7);
-       assert_true(addsl(1, 1)                 == 1 + 1);
-       assert_true(addsl(-1, -2)               == -1 - 2);
-       assert_true(addsl(LONG_MAX, -1)         == LONG_MAX - 1);
-       assert_true(addsl(LONG_MIN, 1)          == LONG_MIN + 1);
-       assert_true(addsl(LONG_MIN, LONG_MAX)   == LONG_MIN + LONG_MAX);
-       assert_true(addsl(0, 0)                 == 0);
+       assert_true(addsl2(1, 3)                == 1 + 3);
+       assert_true(addsl2(-4321, 7)            == -4321 + 7);
+       assert_true(addsl2(1, 1)                == 1 + 1);
+       assert_true(addsl2(-1, -2)              == -1 - 2);
+       assert_true(addsl2(LONG_MAX, -1)        == LONG_MAX - 1);
+       assert_true(addsl2(LONG_MIN, 1)         == LONG_MIN + 1);
+       assert_true(addsl2(LONG_MIN, LONG_MAX)  == LONG_MIN + LONG_MAX);
+       assert_true(addsl2(0, 0)                == 0);
 }
 
 
 static void
-test_addsl_underflow(void **state)
+test_addsl_2_underflow(void **state)
 {
-       assert_true(addsl(LONG_MIN, -1)         == LONG_MIN);
-       assert_true(addsl(LONG_MIN + 3, -7)     == LONG_MIN);
-       assert_true(addsl(LONG_MIN, LONG_MIN)   == LONG_MIN);
+       assert_true(addsl2(LONG_MIN, -1)        == LONG_MIN);
+       assert_true(addsl2(LONG_MIN + 3, -7)    == LONG_MIN);
+       assert_true(addsl2(LONG_MIN, LONG_MIN)  == LONG_MIN);
 }
 
 
 static void
-test_addsl_overflow(void **state)
+test_addsl_2_overflow(void **state)
 {
-       assert_true(addsl(LONG_MAX, 1)          == LONG_MAX);
-       assert_true(addsl(LONG_MAX - 3, 7)      == LONG_MAX);
-       assert_true(addsl(LONG_MAX, LONG_MAX)   == LONG_MAX);
+       assert_true(addsl2(LONG_MAX, 1)         == LONG_MAX);
+       assert_true(addsl2(LONG_MAX - 3, 7)     == LONG_MAX);
+       assert_true(addsl2(LONG_MAX, LONG_MAX)  == LONG_MAX);
 }
 
 
 static void
-test_addsl3_ok(void **state)
+test_addsl_3_ok(void **state)
 {
        assert_true(addsl3(1, 2, 3)             == 1 + 2 + 3);
        assert_true(addsl3(LONG_MIN, -3, 4)     == LONG_MIN + 4 - 3);
@@ -80,7 +80,7 @@ test_addsl3_ok(void **state)
 
 
 static void
-test_addsl3_underflow(void **state)
+test_addsl_3_underflow(void **state)
 {
        assert_true(addsl3(LONG_MIN, 2, -3)     == LONG_MIN);
        assert_true(addsl3(LONG_MIN, -1, 0)     == LONG_MIN);
@@ -88,7 +88,7 @@ test_addsl3_underflow(void **state)
 
 
 static void
-test_addsl3_overflow(void **state)
+test_addsl_3_overflow(void **state)
 {
        assert_true(addsl3(LONG_MAX, -1, 2)     == LONG_MAX);
        assert_true(addsl3(LONG_MAX, +1, 0)     == LONG_MAX);