]> git.meshlink.io Git - meshlink/blobdiff - test/blackbox/common/mesh_event_handler.c
Fix compiler warnings in the test suites.
[meshlink] / test / blackbox / common / mesh_event_handler.c
index 1b7ebe92aec61dd15eee952320313591d7b9f33c..84ae63dd83436ec0cb42c780ef411ec1b36aa66a 100644 (file)
 #define SERVER_LISTEN_PORT "9000" /* Port number that is binded with mesh event server socket */
 #define UDP_BUFF_MAX 2000
 
+const char *event_status[] = {
+       [NODE_STARTED]                          = "Node Started",
+       [NODE_JOINED]                           = "Node Joined",
+       [ERR_NETWORK]                           = "Network Error",
+       [CHANNEL_OPENED]                        = "Channel Opened",
+       [CHANNEL_DATA_RECIEVED]                         = "Channel Data Received",
+       [SIG_ABORT]                             = "SIG_ABORT Received",
+       [MESH_EVENT_COMPLETED]                          = "MESH_EVENT_COMPLETED Received"
+};
+
 // TODO: Implement mesh event handling with reentrancy .
 static struct sockaddr_in server_addr;
 static int client_fd = -1;
@@ -73,6 +83,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;
@@ -110,7 +121,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) {
 
@@ -163,7 +174,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);
@@ -245,7 +256,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);
@@ -270,4 +281,3 @@ void mesh_event_destroy(void) {
        event_receive_thread_running = false;
        pthread_cancel(event_receive_thread);
 }
-