Fixed clang warnings
parent
3bc417467d
commit
83fcc7ddb4
|
@ -39,7 +39,7 @@ int AcceptAndRead(socklen_t sockfd);
|
||||||
int AcceptAndRead(socklen_t sockfd)
|
int AcceptAndRead(socklen_t sockfd)
|
||||||
{
|
{
|
||||||
struct sockaddr_in clientAddr;
|
struct sockaddr_in clientAddr;
|
||||||
int size = sizeof(clientAddr);
|
socklen_t size = sizeof(clientAddr);
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
/* Wait until a client connects */
|
/* Wait until a client connects */
|
||||||
|
@ -99,7 +99,7 @@ int main()
|
||||||
int exit = 0; /* 0 = false, 1 = true */
|
int exit = 0; /* 0 = false, 1 = true */
|
||||||
|
|
||||||
/* If positive value, the socket is valid */
|
/* If positive value, the socket is valid */
|
||||||
if(sockfd < 0){
|
if(sockfd == -1){
|
||||||
printf("ERROR: failed to create the socket\n");
|
printf("ERROR: failed to create the socket\n");
|
||||||
return 1; /* Kill the server with exit status 1 */
|
return 1; /* Kill the server with exit status 1 */
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,11 +146,10 @@ int NonBlocking_ReadWriteAccept(CYASSL* ssl, socklen_t socketfd,
|
||||||
|
|
||||||
int AcceptAndRead(CYASSL_CTX* ctx, socklen_t socketfd, struct sockaddr_in clientAddr)
|
int AcceptAndRead(CYASSL_CTX* ctx, socklen_t socketfd, struct sockaddr_in clientAddr)
|
||||||
{
|
{
|
||||||
int size = sizeof(clientAddr);
|
socklen_t size = sizeof(clientAddr);
|
||||||
CYASSL* ssl;
|
|
||||||
|
|
||||||
/* Wait until a client connects */
|
/* Wait until a client connects */
|
||||||
int connd = accept(socketfd, (struct sockaddr_in *)&clientAddr, &size);
|
int connd = accept(socketfd, (struct sockaddr *)&clientAddr, &size);
|
||||||
|
|
||||||
/* If fails to connect, loop back up and wait for a new connection */
|
/* If fails to connect, loop back up and wait for a new connection */
|
||||||
if (connd == -1) {
|
if (connd == -1) {
|
||||||
|
@ -159,7 +158,7 @@ int AcceptAndRead(CYASSL_CTX* ctx, socklen_t socketfd, struct sockaddr_in client
|
||||||
/* If it connects, read in and reply to the client */
|
/* If it connects, read in and reply to the client */
|
||||||
else {
|
else {
|
||||||
printf("Client connected successfully!\n");
|
printf("Client connected successfully!\n");
|
||||||
|
CYASSL* ssl;
|
||||||
if ( (ssl = CyaSSL_new(ctx)) == NULL) {
|
if ( (ssl = CyaSSL_new(ctx)) == NULL) {
|
||||||
fprintf(stderr, "CyaSSL_new error.\n");
|
fprintf(stderr, "CyaSSL_new error.\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -184,8 +183,8 @@ int AcceptAndRead(CYASSL_CTX* ctx, socklen_t socketfd, struct sockaddr_in client
|
||||||
if (NonBlocking_ReadWriteAccept(ssl, socketfd, WRITE) == 0)
|
if (NonBlocking_ReadWriteAccept(ssl, socketfd, WRITE) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
CyaSSL_free(ssl); /* Free the CYASSL object */
|
||||||
}
|
}
|
||||||
CyaSSL_free(ssl); /* Free the CYASSL object */
|
|
||||||
close(connd); /* close the connected socket */
|
close(connd); /* close the connected socket */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -224,7 +223,7 @@ int main()
|
||||||
socklen_t len = sizeof(on);
|
socklen_t len = sizeof(on);
|
||||||
|
|
||||||
/* If positive value, the socket is valid */
|
/* If positive value, the socket is valid */
|
||||||
if (socketfd < 0) {
|
if (socketfd == -1) {
|
||||||
printf("ERROR: failed to create the socket\n");
|
printf("ERROR: failed to create the socket\n");
|
||||||
exit(EXIT_FAILURE); /* Kill the server with exit status 1 */
|
exit(EXIT_FAILURE); /* Kill the server with exit status 1 */
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ void *ThreadHandler(void* socketDesc)
|
||||||
|
|
||||||
int AcceptAndRead(socklen_t sockfd, struct sockaddr_in clientAddr)
|
int AcceptAndRead(socklen_t sockfd, struct sockaddr_in clientAddr)
|
||||||
{
|
{
|
||||||
int size = sizeof(clientAddr);
|
socklen_t size = sizeof(clientAddr);
|
||||||
int connd; /* Identify and access the clients connection */
|
int connd; /* Identify and access the clients connection */
|
||||||
|
|
||||||
pthread_t thread_id;
|
pthread_t thread_id;
|
||||||
|
@ -149,7 +149,7 @@ int main()
|
||||||
CyaSSL_Init();
|
CyaSSL_Init();
|
||||||
|
|
||||||
/* If positive value, the socket is valid */
|
/* If positive value, the socket is valid */
|
||||||
if (sockfd < 0) {
|
if (sockfd == -1) {
|
||||||
printf("ERROR: failed to create the socket\n");
|
printf("ERROR: failed to create the socket\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,7 @@ int AcceptAndRead(CYASSL_CTX* ctx, socklen_t sockfd, struct sockaddr_in
|
||||||
{
|
{
|
||||||
/* Create our reply message */
|
/* Create our reply message */
|
||||||
const char reply[] = "I hear ya fa shizzle!\n";
|
const char reply[] = "I hear ya fa shizzle!\n";
|
||||||
int size = sizeof(clientAddr);
|
socklen_t size = sizeof(clientAddr);
|
||||||
CYASSL* ssl;
|
|
||||||
|
|
||||||
/* Wait until a client connects */
|
/* Wait until a client connects */
|
||||||
int connd = accept(sockfd, (struct sockaddr *)&clientAddr, &size);
|
int connd = accept(sockfd, (struct sockaddr *)&clientAddr, &size);
|
||||||
|
@ -59,6 +58,7 @@ int AcceptAndRead(CYASSL_CTX* ctx, socklen_t sockfd, struct sockaddr_in
|
||||||
/* If it connects, read in and reply to the client */
|
/* If it connects, read in and reply to the client */
|
||||||
else {
|
else {
|
||||||
printf("Client connected successfully\n");
|
printf("Client connected successfully\n");
|
||||||
|
CYASSL* ssl;
|
||||||
|
|
||||||
if ( (ssl = CyaSSL_new(ctx)) == NULL) {
|
if ( (ssl = CyaSSL_new(ctx)) == NULL) {
|
||||||
fprintf(stderr, "CyaSSL_new error.\n");
|
fprintf(stderr, "CyaSSL_new error.\n");
|
||||||
|
@ -101,8 +101,8 @@ int AcceptAndRead(CYASSL_CTX* ctx, socklen_t sockfd, struct sockaddr_in
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CyaSSL_free(ssl); /* Free the CYASSL object */
|
||||||
}
|
}
|
||||||
CyaSSL_free(ssl); /* Free the CYASSL object */
|
|
||||||
close(connd); /* close the connected socket */
|
close(connd); /* close the connected socket */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -129,7 +129,7 @@ int main()
|
||||||
CyaSSL_Init();
|
CyaSSL_Init();
|
||||||
|
|
||||||
/* If positive value, the socket is valid */
|
/* If positive value, the socket is valid */
|
||||||
if (sockfd < 0) {
|
if (sockfd == -1) {
|
||||||
printf("ERROR: failed to create the socket\n");
|
printf("ERROR: failed to create the socket\n");
|
||||||
return EXIT_FAILURE; /* Kill the server with exit status 1 */
|
return EXIT_FAILURE; /* Kill the server with exit status 1 */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue