No need to save the state of errno

We don't have any library calls afterwards, so it's fine.
This commit is contained in:
Nicolás A. Ortega 2017-07-24 16:14:47 -05:00
parent 6cc7de6383
commit 2dcdf5b74e
No known key found for this signature in database
GPG Key ID: 3D786FB3123FF1DD

View File

@ -33,20 +33,19 @@ int NeoComm_bind(const unsigned short port) {
struct sockaddr_in serv_addr;
sockfd = socket(AF_INET, SOCK_STREAM, 0);
int errsv = errno;
if(sockfd < 0)
{
if(errsv == EACCES)
if(errno == EACCES)
NeoComm_error("Insufficient privileges");
else if(errsv == ENOBUFS)
else if(errno == ENOBUFS)
NeoComm_error("Insufficient resources available");
else if(errsv == ENOMEM)
else if(errno == ENOMEM)
NeoComm_error("Insufficient memory to open socket");
else
{
char error_msg[128];
snprintf(error_msg, 128, "Failed to initiate socket with errno `%d'",
errsv);
errno);
NeoComm_error(error_msg);
}
return 0;
@ -57,7 +56,6 @@ int NeoComm_bind(const unsigned short port) {
serv_addr.sin_addr.s_addr = INADDR_ANY;
if(bind(sockfd, (struct sockaddr*) &serv_addr, sizeof(serv_addr)) < 0)
{
/*int errsv = errno;*/
// TODO: Handle all these errors and shit, I'm too lazy right now
return 0;
}