Skip to content

Commit

Permalink
add return values
Browse files Browse the repository at this point in the history
  • Loading branch information
bigbrett committed Aug 15, 2024
1 parent 36ab889 commit 5327149
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
18 changes: 8 additions & 10 deletions posix/tcp/wh_client_tcp/wh_client_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "wh_demo_client_all.h"

/** Local declarations */
static void* wh_ClientTask(void* cf);
static int wh_ClientTask(void* cf);


enum {
Expand All @@ -30,7 +30,7 @@ enum {
#define WH_SERVER_TCP_PORT 23456
#define WH_CLIENT_ID 12

static void* wh_ClientTask(void* cf)
static int wh_ClientTask(void* cf)
{
whClientConfig* config = (whClientConfig*)cf;
int ret = 0;
Expand All @@ -44,15 +44,15 @@ static void* wh_ClientTask(void* cf)
uint16_t rx_resp_len = 0;

if (config == NULL) {
return NULL;
return -1;
}

ret = wh_Client_Init(client, config);
printf("Client connecting to server...\n");

if (ret != 0) {
perror("Init error:");
return NULL;
return -1;
}
for(counter = 0; counter < REPEAT_COUNT; counter++)
{
Expand Down Expand Up @@ -96,10 +96,10 @@ static void* wh_ClientTask(void* cf)
}


wh_Client_CommClose(client);
ret = wh_Client_Cleanup(client);
(void)wh_Client_CommClose(client);
(void)wh_Client_Cleanup(client);
printf("Client disconnected\n");
return NULL;
return ret;
}

int main(int argc, char** argv)
Expand All @@ -124,7 +124,5 @@ int main(int argc, char** argv)
.comm = cc_conf,
}};

wh_ClientTask(c_conf);

return 0;
return wh_ClientTask(c_conf);
}
18 changes: 11 additions & 7 deletions posix/tcp/wh_server_tcp/wh_server_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "port/posix/posix_transport_tcp.h"

/** Local declarations */
static void* wh_ServerTask(void* cf);
static int wh_ServerTask(void* cf);

enum {
ONE_MS = 1000,
Expand All @@ -28,7 +28,7 @@ enum {
#define WH_SERVER_TCP_PORT 23456
#define WH_SERVER_ID 56

static void* wh_ServerTask(void* cf)
static int wh_ServerTask(void* cf)
{
whServerContext server[1];
whServerConfig* config = (whServerConfig*)cf;
Expand All @@ -37,7 +37,7 @@ static void* wh_ServerTask(void* cf)
whCommConnected am_connected = WH_COMM_CONNECTED;

if (config == NULL) {
return NULL;
return -1;
}

ret = wh_Server_Init(server, config);
Expand All @@ -61,10 +61,14 @@ static void* wh_ServerTask(void* cf)
}
wh_Server_GetConnected(server, &am_connected);
}
ret = wh_Server_Cleanup(server);
if (ret != 0) {
(void)wh_Server_Cleanup(server);
} else {
ret = wh_Server_Cleanup(server);
}
printf("Server disconnected\n");
}
return NULL;
return ret;
}

int main(int argc, char** argv)
Expand Down Expand Up @@ -140,7 +144,7 @@ int main(int argc, char** argv)
return rc;
}

wh_ServerTask(s_conf);
rc = wh_ServerTask(s_conf);

return 0;
return rc;
}

0 comments on commit 5327149

Please sign in to comment.