summaryrefslogtreecommitdiff
path: root/util/libreboot-utils
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-27 22:03:08 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-27 22:58:12 +0000
commit29296fc51307c13bf5094cd8981e6616df43fdec (patch)
tree7e9d3caebdf7423c4ab81565176a9c7127877027 /util/libreboot-utils
parent1e23ee26b1a476ecfebefe853e593ae5db48cbc5 (diff)
cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/libreboot-utils')
-rw-r--r--util/libreboot-utils/lottery.c77
1 files changed, 11 insertions, 66 deletions
diff --git a/util/libreboot-utils/lottery.c b/util/libreboot-utils/lottery.c
index f7c467e2..089c5bc4 100644
--- a/util/libreboot-utils/lottery.c
+++ b/util/libreboot-utils/lottery.c
@@ -1,76 +1,21 @@
/* SPDX-License-Identifier: MIT ( >:3 )
* Copyright (c) 2026 Leah Rowe <leah@libreboot.org> /| |\
- Presenting: a love song about non-determinism. / \ */
+ Something something non-determinism / \ */
#include <stdio.h>
#include <stdint.h>
-#include <stdlib.h> /* (^.>) - are u lucky? */
-#include <string.h> /* \| /= */
-#include "include/common.h" /* l \ */
+#include "include/common.h"
-#define len_hell(x, y) ((((x) - (y)) < BUFSIZ) ? ((x) - (y)) : BUFSIZ)
-
-static int rigged(void)
+int
+main(int argc, char **argv)
{
- size_t size[5] = { 0, 0, 0, SIZE_MAX, SIZE_MAX};
- char *b1 = NULL, *b2 = NULL;
- char *s = NULL;
- size_t e = 0;
-
- int rval = 1;
-
-for (e = 0; e < SIZE_MAX; e++) {
- if (rsize(e | 1) == 666)
- goto heaven;
-
- size[3] = SIZE_MAX;
- size[4] = SIZE_MAX;
-hell:
- if (!size[3]) {
- if (!size[4])
- continue;
- else --size[4];
- } else --size[3];
-
- free_and_set_null(&b1);
- free_and_set_null(&b2);
-
- size[0] = rsize(SIZE_MAX); /* \( ^o^)/ - then come play! */
- size[1] = rsize(SIZE_MAX); /* | | */
-/* / \ */
- if (!(size[0] && (size[0] == size[1]) && (size[0] <= SIZE_MAX)) ||
- ((size[0] & 1) && (*(b1 = mkrstr(1)) != *(b2 = mkrstr(1)))))
- goto out; /* \(^-^)/ - it could be you! */
- if (!(size[0] &= ~(size_t)1)) /* \ / */
- goto hell; /* / \ */
+ int same = 0;
+ (void) argc, (void) argv;
+ xpledgex("stdio", NULL);
- if (s == NULL) {
- if ((s = malloc(BUFSIZ)) == NULL)
- goto out;
- }
-
- for (size[1] = 0; size[1] < size[0]; size[1] += BUFSIZ) {
- rset(s, size[2] = len_hell(size[0], size[1]));
- if (!memcmp(s, s + (size[2] >> 1), size[2] >> 1))
- goto out;
- }
-
- goto hell;
-}
-heaven:
- rval = 0; /* <-- WINNER!!! */
-out:
- free_and_set_null(&b1);
- free_and_set_null(&b2);
- free_and_set_null(&s);
-
- return rval;
-}
-/* \(^o^)/ - come back soon! */
-int main(int argc, char **argv) /* \ / */
-{ /* / \ */
- xpledgex("stdio", NULL); /* */
- printf("%s\n", (argc = rigged()) ? "You lose!" : "You win!");
+ if (rsize(SIZE_MAX) == rsize(SIZE_MAX))
+ same = 1;
- return argc;
+ printf("%s\n", same ? "You win!" : "You lose!");
+ return same ^ 1;
}