From 01353032b4cf39d75e48d7bd93244fbe64b9ae52 Mon Sep 17 00:00:00 2001 From: theBigBlase Date: Fri, 6 Oct 2023 22:23:37 -0400 Subject: [PATCH] main: refacto --- src/main.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/main.c b/src/main.c index 814914a..325da2c 100644 --- a/src/main.c +++ b/src/main.c @@ -50,28 +50,26 @@ main(int argc, char *argv[]) free(res); #endif - printf("\n--- MSG ---\nas 0x: "); -#ifdef TEST_ZERO - msg = 0; - printf("0x00000000\n"); -#endif + printf("\n--- MSG ---\n"); -#ifdef TEST_MAX - msg = UINT32_MAX; - printf("0xffffffff\n"); +#ifdef TEST_ZERO + msg = 0x00000000; #endif #ifdef TEST_MID - printf("0x0000ffff\n"); /* is UINT16_MAX, but keeping this way for corrector convenience */ - msg = UINT32_MAX & UINT16_MAX; + msg = 0x0000ffff; +#endif + +#ifdef TEST_MAX + msg = 0xffffffff; #endif #ifdef TEST_NAME msg = *(uint32_t *)"bob"; - printf("%u\n", msg); #endif + printf("as 0x: %x\n", msg); char *msg_char = uint32_to_char_arr(msg); printf("as char *: %s\nas uint32: %u\n", @@ -125,21 +123,27 @@ gen() static struct eve eve_shenanigans(struct eve str) { -#ifdef EVE_NAME +#ifdef EVE_ZERO uint32_t old_msg = str.msg; - str.msg = *(uint32_t *)"eve"; + str.msg = 0x00000000; str.tag = str.tag ^ old_msg ^ str.msg; #endif -#ifdef EVE_ZERO +#ifdef EVE_MID uint32_t old_msg = str.msg; - str.msg = 0; + str.msg = 0x0000ffff; str.tag = str.tag ^ old_msg ^ str.msg; #endif #ifdef EVE_MAX uint32_t old_msg = str.msg; - str.msg = UINT32_MAX; + str.msg = 0xffffffff; + str.tag = str.tag ^ old_msg ^ str.msg; +#endif + +#ifdef EVE_NAME + uint32_t old_msg = str.msg; + str.msg = *(uint32_t *)"eve"; str.tag = str.tag ^ old_msg ^ str.msg; #endif