From: Michael Tremer Date: Mon, 10 Feb 2025 17:10:54 +0000 (+0000) Subject: tests: string: Fail with a clear error code on invalid input X-Git-Tag: 0.9.30~49 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a21bde5cca1f940e75269336985ddd127b488e9f;p=pakfire.git tests: string: Fail with a clear error code on invalid input Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/string.c b/src/pakfire/string.c index 4bca3ee8..09aa6037 100644 --- a/src/pakfire/string.c +++ b/src/pakfire/string.c @@ -657,7 +657,7 @@ int __pakfire_format_time(char* buffer, const size_t length, const time_t t) { // Values smaller than zero for t are invalid if (t < 0) - return 1; + return -EINVAL; if (t >= 86400) format = "%dd%Hh%Mm"; diff --git a/tests/libpakfire/string.c b/tests/libpakfire/string.c index 706c0b4a..f569833f 100644 --- a/tests/libpakfire/string.c +++ b/tests/libpakfire/string.c @@ -307,8 +307,7 @@ static int test_format_time(const struct test* t) { char buffer[128]; // Values smaller than zero - ASSERT_SUCCESS(pakfire_format_time(buffer, -1)); - ASSERT_STRING_EQUALS(buffer, NULL); + ASSERT_ERROR(pakfire_format_time(buffer, -1), EINVAL); // Values greater than a day ASSERT_SUCCESS(pakfire_format_time(buffer, 86400));