Skip to content

Commit

Permalink
fix(tests): fix warnings reported by scan-build (clang)
Browse files Browse the repository at this point in the history
    tslibxstrton_agetollint.c:44:3: warning: The left operand of '!=' is a garbage value
                                   [core.UndefinedBinaryOperatorResult]
       44 |   TEST_ASSERT_EQUAL_NUMERIC (result, data->expect_value);
          |   ^                          ~~~~~~
    ../include/testutils.h:59:16: note: expanded from macro 'TEST_ASSERT_EQUAL_NUMERIC'
       59 |   do { if ((A) != (B)) ret = -1; } while (0)
          |             ~  ^

    tslibxstrton_sizetollint.c:44:3: warning: The left operand of '!=' is a garbage value
                                     [core.UndefinedBinaryOperatorResult]
       44 |   TEST_ASSERT_EQUAL_NUMERIC (result, data->expect_value);
          |   ^                          ~~~~~~
    ../include/testutils.h:59:16: note: expanded from macro 'TEST_ASSERT_EQUAL_NUMERIC'
       59 |   do { if ((A) != (B)) ret = -1; } while (0)
          |             ~  ^

Signed-off-by: Davide Madrisan <[email protected]>
  • Loading branch information
madrisan committed Sep 12, 2024
1 parent 9828130 commit 12c581d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/xstrton.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ strtollint (const char *str, long long int *result,
* return 0 on success, -1 otherwise (in this case errmesg will provide a
* human readable error message) */
int
agetollint (const char *str, long long int * age, char **errmesg)
agetollint (const char *str, long long int *age, char **errmesg)
{
return strtollint (str, age, agemultiplier, errmesg);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/tslibxstrton_agetollint.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ test_agetoint64 (const void *tdata)
char *errmegs;
int ret = 0;

agetollint (data->age, &result, &errmegs);
if (agetollint (data->age, &result, &errmegs) < 0)
return EXIT_AM_HARDFAIL;
TEST_ASSERT_EQUAL_NUMERIC (result, data->expect_value);
return ret;
}
Expand Down
3 changes: 2 additions & 1 deletion tests/tslibxstrton_sizetollint.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ test_sizetollint (const void *tdata)
char *errmegs;
int ret = 0;

sizetollint (data->size, &result, &errmegs);
if (sizetollint (data->size, &result, &errmegs) < 0)
return EXIT_AM_HARDFAIL;
TEST_ASSERT_EQUAL_NUMERIC (result, data->expect_value);
return ret;
}
Expand Down

0 comments on commit 12c581d

Please sign in to comment.