diff --git a/include/server.h b/include/server.h index 9f5a0ef..402c430 100644 --- a/include/server.h +++ b/include/server.h @@ -26,8 +26,8 @@ #ifndef __SERVER_H__ #define __SERVER_H__ -#include /* for printf() and fprintf() */ -#include /* for select system call and related */ +#include // for printf() and fprintf() +#include // for poll system call and related #include "class.h" #include "socket.h" diff --git a/include/socket.h b/include/socket.h index 71c83f9..8b61b9c 100644 --- a/include/socket.h +++ b/include/socket.h @@ -25,7 +25,7 @@ #ifndef __SOCKET_H__ #define __SOCKET_H__ -#include /* for in_port_t */ +#include // for in_port_t #include "class.h" #include "logger.h" diff --git a/src/http/header.c b/src/http/header.c index 6b12a5d..839a52d 100644 --- a/src/http/header.c +++ b/src/http/header.c @@ -46,9 +46,9 @@ ctor(void * _this, va_list * params) { this->hash = sdbm((unsigned char *)name); - this->value = malloc(sizeof(char*) * (++this->nvalue)); - this->value[this->nvalue - 1] = malloc(strlen(value) + 1); - strcpy(this->value[this->nvalue - 1], value); + this->value = malloc(sizeof(char*) * (++(this->nvalue))); + (this->value)[this->nvalue - 1] = malloc(strlen(value) + 1); + strcpy((this->value)[this->nvalue - 1], value); return 0; } diff --git a/src/http/header/add.c b/src/http/header/add.c index 5af6bbe..dd21805 100644 --- a/src/http/header/add.c +++ b/src/http/header/add.c @@ -46,8 +46,11 @@ httpHeaderAdd(const HttpHeader * root, HttpHeader header) HttpHeader * found = tsearch(header, (void **)root, comp); if (*found != header) { - (*found)->value = realloc((*found)->value, sizeof(char) * (++(*found)->nvalue)); - (*found)->value[(*found)->nvalue - 1] = malloc(strlen(header->value) + 1); + (*found)->value = realloc( + (*found)->value, + sizeof(char*) * (++(*found)->nvalue)); + (*found)->value[(*found)->nvalue - 1] = malloc( + strlen((header->value)[0]) + 1); strcpy(((*found)->value)[(*found)->nvalue - 1], (header->value)[0]); delete(&header); } diff --git a/src/http/response/me.c b/src/http/response/me.c index 809a143..de7dc57 100644 --- a/src/http/response/me.c +++ b/src/http/response/me.c @@ -76,7 +76,7 @@ httpResponseMe(int value) new(HttpHeader, "Set-Cookie", "profession=\"coder\"")); message->type = HTTP_MESSAGE_BUFFERED; - message->nbody = sizeof(RESP_DATA) - 1; + message->nbody = sizeof(RESP_DATA)-1-2; message->body = calloc(1, sizeof(RESP_DATA)-2); sprintf(message->body, RESP_DATA, value); diff --git a/src/server/poll.c b/src/server/poll.c index 0b5a775..2944710 100644 --- a/src/server/poll.c +++ b/src/server/poll.c @@ -67,7 +67,7 @@ serverPoll(Server this) { case EINVAL: case ENOMEM: doShutdown = 1; - /* Fallthrough */ + // DROP THROUGH case EINTR: loggerLog(this->logger, LOGGER_CRIT, diff --git a/src/server/read.c b/src/server/read.c index 4bc350f..f08db59 100644 --- a/src/server/read.c +++ b/src/server/read.c @@ -47,7 +47,7 @@ serverRead(Server this, unsigned int i) * \todo make sure all pending writes will be done before * close. */ - /* DROP-THROUGH */ + // DROP-THROUGH case -1: /* diff --git a/src/testserver.c b/src/testserver.c index c545ea0..605fb8a 100644 --- a/src/testserver.c +++ b/src/testserver.c @@ -88,12 +88,12 @@ main() close(shm); - /* Block SIGALRM */ + // Block SIGALRM sigemptyset(&block_these); sigaddset(&block_these, SIGALRM); sigprocmask(SIG_BLOCK, &block_these, &pause_mask); - /* Set up handler for SIGALRM */ + // Set up handler for SIGALRM sigemptyset(&s.sa_mask); sigaddset(&s.sa_mask, SIGINT); s.sa_flags = 0; diff --git a/src/utils/daemonize.c b/src/utils/daemonize.c index 6d77a08..bdd61f5 100644 --- a/src/utils/daemonize.c +++ b/src/utils/daemonize.c @@ -22,8 +22,8 @@ * along with this program. If not, see . */ -#include /* for printf() and fprintf() */ -#include /* for getopt */ +#include // for printf() and fprintf() +#include // for getopt #include