diff options
author | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2010-10-06 21:23:03 +0200 |
---|---|---|
committer | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2010-10-06 21:23:03 +0200 |
commit | 5c7b5fca4d36fbf5050a1b36e9308fdd8bf5813c (patch) | |
tree | a3255e9a4405a94b49bf97d51ca6ad78213d90b9 | |
parent | 1a5f111d5208ce3ea5d0d64fa167cec6781abd4f (diff) |
Make error messages more consistent (e.g. no newline)
-rw-r--r-- | anet.c | 30 | ||||
-rw-r--r-- | example.c | 2 | ||||
-rw-r--r-- | hiredis.c | 6 | ||||
-rw-r--r-- | libevent-example.c | 2 | ||||
-rw-r--r-- | test.c | 2 |
5 files changed, 21 insertions, 21 deletions
@@ -63,11 +63,11 @@ int anetNonBlock(char *err, int fd) * Note that fcntl(2) for F_GETFL and F_SETFL can't be * interrupted by a signal. */ if ((flags = fcntl(fd, F_GETFL)) == -1) { - anetSetError(err, "fcntl(F_GETFL): %s\n", strerror(errno)); + anetSetError(err, "fcntl(F_GETFL): %s", strerror(errno)); return ANET_ERR; } if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1) { - anetSetError(err, "fcntl(F_SETFL,O_NONBLOCK): %s\n", strerror(errno)); + anetSetError(err, "fcntl(F_SETFL,O_NONBLOCK): %s", strerror(errno)); return ANET_ERR; } return ANET_OK; @@ -78,7 +78,7 @@ int anetTcpNoDelay(char *err, int fd) int yes = 1; if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &yes, sizeof(yes)) == -1) { - anetSetError(err, "setsockopt TCP_NODELAY: %s\n", strerror(errno)); + anetSetError(err, "setsockopt(TCP_NODELAY): %s", strerror(errno)); return ANET_ERR; } return ANET_OK; @@ -88,7 +88,7 @@ int anetSetSendBuffer(char *err, int fd, int buffsize) { if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &buffsize, sizeof(buffsize)) == -1) { - anetSetError(err, "setsockopt SO_SNDBUF: %s\n", strerror(errno)); + anetSetError(err, "setsockopt(SO_SNDBUF): %s", strerror(errno)); return ANET_ERR; } return ANET_OK; @@ -98,7 +98,7 @@ int anetTcpKeepAlive(char *err, int fd) { int yes = 1; if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &yes, sizeof(yes)) == -1) { - anetSetError(err, "setsockopt SO_KEEPALIVE: %s\n", strerror(errno)); + anetSetError(err, "setsockopt(SO_KEEPALIVE): %s", strerror(errno)); return ANET_ERR; } return ANET_OK; @@ -114,7 +114,7 @@ int anetResolve(char *err, char *host, char *ipbuf) he = gethostbyname(host); if (he == NULL) { - anetSetError(err, "can't resolve: %s\n", host); + anetSetError(err, "can't resolve: %s", host); return ANET_ERR; } memcpy(&sa.sin_addr, he->h_addr, sizeof(struct in_addr)); @@ -131,7 +131,7 @@ static int anetTcpGenericConnect(char *err, const char *addr, int port, int flag struct sockaddr_in sa; if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1) { - anetSetError(err, "creating socket: %s\n", strerror(errno)); + anetSetError(err, "creating socket: %s", strerror(errno)); return ANET_ERR; } /* Make sure connection-intensive things like the redis benckmark @@ -145,7 +145,7 @@ static int anetTcpGenericConnect(char *err, const char *addr, int port, int flag he = gethostbyname(addr); if (he == NULL) { - anetSetError(err, "can't resolve: %s\n", addr); + anetSetError(err, "can't resolve: %s", addr); close(s); return ANET_ERR; } @@ -160,7 +160,7 @@ static int anetTcpGenericConnect(char *err, const char *addr, int port, int flag flags & ANET_CONNECT_NONBLOCK) return s; - anetSetError(err, "connect: %s\n", strerror(errno)); + anetSetError(err, "connect: %s", strerror(errno)); close(s); return ANET_ERR; } @@ -213,11 +213,11 @@ int anetTcpServer(char *err, int port, char *bindaddr) struct sockaddr_in sa; if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1) { - anetSetError(err, "socket: %s\n", strerror(errno)); + anetSetError(err, "socket: %s", strerror(errno)); return ANET_ERR; } if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) { - anetSetError(err, "setsockopt SO_REUSEADDR: %s\n", strerror(errno)); + anetSetError(err, "setsockopt(SO_REUSEADDR): %s", strerror(errno)); close(s); return ANET_ERR; } @@ -227,18 +227,18 @@ int anetTcpServer(char *err, int port, char *bindaddr) sa.sin_addr.s_addr = htonl(INADDR_ANY); if (bindaddr) { if (inet_aton(bindaddr, &sa.sin_addr) == 0) { - anetSetError(err, "Invalid bind address\n"); + anetSetError(err, "inet_aton: Invalid bind address"); close(s); return ANET_ERR; } } if (bind(s, (struct sockaddr*)&sa, sizeof(sa)) == -1) { - anetSetError(err, "bind: %s\n", strerror(errno)); + anetSetError(err, "bind: %s", strerror(errno)); close(s); return ANET_ERR; } if (listen(s, 511) == -1) { /* the magic 511 constant is from nginx */ - anetSetError(err, "listen: %s\n", strerror(errno)); + anetSetError(err, "listen: %s", strerror(errno)); close(s); return ANET_ERR; } @@ -258,7 +258,7 @@ int anetAccept(char *err, int serversock, char *ip, int *port) if (errno == EINTR) continue; else { - anetSetError(err, "accept: %s\n", strerror(errno)); + anetSetError(err, "accept: %s", strerror(errno)); return ANET_ERR; } } @@ -11,7 +11,7 @@ int main(void) { c = redisConnect((char*)"127.0.0.1", 6379, NULL); if (c->error != NULL) { - printf("Connection error: %s", c->error); + printf("Connection error: %s\n", c->error); exit(1); } @@ -643,12 +643,12 @@ int redisBufferRead(redisContext *c) { } else { /* Set error in context */ c->error = sdscatprintf(sdsempty(), - "Error reading from socket: %s", strerror(errno)); + "read: %s", strerror(errno)); return REDIS_ERR; } } else if (nread == 0) { c->error = sdscatprintf(sdsempty(), - "Server closed the connection"); + "read: Server closed the connection"); return REDIS_ERR; } else { redisReplyReaderFeed(c->reader,buf,nread); @@ -704,7 +704,7 @@ int redisBufferWrite(redisContext *c, int *done) { } else { /* Set error in context */ c->error = sdscatprintf(sdsempty(), - "Error writing to socket: %s", strerror(errno)); + "write: %s", strerror(errno)); return REDIS_ERR; } } else if (nwritten > 0) { diff --git a/libevent-example.c b/libevent-example.c index 5e0bb9f..d9c8784 100644 --- a/libevent-example.c +++ b/libevent-example.c @@ -85,7 +85,7 @@ int main (int argc, char **argv) { redisContext *c = redisLibEventConnect("127.0.0.1", 6379); if (c->error != NULL) { - printf("Connect error: %s\n", c->error); + printf("Connection error: %s\n", c->error); return 1; } @@ -20,7 +20,7 @@ static void __connect(redisContext **target) { redisContext *c; c = *target = redisConnect((char*)"127.0.0.1", 6379, NULL); if (c->error != NULL) { - printf("Connection error: %s", c->error); + printf("Connection error: %s\n", c->error); exit(1); } } |