From 1401e1d70b933a5ea9c6c108717a219ba25be02d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorben=20H=C3=B6hne?= Date: Sun, 29 Jun 2025 02:33:07 +0200 Subject: [PATCH] fix: Adding casts for C++ and optimizing pointer comparison. --- include/set.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/include/set.h b/include/set.h index fe4a1f5..a66ee13 100644 --- a/include/set.h +++ b/include/set.h @@ -2,6 +2,7 @@ #define _GNU_SOURCE #include +#include #include #include #include @@ -160,17 +161,17 @@ bool tear_down(); void suit_name##_suit(struct SETSuit *suit, bool count); \ struct SETSuit *suit_name##_suit_contructor() \ { \ - struct SETSuit *suit = \ - mmap(NULL, sizeof(struct SETSuit), PROT_READ | PROT_WRITE, \ - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); \ + struct SETSuit *suit = (struct SETSuit *)mmap( \ + NULL, sizeof(struct SETSuit), PROT_READ | PROT_WRITE, \ + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); \ madvise(suit, sizeof(struct SETSuit), MADV_DONTFORK); \ suit->len = 0; \ suit_name##_suit(suit, true); \ suit->shm_key = \ create_shared_suit_space(suit->len * sizeof(struct SETest)); \ suit->name = #suit_name; \ - suit->tests = shmat(suit->shm_key, 0, 0); \ - if (suit->tests == (struct SETest *)-1) \ + suit->tests = (struct SETest *)shmat(suit->shm_key, 0, 0); \ + if ((uint64_t)suit->tests == -1) \ { \ fprintf(stderr, "Couldn't attach suit space.\n"); \ perror("shmat"); \