]> git.meshlink.io Git - meshlink/blobdiff - test/blackbox/common/mesh_event_handler.c
Ensure NDEBUG is not set in the test suite.
[meshlink] / test / blackbox / common / mesh_event_handler.c
index bb5faf1c173c463698266cc7ba339dddd528a138..17b5abaf750ef3f7a33fddf21ca177babf547bd1 100644 (file)
     with this program; if not, write to the Free Software Foundation, Inc.,
     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
+
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -83,6 +88,7 @@ static bool wait_cond_flag(struct cond_flag *s, int seconds) {
 
 // event_receive_handler running in a separate thread queues all the events received from the UDP port
 static void *event_receive_handler(void *arg) {
+       (void)arg;
        size_t recv_ret;
        char udp_buff[UDP_BUFF_MAX];
        struct sockaddr client;
@@ -120,7 +126,7 @@ static void *event_handler(void *argv) {
        bool callback_return = false;
        void *data;
        mesh_event_payload_t mesh_event_rec_packet;
-       mesh_event_callback_t callback = (mesh_event_callback_t)argv;
+       mesh_event_callback_t callback = *(mesh_event_callback_t *)argv;
 
        while(event_handle_thread_running) {
 
@@ -173,7 +179,7 @@ char *mesh_event_sock_create(const char *if_name) {
        server.sin_port   = htons(atoi(SERVER_LISTEN_PORT));
        assert(bind(server_fd, (struct sockaddr *) &server, sizeof(struct sockaddr)) != -1);
 
-       assert(ip = malloc(30));
+       assert((ip = malloc(30)));
        strncpy(ip, inet_ntoa(resp_if_addr->sin_addr), 20);
        strcat(ip, ":");
        strcat(ip, SERVER_LISTEN_PORT);
@@ -255,7 +261,7 @@ bool wait_for_event(mesh_event_callback_t callback, int seconds) {
        }
 
        set_cond_flag(&sync_event, false);
-       assert(!pthread_create(&event_handle_thread, NULL, event_handler, (void *)callback));
+       assert(!pthread_create(&event_handle_thread, NULL, event_handler, (void *)&callback));
        bool wait_ret = wait_cond_flag(&sync_event, seconds);
        event_handle_thread_running = false;
        pthread_cancel(event_handle_thread);
@@ -279,4 +285,4 @@ void mesh_event_destroy(void) {
        mesh_events_flush();
        event_receive_thread_running = false;
        pthread_cancel(event_receive_thread);
-}
\ No newline at end of file
+}