summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Noordhuis <pcnoordhuis@gmail.com>2010-10-06 21:23:03 +0200
committerPieter Noordhuis <pcnoordhuis@gmail.com>2010-10-06 21:23:03 +0200
commit5c7b5fca4d36fbf5050a1b36e9308fdd8bf5813c (patch)
treea3255e9a4405a94b49bf97d51ca6ad78213d90b9
parent1a5f111d5208ce3ea5d0d64fa167cec6781abd4f (diff)
Make error messages more consistent (e.g. no newline)
-rw-r--r--anet.c30
-rw-r--r--example.c2
-rw-r--r--hiredis.c6
-rw-r--r--libevent-example.c2
-rw-r--r--test.c2
5 files changed, 21 insertions, 21 deletions
diff --git a/anet.c b/anet.c
index 45b8620..aec2cc7 100644
--- a/anet.c
+++ b/anet.c
@@ -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;
}
}
diff --git a/example.c b/example.c
index 7c3f353..9e53b35 100644
--- a/example.c
+++ b/example.c
@@ -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);
}
diff --git a/hiredis.c b/hiredis.c
index e59919d..4544c28 100644
--- a/hiredis.c
+++ b/hiredis.c
@@ -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;
}
diff --git a/test.c b/test.c
index cca1587..e4de5cd 100644
--- a/test.c
+++ b/test.c
@@ -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);
}
}