summaryrefslogtreecommitdiff
path: root/tests/random.c
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-04-06 11:37:04 -0300
committerEuAndreh <eu@euandre.org>2024-04-06 11:37:04 -0300
commit3b32f5a1abbec9655a93a184ed0a3c5e6e5134fd (patch)
tree03969b7b76835f2507ccd1a8aeb057bb1d7f7201 /tests/random.c
parentsrc/: Remove unused "infallible" tag (diff)
downloadpindaiba-3b32f5a1abbec9655a93a184ed0a3c5e6e5134fd.tar.gz
pindaiba-3b32f5a1abbec9655a93a184ed0a3c5e6e5134fd.tar.xz
Start "rc = -1" instead of 0
Diffstat (limited to 'tests/random.c')
-rw-r--r--tests/random.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/tests/random.c b/tests/random.c
index eec83c5..e56e747 100644
--- a/tests/random.c
+++ b/tests/random.c
@@ -4,7 +4,7 @@
static int
test_urandom_bytes(void) {
- int rc = 0;
+ int rc = -1;
test_start("urandom_bytes()");
@@ -17,7 +17,6 @@ test_urandom_bytes(void) {
for (size_t n = 0; n < LEN; n++) {
if (urandom_bytes(n, &arr)) {
logerr("urandom_bytes(n, &arr);\n");
- rc = -1;
goto out;
}
for (size_t i = n; i < LEN; i++) {
@@ -37,7 +36,6 @@ test_urandom_bytes(void) {
if (urandom_bytes(LEN, &arr1)) {
logerr("urandom_bytes(LEN, &arr1);\n");
- rc = -1;
goto out;
}
@@ -45,7 +43,6 @@ test_urandom_bytes(void) {
for (size_t n = 0; n < attempts; n++) {
if (urandom_bytes(LEN, &arr2)) {
logerr("urandom_bytes(LEN, &arr2);\n");
- rc = -1;
goto out;
}
assert(memcmp(arr1, arr2, LEN) != 0);
@@ -54,20 +51,21 @@ test_urandom_bytes(void) {
test_ok();
}
+ rc = 0;
out:
return rc;
}
int
main(void) {
- int rc = 0;
+ int rc = -1;
if (test_urandom_bytes()) {
logerr("test_urandom_bytes();\n");
- rc = -1;
goto out;
}
+ rc = 0;
out:
return !!rc;
}