[sheepdog] [PATCH 3/3] remove newline from sd_printf format string

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Mon Feb 25 09:31:12 CET 2013


This simplifies codes a bit.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 include/sheep.h           |   2 +-
 include/util.h            |   2 +-
 lib/event.c               |  18 ++++----
 lib/logger.c              |  14 +++---
 lib/net.c                 |  67 ++++++++++++++-------------
 lib/util.c                |  18 ++++----
 sheep/cluster.h           |   2 +-
 sheep/cluster/corosync.c  |  60 ++++++++++++------------
 sheep/cluster/local.c     |  36 +++++++--------
 sheep/cluster/zookeeper.c |  84 +++++++++++++++++-----------------
 sheep/config.c            |  16 +++----
 sheep/farm/farm.c         |  32 ++++++-------
 sheep/farm/sha1_file.c    |  31 ++++++-------
 sheep/farm/snap.c         |  11 ++---
 sheep/farm/trunk.c        |  12 ++---
 sheep/gateway.c           |  22 ++++-----
 sheep/group.c             | 109 +++++++++++++++++++++-----------------------
 sheep/journal.c           |  30 ++++++------
 sheep/journal_file.c      |  36 +++++++--------
 sheep/migrate.c           |  32 ++++++-------
 sheep/object_cache.c      | 114 ++++++++++++++++++++++------------------------
 sheep/object_list_cache.c |   6 +--
 sheep/ops.c               |  38 ++++++++--------
 sheep/plain_store.c       |  78 +++++++++++++++----------------
 sheep/recovery.c          |  64 +++++++++++++-------------
 sheep/request.c           |  76 ++++++++++++++-----------------
 sheep/sheep.c             |  37 ++++++++-------
 sheep/sockfd_cache.c      |  34 +++++++-------
 sheep/store.c             |  52 ++++++++++-----------
 sheep/trace/trace.c       |  26 +++++------
 sheep/vdi.c               |  62 ++++++++++++-------------
 sheep/work.c              |  13 +++---
 32 files changed, 600 insertions(+), 634 deletions(-)

diff --git a/include/sheep.h b/include/sheep.h
index 7178795..a3bba2d 100644
--- a/include/sheep.h
+++ b/include/sheep.h
@@ -105,7 +105,7 @@ static inline int get_vnode_next_idx(const struct sd_vnode *entries,
 	for (;;) {
 		idx = (idx + 1) % nr_entries;
 		if (idx == first_idx)
-			panic("can't find next new idx\n");
+			panic("can't find next new idx");
 
 		for (found = false, i = 0; i < nr_prev_idxs; i++) {
 			if (same_zone(entries, idx, prev_idxs[i])) {
diff --git a/include/util.h b/include/util.h
index 8588ddd..0530a2c 100644
--- a/include/util.h
+++ b/include/util.h
@@ -99,7 +99,7 @@ void untrim_zero_sectors(void *buf, uint64_t offset, uint32_t len,
 #ifndef NDEBUG
 
 #define assert(expr) ((expr) ?						\
-			(void)0 : panic("Asserting `%s' failed.\n", #expr))
+			(void)0 : panic("Asserting `%s' failed.", #expr))
 
 #else
 
diff --git a/lib/event.c b/lib/event.c
index 8b84a53..536b285 100644
--- a/lib/event.c
+++ b/lib/event.c
@@ -47,7 +47,7 @@ void add_timer(struct timer *t, unsigned int mseconds)
 
 	tfd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
 	if (tfd < 0) {
-		sd_eprintf("timerfd_create: %m\n");
+		sd_eprintf("timerfd_create: %m");
 		return;
 	}
 
@@ -56,12 +56,12 @@ void add_timer(struct timer *t, unsigned int mseconds)
 	it.it_value.tv_nsec = (mseconds % 1000) * 1000000;
 
 	if (timerfd_settime(tfd, 0, &it, NULL) < 0) {
-		sd_eprintf("timerfd_settime: %m\n");
+		sd_eprintf("timerfd_settime: %m");
 		return;
 	}
 
 	if (register_event(tfd, timer_handler, t) < 0)
-		sd_eprintf("failed to register timer fd\n");
+		sd_eprintf("failed to register timer fd");
 }
 
 struct event_info {
@@ -75,7 +75,7 @@ int init_event(int nr)
 {
 	efd = epoll_create(nr);
 	if (efd < 0) {
-		sd_eprintf("failed to create epoll fd\n");
+		sd_eprintf("failed to create epoll fd");
 		return -1;
 	}
 	return 0;
@@ -109,7 +109,7 @@ int register_event(int fd, event_handler_t h, void *data)
 
 	ret = epoll_ctl(efd, EPOLL_CTL_ADD, fd, &ev);
 	if (ret) {
-		sd_eprintf("failed to add epoll event: %m\n");
+		sd_eprintf("failed to add epoll event: %m");
 		free(ei);
 	} else
 		list_add(&ei->ei_list, &events_list);
@@ -128,7 +128,7 @@ void unregister_event(int fd)
 
 	ret = epoll_ctl(efd, EPOLL_CTL_DEL, fd, NULL);
 	if (ret)
-		sd_eprintf("failed to delete epoll event for fd %d: %m\n", fd);
+		sd_eprintf("failed to delete epoll event for fd %d: %m", fd);
 
 	list_del(&ei->ei_list);
 	free(ei);
@@ -142,7 +142,7 @@ int modify_event(int fd, unsigned int events)
 
 	ei = lookup_event(fd);
 	if (!ei) {
-		sd_eprintf("event info for fd %d not found\n", fd);
+		sd_eprintf("event info for fd %d not found", fd);
 		return 1;
 	}
 
@@ -152,7 +152,7 @@ int modify_event(int fd, unsigned int events)
 
 	ret = epoll_ctl(efd, EPOLL_CTL_MOD, fd, &ev);
 	if (ret) {
-		sd_eprintf("failed to delete epoll event for fd %d: %m\n", fd);
+		sd_eprintf("failed to delete epoll event for fd %d: %m", fd);
 		return 1;
 	}
 	return 0;
@@ -167,7 +167,7 @@ void event_loop(int timeout)
 	if (nr < 0) {
 		if (errno == EINTR)
 			return;
-		sd_eprintf("epoll_wait failed: %m\n");
+		sd_eprintf("epoll_wait failed: %m");
 		exit(1);
 	} else if (nr) {
 		for (i = 0; i < nr; i++) {
diff --git a/lib/logger.c b/lib/logger.c
index 1b0fb15..57e0a09 100644
--- a/lib/logger.c
+++ b/lib/logger.c
@@ -451,11 +451,11 @@ static notrace void log_flush(void)
 
 static notrace void crash_handler(int signo)
 {
-	if (signo == SIGHUP) {
-		sd_printf(SDOG_ERR, "sheep pid %d exited unexpectedly.\n",
-			sheep_pid);
-	} else {
-		sd_printf(SDOG_ERR, "logger pid %d exits unexpectedly (%s).\n",
+	if (signo == SIGHUP)
+		sd_printf(SDOG_ERR, "sheep pid %d exited unexpectedly.",
+			  sheep_pid);
+	else {
+		sd_printf(SDOG_ERR, "logger pid %d exits unexpectedly (%s).",
 			  getpid(), strsignal(signo));
 		sd_backtrace();
 	}
@@ -657,7 +657,7 @@ notrace void sd_backtrace(void)
 			goto fallback_close;
 
 		if (info[0] != '?' && info[0] != '\0')
-			sd_printf(SDOG_EMERG, "%s\n", info);
+			sd_printf(SDOG_EMERG, "%s", info);
 		else
 			goto fallback_close;
 
@@ -669,7 +669,7 @@ fallback_close:
 		pclose(f);
 fallback:
 		str = backtrace_symbols(&addr, 1);
-		sd_printf(SDOG_EMERG, "%s\n", *str);
+		sd_printf(SDOG_EMERG, "%s", *str);
 		free(str);
 	}
 }
diff --git a/lib/net.c b/lib/net.c
index d5a9efe..ff0c150 100644
--- a/lib/net.c
+++ b/lib/net.c
@@ -130,7 +130,7 @@ int create_listen_ports(const char *bindaddr, int port,
 
 	ret = getaddrinfo(bindaddr, servname, &hints, &res0);
 	if (ret) {
-		sd_eprintf("failed to get address info: %m\n");
+		sd_eprintf("failed to get address info: %m");
 		return 1;
 	}
 
@@ -143,7 +143,7 @@ int create_listen_ports(const char *bindaddr, int port,
 		ret = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt,
 				 sizeof(opt));
 		if (ret)
-			sd_eprintf("failed to set SO_REUSEADDR: %m\n");
+			sd_eprintf("failed to set SO_REUSEADDR: %m");
 
 		opt = 1;
 		if (res->ai_family == AF_INET6) {
@@ -157,14 +157,14 @@ int create_listen_ports(const char *bindaddr, int port,
 
 		ret = bind(fd, res->ai_addr, res->ai_addrlen);
 		if (ret) {
-			sd_eprintf("failed to bind server socket: %m\n");
+			sd_eprintf("failed to bind server socket: %m");
 			close(fd);
 			continue;
 		}
 
 		ret = listen(fd, SOMAXCONN);
 		if (ret) {
-			sd_eprintf("failed to listen on server socket: %m\n");
+			sd_eprintf("failed to listen on server socket: %m");
 			close(fd);
 			continue;
 		}
@@ -187,7 +187,7 @@ int create_listen_ports(const char *bindaddr, int port,
 	freeaddrinfo(res0);
 
 	if (!success)
-		sd_eprintf("failed to create a listening port\n");
+		sd_eprintf("failed to create a listening port");
 
 	return !success;
 }
@@ -207,7 +207,7 @@ int connect_to(const char *name, int port)
 
 	ret = getaddrinfo(name, buf, &hints, &res0);
 	if (ret) {
-		sd_eprintf("failed to get address info: %m\n");
+		sd_eprintf("failed to get address info: %m");
 		return -1;
 	}
 
@@ -225,36 +225,36 @@ int connect_to(const char *name, int port)
 		ret = setsockopt(fd, SOL_SOCKET, SO_LINGER, &linger_opt,
 				 sizeof(linger_opt));
 		if (ret) {
-			sd_eprintf("failed to set SO_LINGER: %m\n");
+			sd_eprintf("failed to set SO_LINGER: %m");
 			close(fd);
 			continue;
 		}
 
 		ret = set_snd_timeout(fd);
 		if (ret) {
-			sd_eprintf("failed to set send timeout: %m\n");
+			sd_eprintf("failed to set send timeout: %m");
 			close(fd);
 			break;
 		}
 
 		ret = set_rcv_timeout(fd);
 		if (ret) {
-			sd_eprintf("failed to set recv timeout: %m\n");
+			sd_eprintf("failed to set recv timeout: %m");
 			close(fd);
 			break;
 		}
 
 		ret = connect(fd, res->ai_addr, res->ai_addrlen);
 		if (ret) {
-			sd_eprintf("failed to connect to %s:%d: %m\n",
-				name, port);
+			sd_eprintf("failed to connect to %s:%d: %m", name,
+				   port);
 			close(fd);
 			continue;
 		}
 
 		ret = set_nodelay(fd);
 		if (ret) {
-			sd_eprintf("%m\n");
+			sd_eprintf("%m");
 			close(fd);
 			break;
 		} else
@@ -263,7 +263,7 @@ int connect_to(const char *name, int port)
 	fd = -1;
 success:
 	freeaddrinfo(res0);
-	sd_dprintf("%d, %s:%d\n", fd, name, port);
+	sd_dprintf("%d, %s:%d", fd, name, port);
 	return fd;
 }
 
@@ -286,8 +286,7 @@ reread:
 			goto reread;
 		}
 
-		sd_eprintf("failed to read from socket: %d, %d(%m)\n",
-			ret, errno);
+		sd_eprintf("failed to read from socket: %d, %m", ret);
 		return 1;
 	}
 
@@ -331,7 +330,7 @@ rewrite:
 			goto rewrite;
 		}
 
-		sd_eprintf("failed to write to socket: %m\n");
+		sd_eprintf("failed to write to socket: %m");
 		return 1;
 	}
 
@@ -367,8 +366,8 @@ int send_req(int sockfd, struct sd_req *hdr, void *data, unsigned int wlen,
 
 	ret = do_write(sockfd, &msg, sizeof(*hdr) + wlen, need_retry, epoch);
 	if (ret) {
-		sd_eprintf("failed to send request %x, %d: %m\n", hdr->opcode,
-			wlen);
+		sd_eprintf("failed to send request %x, %d: %m", hdr->opcode,
+			   wlen);
 		ret = -1;
 	}
 
@@ -395,7 +394,7 @@ int exec_req(int sockfd, struct sd_req *hdr, void *data,
 
 	ret = do_read(sockfd, rsp, sizeof(*rsp), need_retry, epoch);
 	if (ret) {
-		sd_eprintf("failed to read a response\n");
+		sd_eprintf("failed to read a response");
 		return 1;
 	}
 
@@ -405,7 +404,7 @@ int exec_req(int sockfd, struct sd_req *hdr, void *data,
 	if (rlen) {
 		ret = do_read(sockfd, data, rlen, need_retry, epoch);
 		if (ret) {
-			sd_eprintf("failed to read the response data\n");
+			sd_eprintf("failed to read the response data");
 			return 1;
 		}
 	}
@@ -456,12 +455,12 @@ int set_nonblocking(int fd)
 
 	ret = fcntl(fd, F_GETFL);
 	if (ret < 0) {
-		sd_eprintf("fcntl F_GETFL failed: %m\n");
+		sd_eprintf("fcntl F_GETFL failed: %m");
 		close(fd);
 	} else {
 		ret = fcntl(fd, F_SETFL, ret | O_NONBLOCK);
 		if (ret < 0)
-			sd_eprintf("fcntl O_NONBLOCK failed: %m\n");
+			sd_eprintf("fcntl O_NONBLOCK failed: %m");
 	}
 
 	return ret;
@@ -512,22 +511,22 @@ int set_keepalive(int fd)
 	int val = 1;
 
 	if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val)) < 0) {
-		sd_dprintf("%m\n");
+		sd_dprintf("%m");
 		return -1;
 	}
 	val = 5;
 	if (setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, &val, sizeof(val)) < 0) {
-		sd_dprintf("%m\n");
+		sd_dprintf("%m");
 		return -1;
 	}
 	val = 1;
 	if (setsockopt(fd, SOL_TCP, TCP_KEEPINTVL, &val, sizeof(val)) < 0) {
-		sd_dprintf("%m\n");
+		sd_dprintf("%m");
 		return -1;
 	}
 	val = 3;
 	if (setsockopt(fd, SOL_TCP, TCP_KEEPCNT, &val, sizeof(val)) < 0) {
-		sd_dprintf("%m\n");
+		sd_dprintf("%m");
 		return -1;
 	}
 	return 0;
@@ -539,7 +538,7 @@ int get_local_addr(uint8_t *bytes)
 	int ret = 0;
 
 	if (getifaddrs(&ifaddr) == -1) {
-		sd_eprintf("getifaddrs failed: %m\n");
+		sd_eprintf("getifaddrs failed: %m");
 		return -1;
 	}
 
@@ -559,17 +558,17 @@ int get_local_addr(uint8_t *bytes)
 			memset(bytes, 0, 12);
 			memcpy(bytes + 12, &sin->sin_addr, 4);
 			memcpy(bytes + 12, &sin->sin_addr, 4);
-			sd_eprintf("found IPv4 address\n");
+			sd_eprintf("found IPv4 address");
 			goto out;
 		case AF_INET6:
 			sin6 = (struct sockaddr_in6 *)ifa->ifa_addr;
 			memcpy(bytes, &sin6->sin6_addr, 16);
-			sd_eprintf("found IPv6 address\n");
+			sd_eprintf("found IPv6 address");
 			goto out;
 		}
 	}
 
-	sd_eprintf("no valid interface found\n");
+	sd_eprintf("no valid interface found");
 	ret = -1;
 out:
 	freeifaddrs(ifaddr);
@@ -587,19 +586,19 @@ int create_unix_domain_socket(const char *unix_path,
 
 	fd = socket(addr.sun_family, SOCK_STREAM, 0);
 	if (fd < 0) {
-		sd_eprintf("failed to create socket, %m\n");
+		sd_eprintf("failed to create socket, %m");
 		return -1;
 	}
 
 	ret = bind(fd, &addr, sizeof(addr));
 	if (ret) {
-		sd_eprintf("failed to bind socket: %m\n");
+		sd_eprintf("failed to bind socket: %m");
 		goto err;
 	}
 
 	ret = listen(fd, SOMAXCONN);
 	if (ret) {
-		sd_eprintf("failed to listen on socket: %m\n");
+		sd_eprintf("failed to listen on socket: %m");
 		goto err;
 	}
 
@@ -625,7 +624,7 @@ bool inetaddr_is_valid(char *addr)
 
 	af = strstr(addr, ":") ? AF_INET6 : AF_INET;
 	if (!inet_pton(af, addr, buf)) {
-		sd_eprintf("Bad address '%s'\n", addr);
+		sd_eprintf("Bad address '%s'", addr);
 		return false;
 	}
 	return true;
diff --git a/lib/util.c b/lib/util.c
index b0d5616..3ac89c0 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -50,7 +50,7 @@ void *xmalloc(size_t size)
 		if (!ret && !size)
 			ret = malloc(1);
 		if (!ret)
-			panic("Out of memory\n");
+			panic("Out of memory");
 	}
 	return ret;
 }
@@ -71,7 +71,7 @@ notrace void *xrealloc(void *ptr, size_t size)
 		if (!ret && !size)
 			ret = realloc(ptr, 1);
 		if (!ret)
-			panic("Out of memory\n");
+			panic("Out of memory");
 	}
 	return ret;
 }
@@ -87,7 +87,7 @@ void *xcalloc(size_t nmemb, size_t size)
 		if (!ret && (!nmemb || !size))
 			ret = calloc(1, 1);
 		if (!ret)
-			panic("Out of memory\n");
+			panic("Out of memory");
 	}
 	return ret;
 }
@@ -96,7 +96,7 @@ void *xvalloc(size_t size)
 {
 	void *ret = valloc(size);
 	if (!ret)
-		panic("Out of memory\n");
+		panic("Out of memory");
 	return ret;
 }
 
@@ -265,7 +265,7 @@ int rmdir_r(char *dir_path)
 	dir = opendir(dir_path);
 	if (!dir) {
 		if (errno != ENOENT)
-			sd_eprintf("failed to open %s: %m\n", dir_path);
+			sd_eprintf("failed to open %s: %m", dir_path);
 		return -errno;
 	}
 
@@ -276,7 +276,7 @@ int rmdir_r(char *dir_path)
 		snprintf(path, sizeof(path), "%s/%s", dir_path, d->d_name);
 		ret = stat(path, &s);
 		if (ret) {
-			sd_eprintf("failed to stat %s: %m\n", path);
+			sd_eprintf("failed to stat %s: %m", path);
 			goto out;
 		}
 		if (S_ISDIR(s.st_mode))
@@ -285,9 +285,9 @@ int rmdir_r(char *dir_path)
 			ret = unlink(path);
 
 		if (ret != 0) {
-			sd_eprintf("failed to remove %s %s: %m\n",
-					S_ISDIR(s.st_mode) ? "directory" : "file",
-					path);
+			sd_eprintf("failed to remove %s %s: %m",
+				   S_ISDIR(s.st_mode) ? "directory" : "file",
+				   path);
 			goto out;
 		}
 	}
diff --git a/sheep/cluster.h b/sheep/cluster.h
index 2ef8f26..df73d06 100644
--- a/sheep/cluster.h
+++ b/sheep/cluster.h
@@ -121,7 +121,7 @@ extern struct list_head cluster_drivers;
 static void __attribute__((constructor)) regist_ ## driver(void)	\
 {									\
 	if (!driver.init || !driver.join || !driver.leave || !driver.notify) \
-		panic("the driver '%s' is incomplete\n", driver.name);	\
+		panic("the driver '%s' is incomplete", driver.name);	\
 	list_add(&driver.list, &cluster_drivers);			\
 }
 
diff --git a/sheep/cluster/corosync.c b/sheep/cluster/corosync.c
index fb43a8b..e3224e4 100644
--- a/sheep/cluster/corosync.c
+++ b/sheep/cluster/corosync.c
@@ -119,7 +119,7 @@ static inline void del_cpg_node(struct cpg_node *nodes, size_t nr_nodes,
 
 	idx = find_cpg_node(nodes, nr_nodes, deled);
 	if (idx < 0) {
-		sd_dprintf("cannot find node\n");
+		sd_dprintf("cannot find node");
 		return;
 	}
 
@@ -139,12 +139,12 @@ static int corosync_get_local_addr(uint8_t *addr)
 	ret = corosync_cfg_get_node_addrs(cfg_handle, this_node.nodeid, 1,
 					  &nr, &caddr);
 	if (ret != CS_OK) {
-		sd_printf(SDOG_ERR, "failed to get node addresses (%d)\n", ret);
+		sd_printf(SDOG_ERR, "failed to get node addresses (%d)", ret);
 		return -1;
 	}
 
 	if (!nr) {
-		sd_printf(SDOG_ERR, "no node addresses found\n");
+		sd_printf(SDOG_ERR, "no node addresses found");
 		return -1;
 	}
 
@@ -156,7 +156,7 @@ static int corosync_get_local_addr(uint8_t *addr)
 		memset(addr, 0, 16);
 		memcpy(addr + 12, saddr, 4);
 	} else {
-		sd_printf(SDOG_ERR, "unknown protocol %d\n", ss->ss_family);
+		sd_printf(SDOG_ERR, "unknown protocol %d", ss->ss_family);
 		return -1;
 	}
 
@@ -194,11 +194,11 @@ retry:
 	case CS_OK:
 		break;
 	case CS_ERR_TRY_AGAIN:
-		sd_dprintf("failed to send message: retrying\n");
+		sd_dprintf("failed to send message: retrying");
 		sleep(1);
 		goto retry;
 	default:
-		sd_eprintf("failed to send message (%d)\n", ret);
+		sd_eprintf("failed to send message (%d)", ret);
 		return -1;
 	}
 	return 0;
@@ -306,8 +306,8 @@ static bool __corosync_dispatch_one(struct corosync_event *cevent)
 			     cevent->msg, cevent->msg_len);
 
 		if (res == CJ_RES_MASTER_TRANSFER) {
-			sd_eprintf("failed to join sheepdog cluster:"	\
-				" please retry when master is up\n");
+			sd_eprintf("failed to join sheepdog cluster:"
+				   " please retry when master is up");
 			exit(1);
 		}
 
@@ -369,7 +369,7 @@ static void __corosync_dispatch(void)
 		 * when network partition has occured.  To count the
 		 * number of alive nodes correctly, we postpone
 		 * processsing events if there are incoming ones. */
-		sd_dprintf("wait for a next dispatch event\n");
+		sd_dprintf("wait for a next dispatch event");
 		return;
 	}
 
@@ -442,7 +442,7 @@ update_event(enum corosync_event_type type, struct cpg_node *sender, void *msg,
 	if (msg_len) {
 		cevent->msg = realloc(cevent->msg, msg_len);
 		if (!cevent->msg)
-			panic("failed to allocate memory\n");
+			panic("failed to allocate memory");
 		memcpy(cevent->msg, msg, msg_len);
 	} else {
 		free(cevent->msg);
@@ -469,7 +469,7 @@ static void cdrv_cpg_deliver(cpg_handle_t handle,
 	struct corosync_message *cmsg = msg;
 	int master;
 
-	sd_dprintf("%d\n", cmsg->type);
+	sd_dprintf("%d", cmsg->type);
 
 	switch (cmsg->type) {
 	case COROSYNC_MSG_TYPE_JOIN_REQUEST:
@@ -574,9 +574,8 @@ static void cdrv_cpg_confchg(cpg_handle_t handle,
 	struct cpg_node left_sheep[SD_MAX_NODES];
 	bool promote = true;
 
-	sd_dprintf("mem:%zu, joined:%zu, left:%zu\n",
-		member_list_entries, joined_list_entries,
-		left_list_entries);
+	sd_dprintf("mem:%zu, joined:%zu, left:%zu", member_list_entries,
+		   joined_list_entries, left_list_entries);
 
 	/* check network partition */
 	if (left_list_entries) {
@@ -590,9 +589,9 @@ static void cdrv_cpg_confchg(cpg_handle_t handle,
 		}
 
 		if (member_list_entries == 0)
-			panic("NIC failure?\n");
+			panic("NIC failure?");
 		if (member_list_entries < nr_majority)
-			panic("Network partition is detected\n");
+			panic("Network partition is detected");
 	}
 
 	/* convert cpg_address to cpg_node */
@@ -653,7 +652,7 @@ static void cdrv_cpg_confchg(cpg_handle_t handle,
 					    &member_sheep[i]);
 			if (!cevent) {
 				sd_dprintf("Not promoting because member is "
-					"not in our event list.\n");
+					   "not in our event list.");
 				promote = false;
 				break;
 			}
@@ -680,14 +679,14 @@ retry:
 	case CS_OK:
 		break;
 	case CS_ERR_TRY_AGAIN:
-		sd_dprintf("failed to join the sheepdog group: retrying\n");
+		sd_dprintf("failed to join the sheepdog group: retrying");
 		sleep(1);
 		goto retry;
 	case CS_ERR_SECURITY:
-		sd_eprintf("permission denied to join the sheepdog group\n");
+		sd_eprintf("permission denied to join the sheepdog group");
 		return -1;
 	default:
-		sd_eprintf("failed to join the sheepdog group (%d)\n", ret);
+		sd_eprintf("failed to join the sheepdog group (%d)", ret);
 		return -1;
 	}
 
@@ -728,14 +727,13 @@ static void corosync_handler(int listen_fd, int events, void *data)
 	int ret;
 
 	if (events & EPOLLHUP) {
-		sd_eprintf("corosync driver received EPOLLHUP event,"	\
-			" exiting.\n");
+		sd_eprintf("corosync driver received EPOLLHUP event, exiting.");
 		goto out;
 	}
 
 	ret = cpg_dispatch(cpg_handle, CS_DISPATCH_ALL);
 	if (ret != CS_OK) {
-		sd_eprintf("cpg_dispatch returned %d\n", ret);
+		sd_eprintf("cpg_dispatch returned %d", ret);
 		goto out;
 	}
 
@@ -763,27 +761,27 @@ again:
 	case CS_ERR_TRY_AGAIN:
 		if (retry_cnt++ == CPG_INIT_RETRY_CNT) {
 			sd_eprintf("failed to initialize cpg (%d) - "
-				"is corosync running?\n", ret);
+				   "is corosync running?", ret);
 			return -1;
 		}
-		sd_dprintf("retry cpg_initialize\n");
+		sd_dprintf("retry cpg_initialize");
 		usleep(200000);
 		goto again;
 	default:
 		sd_eprintf("failed to initialize cpg (%d) - "
-			"is corosync running?\n", ret);
+			   "is corosync running?", ret);
 		return -1;
 	}
 
 	ret = corosync_cfg_initialize(&cfg_handle, NULL);
 	if (ret != CS_OK) {
-		sd_printf(SDOG_ERR, "failed to initialize cfg (%d)\n", ret);
+		sd_printf(SDOG_ERR, "failed to initialize cfg (%d)", ret);
 		return -1;
 	}
 
 	ret = corosync_cfg_local_get(cfg_handle, &nodeid);
 	if (ret != CS_OK) {
-		sd_printf(SDOG_ERR, "failed to get node id (%d)\n", ret);
+		sd_printf(SDOG_ERR, "failed to get node id (%d)", ret);
 		return -1;
 	}
 
@@ -792,14 +790,14 @@ again:
 
 	ret = cpg_fd_get(cpg_handle, &cpg_fd);
 	if (ret != CS_OK) {
-		sd_eprintf("failed to get cpg file descriptor (%d)\n", ret);
+		sd_eprintf("failed to get cpg file descriptor (%d)", ret);
 		return -1;
 	}
 
 	ret = register_event(cpg_fd, corosync_handler, NULL);
 	if (ret) {
-		sd_eprintf("failed to register corosync event handler (%d)\n",
-			ret);
+		sd_eprintf("failed to register corosync event handler (%d)",
+			   ret);
 		return -1;
 	}
 
diff --git a/sheep/cluster/local.c b/sheep/cluster/local.c
index b77158b..d1cb45f 100644
--- a/sheep/cluster/local.c
+++ b/sheep/cluster/local.c
@@ -179,7 +179,7 @@ static void shm_queue_notify(void)
 	nr = get_nodes(lnodes);
 
 	for (i = 0; i < nr; i++) {
-		sd_dprintf("send signal to %s\n", lnode_to_str(lnodes + i));
+		sd_dprintf("send signal to %s", lnode_to_str(lnodes + i));
 		kill(lnodes[i].pid, SIGUSR1);
 	}
 }
@@ -208,7 +208,7 @@ static void shm_queue_init(void)
 
 	shmfd = open(shmfile, O_CREAT | O_RDWR, 0644);
 	if (shmfd < 0)
-		panic("cannot open shared file, %s\n", shmfile);
+		panic("cannot open shared file, %s", shmfile);
 
 	shm_queue_lock();
 
@@ -244,7 +244,7 @@ static struct local_node *find_lnode(struct local_node *key, size_t nr_lnodes,
 		if (lnode_eq(key, lnodes + i))
 			return lnodes + i;
 
-	panic("internal error\n");
+	panic("internal error");
 }
 
 static void add_event(enum local_event_type type, struct local_node *lnode,
@@ -286,10 +286,9 @@ static void add_event(enum local_event_type type, struct local_node *lnode,
 		abort();
 	}
 
-	sd_dprintf("type = %d, sender = %s\n",
-		ev.type, lnode_to_str(&ev.sender));
+	sd_dprintf("type = %d, sender = %s", ev.type, lnode_to_str(&ev.sender));
 	for (i = 0; i < ev.nr_lnodes; i++)
-		sd_dprintf("%d: %s\n", i, lnode_to_str(ev.lnodes + i));
+		sd_dprintf("%d: %s", i, lnode_to_str(ev.lnodes + i));
 
 	shm_queue_push(&ev);
 
@@ -405,14 +404,14 @@ static bool local_process_event(void)
 	if (!ev)
 		return false;
 
-	sd_dprintf("type = %d, sender = %s\n",
-		ev->type, lnode_to_str(&ev->sender));
-	sd_dprintf("callbacked = %d, removed = %d\n",
-		ev->callbacked, ev->removed);
+	sd_dprintf("type = %d, sender = %s", ev->type,
+		   lnode_to_str(&ev->sender));
+	sd_dprintf("callbacked = %d, removed = %d", ev->callbacked,
+		   ev->removed);
 
 	nr_nodes = 0;
 	for (i = 0; i < ev->nr_lnodes; i++) {
-		sd_dprintf("%d: %s\n", i, lnode_to_str(ev->lnodes + i));
+		sd_dprintf("%d: %s", i, lnode_to_str(ev->lnodes + i));
 		if (!ev->lnodes[i].gateway)
 			nodes[nr_nodes++] = ev->lnodes[i].node;
 	}
@@ -425,7 +424,7 @@ static bool local_process_event(void)
 
 	if (ev->type == EVENT_JOIN_RESPONSE &&
 	    lnode_eq(&this_node, &ev->sender)) {
-		sd_dprintf("join Sheepdog\n");
+		sd_dprintf("join Sheepdog");
 		joined = true;
 	}
 
@@ -438,7 +437,7 @@ static bool local_process_event(void)
 
 			if (!lnode_eq(&this_node, &lnodes[0])) {
 				sd_dprintf("wait for another node"
-					" to accept this node\n");
+					   " to accept this node");
 				return false;
 			}
 		} else
@@ -456,7 +455,7 @@ static bool local_process_event(void)
 
 		if (res == CJ_RES_MASTER_TRANSFER) {
 			sd_eprintf("failed to join sheepdog cluster: "
-				"please retry when master is up\n");
+				   "please retry when master is up");
 			shm_queue_unlock();
 			exit(1);
 		}
@@ -499,12 +498,12 @@ static void local_handler(int listen_fd, int events, void *data)
 	int ret;
 
 	if (events & EPOLLHUP) {
-		sd_eprintf("local driver received EPOLLHUP event, exiting.\n");
+		sd_eprintf("local driver received EPOLLHUP event, exiting.");
 		log_close();
 		exit(1);
 	}
 
-	sd_dprintf("read siginfo\n");
+	sd_dprintf("read siginfo");
 
 	ret = read(sigfd, &siginfo, sizeof(siginfo));
 	assert(ret == sizeof(siginfo));
@@ -546,7 +545,7 @@ static int local_init(const char *option)
 
 	sigfd = signalfd(-1, &mask, SFD_NONBLOCK);
 	if (sigfd < 0) {
-		sd_eprintf("failed to create a signal fd: %m\n");
+		sd_eprintf("failed to create a signal fd: %m");
 		return -1;
 	}
 
@@ -554,8 +553,7 @@ static int local_init(const char *option)
 
 	ret = register_event(sigfd, local_handler, NULL);
 	if (ret) {
-		sd_eprintf("failed to register local event handler (%d)\n",
-			ret);
+		sd_eprintf("failed to register local event handler (%d)", ret);
 		return -1;
 	}
 
diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c
index 3b3c000..25152b3 100644
--- a/sheep/cluster/zookeeper.c
+++ b/sheep/cluster/zookeeper.c
@@ -141,7 +141,7 @@ static inline ZOOAPI int zk_delete_node(const char *path, int version)
 		rc = zoo_delete(zhandle, path, version);
 	} while (rc == ZOPERATIONTIMEOUT || rc == ZCONNECTIONLOSS);
 	if (rc != ZOK)
-		sd_eprintf("failed, path:%s, %s\n", path, zerror(rc));
+		sd_eprintf("failed, path:%s, %s", path, zerror(rc));
 	return rc;
 }
 
@@ -155,7 +155,7 @@ zk_init_node(const char *path)
 	} while (rc == ZOPERATIONTIMEOUT || rc == ZCONNECTIONLOSS);
 
 	if (rc != ZOK && rc != ZNODEEXISTS)
-		panic("failed, path:%s, %s\n", path, zerror(rc));
+		panic("failed, path:%s, %s", path, zerror(rc));
 }
 
 static inline ZOOAPI int
@@ -168,7 +168,7 @@ zk_create_node(const char *path, const char *value, int valuelen,
 		rc = zoo_create(zhandle, path, value, valuelen, acl,
 				flags, path_buffer, path_buffer_len);
 		if (rc != ZOK && rc != ZNODEEXISTS)
-			sd_eprintf("failed, path:%s, %s\n", path, zerror(rc));
+			sd_eprintf("failed, path:%s, %s", path, zerror(rc));
 	} while (rc == ZOPERATIONTIMEOUT || rc == ZCONNECTIONLOSS);
 	return rc;
 }
@@ -186,7 +186,7 @@ zk_create_seq_node(const char *path, const char *value, int valuelen,
 	rc = zoo_create(zhandle, path, value, valuelen, &ZOO_OPEN_ACL_UNSAFE,
 			ZOO_SEQUENCE, path_buffer, path_buffer_len);
 	if (rc != ZOK)
-		panic("failed, path:%s, %s\n", path, zerror(rc));
+		panic("failed, path:%s, %s", path, zerror(rc));
 }
 
 static inline ZOOAPI int zk_get_data(const char *path, void *buffer,
@@ -197,7 +197,7 @@ static inline ZOOAPI int zk_get_data(const char *path, void *buffer,
 		rc = zoo_get(zhandle, path, 1, (char *)buffer,
 			     buffer_len, NULL);
 		if (rc != ZOK)
-			sd_eprintf("failed, path:%s, %s\n", path, zerror(rc));
+			sd_eprintf("failed, path:%s, %s", path, zerror(rc));
 	} while (rc == ZOPERATIONTIMEOUT || rc == ZCONNECTIONLOSS);
 	return rc;
 }
@@ -210,7 +210,7 @@ zk_set_data(const char *path, const char *buffer, int buflen, int version)
 		rc = zoo_set(zhandle, path, buffer, buflen, version);
 	} while (rc == ZOPERATIONTIMEOUT || rc == ZCONNECTIONLOSS);
 	if (rc != ZOK)
-		panic("failed, path:%s, %s\n", path, zerror(rc));
+		panic("failed, path:%s, %s", path, zerror(rc));
 	return rc;
 }
 
@@ -220,7 +220,7 @@ static inline ZOOAPI int zk_node_exists(const char *path)
 	do {
 		rc = zoo_exists(zhandle, path, 1, NULL);
 		if (rc != ZOK && rc != ZNONODE)
-			sd_eprintf("failed, path:%s, %s\n", path, zerror(rc));
+			sd_eprintf("failed, path:%s, %s", path, zerror(rc));
 	} while (rc == ZOPERATIONTIMEOUT || rc == ZCONNECTIONLOSS);
 
 	return rc;
@@ -234,7 +234,7 @@ static inline ZOOAPI void zk_get_children(const char *path,
 		rc = zoo_get_children(zhandle, path, 1, strings);
 	} while (rc == ZOPERATIONTIMEOUT || rc == ZCONNECTIONLOSS);
 	if (rc != ZOK)
-		panic("failed, path:%s, %s\n", path, zerror(rc));
+		panic("failed, path:%s, %s", path, zerror(rc));
 }
 
 /* ZooKeeper-based queue give us an totally ordered events */
@@ -273,8 +273,8 @@ static void zk_queue_push(struct zk_event *ev)
 		first_push = false;
 	}
 
-	sd_dprintf("create path:%s, queue_pos:%010"PRId32", len:%d\n",
-		buf, queue_pos, len);
+	sd_dprintf("create path:%s, queue_pos:%010"PRId32", len:%d",
+		   buf, queue_pos, len);
 }
 
 static inline void *zk_event_sd_nodes(struct zk_event *ev)
@@ -297,8 +297,8 @@ static void push_join_response(struct zk_event *ev)
 	len = (char *)(ev->buf) - (char *)ev + ev->buf_len;
 	snprintf(path, sizeof(path), QUEUE_ZNODE "/%010"PRId32, queue_pos);
 	zk_set_data(path, (char *)ev, len, -1);
-	sd_dprintf("update path:%s, queue_pos:%010"PRId32", len:%d\n",
-		path, queue_pos, len);
+	sd_dprintf("update path:%s, queue_pos:%010"PRId32", len:%d",
+		   path, queue_pos, len);
 }
 
 static void zk_queue_pop_advance(struct zk_event *ev)
@@ -309,8 +309,8 @@ static void zk_queue_pop_advance(struct zk_event *ev)
 	len = sizeof(*ev);
 	snprintf(path, sizeof(path), QUEUE_ZNODE "/%010"PRId32, queue_pos);
 	assert(zk_get_data(path, ev, &len) == ZOK);
-	sd_dprintf("%s, type:%d, len:%d, pos:%"PRId32"\n",
-		path, ev->type, len, queue_pos);
+	sd_dprintf("%s, type:%d, len:%d, pos:%"PRId32, path, ev->type, len,
+		   queue_pos);
 	queue_pos++;
 }
 
@@ -377,7 +377,7 @@ static inline void build_node_list(void)
 		zk = rb_entry(n, struct zk_node, rb);
 		sd_nodes[nr_sd_nodes++] = zk->node;
 	}
-	sd_dprintf("nr_sd_nodes:%zu\n", nr_sd_nodes);
+	sd_dprintf("nr_sd_nodes:%zu", nr_sd_nodes);
 }
 
 static inline int zk_master_create(void)
@@ -438,7 +438,7 @@ static void zk_watcher(zhandle_t *zh, int type, int state, const char *path,
 	int ret;
 
 /* CREATED_EVENT 1, DELETED_EVENT 2, CHANGED_EVENT 3, CHILD_EVENT 4 */
-	sd_dprintf("path:%s, type:%d\n", path, type);
+	sd_dprintf("path:%s, type:%d", path, type);
 	if (type == ZOO_CREATED_EVENT || type == ZOO_CHANGED_EVENT) {
 		ret = sscanf(path, MEMBER_ZNODE "/%s", str);
 		if (ret == 1)
@@ -497,7 +497,7 @@ static int zk_join(const struct sd_node *myself,
 	snprintf(path, sizeof(path), MEMBER_ZNODE "/%s", node_to_str(myself));
 	rc = zk_node_exists(path);
 	if (rc == ZOK) {
-		sd_eprintf("Previous zookeeper session exist, shoot myself.\n");
+		sd_eprintf("Previous zookeeper session exist, shoot myself.");
 		exit(1);
 	}
 
@@ -532,7 +532,7 @@ static void zk_handle_join_request(struct zk_event *ev)
 {
 	enum cluster_join_result res;
 
-	sd_dprintf("sender: %s\n", node_to_str(&ev->sender.node));
+	sd_dprintf("sender: %s", node_to_str(&ev->sender.node));
 	if (!is_master()) {
 		/* Let's await master acking the join-request */
 		queue_pos--;
@@ -544,11 +544,11 @@ static void zk_handle_join_request(struct zk_event *ev)
 	push_join_response(ev);
 	if (res == CJ_RES_MASTER_TRANSFER) {
 		sd_eprintf("failed to join sheepdog cluster: "
-			"please retry when master is up\n");
+			   "please retry when master is up");
 		add_event(EVENT_LEAVE, &this_node, NULL, 0);
 		exit(1);
 	}
-	sd_dprintf("I'm the master now\n");
+	sd_dprintf("I'm the master now");
 }
 
 static void watch_all_nodes(void)
@@ -572,7 +572,7 @@ static void init_node_list(struct zk_event *ev)
 	size_t node_nr = ev->nr_nodes;
 	int i;
 
-	sd_dprintf("%zu\n", node_nr);
+	sd_dprintf("%zu", node_nr);
 	for (i = 0; i < node_nr; i++) {
 		struct zk_node zk;
 		mempcpy(&zk.node, p, sizeof(struct sd_node));
@@ -587,7 +587,7 @@ static void zk_handle_join_response(struct zk_event *ev)
 {
 	char path[MAX_NODE_STR_LEN];
 
-	sd_dprintf("JOIN RESPONSE\n");
+	sd_dprintf("JOIN RESPONSE");
 	if (node_eq(&ev->sender.node, &this_node.node))
 		/* newly joined node */
 		init_node_list(ev);
@@ -600,7 +600,7 @@ static void zk_handle_join_response(struct zk_event *ev)
 		 */
 		zk_tree_destroy();
 
-	sd_dprintf("%s, %d\n", node_to_str(&ev->sender.node), ev->join_result);
+	sd_dprintf("%s, %d", node_to_str(&ev->sender.node), ev->join_result);
 	switch (ev->join_result) {
 	case CJ_RES_SUCCESS:
 	case CJ_RES_JOIN_LATER:
@@ -608,7 +608,7 @@ static void zk_handle_join_response(struct zk_event *ev)
 		snprintf(path, sizeof(path), MEMBER_ZNODE"/%s",
 			 node_to_str(&ev->sender.node));
 		if (node_eq(&ev->sender.node, &this_node.node)) {
-			sd_dprintf("create path:%s\n", path);
+			sd_dprintf("create path:%s", path);
 			zk_create_node(path, (char *)&ev->sender,
 				       sizeof(ev->sender), &ZOO_OPEN_ACL_UNSAFE,
 				       ZOO_EPHEMERAL, NULL, 0);
@@ -654,8 +654,8 @@ static void zk_handle_leave(struct zk_event *ev)
 	struct zk_node *n = zk_tree_search(&ev->sender.node.nid);
 
 	if (!n) {
-		sd_dprintf("can't find this leave node:%s, ignore it.\n",
-			node_to_str(&ev->sender.node));
+		sd_dprintf("can't find this leave node:%s, ignore it.",
+			   node_to_str(&ev->sender.node));
 		return;
 	}
 	block_event_list_del(n);
@@ -668,7 +668,7 @@ static void zk_handle_block(struct zk_event *ev)
 {
 	struct zk_node *block = xzalloc(sizeof(*block));
 
-	sd_dprintf("BLOCK\n");
+	sd_dprintf("BLOCK");
 	block->node = ev->sender.node;
 	list_add_tail(&block->list, &zk_block_list);
 	block = list_first_entry(&zk_block_list, typeof(*block), list);
@@ -680,7 +680,7 @@ static void zk_handle_unblock(struct zk_event *ev)
 {
 	struct zk_node *block;
 
-	sd_dprintf("UNBLOCK\n");
+	sd_dprintf("UNBLOCK");
 	if (list_empty(&zk_block_list))
 		return;
 	block = list_first_entry(&zk_block_list, typeof(*block), list);
@@ -693,7 +693,7 @@ static void zk_handle_unblock(struct zk_event *ev)
 
 static void zk_handle_notify(struct zk_event *ev)
 {
-	sd_dprintf("NOTIFY\n");
+	sd_dprintf("NOTIFY");
 	sd_notify_handler(&ev->sender.node, ev->buf, ev->buf_len);
 }
 
@@ -713,16 +713,16 @@ static void zk_event_handler(int listen_fd, int events, void *data)
 	eventfd_t value;
 	struct zk_event ev;
 
-	sd_dprintf("%d, %d\n", events, queue_pos);
+	sd_dprintf("%d, %d", events, queue_pos);
 	if (events & EPOLLHUP) {
 		sd_eprintf("zookeeper driver received EPOLLHUP event,"
-			" exiting.\n");
+			   " exiting.");
 		log_close();
 		exit(1);
 	}
 
 	if (eventfd_read(efd, &value) < 0) {
-		sd_eprintf("%m\n");
+		sd_eprintf("%m");
 		return;
 	}
 
@@ -733,7 +733,7 @@ static void zk_event_handler(int listen_fd, int events, void *data)
 	if (ev.type < zk_max_event_handlers && zk_event_handlers[ev.type])
 		zk_event_handlers[ev.type](&ev);
 	else
-		panic("unhandled type %d\n", ev.type);
+		panic("unhandled type %d", ev.type);
 
 	 /* Someone has created next event, go kick event handler. */
 	if (zk_queue_peek()) {
@@ -759,25 +759,25 @@ static int zk_init(const char *option)
 	int ret, timeout = SESSION_TIMEOUT;
 
 	if (!option) {
-		sd_eprintf("You must specify zookeeper servers.\n");
+		sd_eprintf("You must specify zookeeper servers.");
 		return -1;
 	}
 
 	hosts = strtok((char *)option, "=");
 	if ((to = strtok(NULL, "="))) {
 		if (sscanf(to, "%u", &timeout) != 1) {
-			sd_eprintf("Invalid paramter for timeout\n");
+			sd_eprintf("Invalid paramter for timeout");
 			return -1;
 		}
 		p = strstr(hosts, "timeout");
 		*--p = '\0';
 	}
-	sd_dprintf("version %d.%d.%d, address %s, timeout %d\n",
-		ZOO_MAJOR_VERSION, ZOO_MINOR_VERSION, ZOO_PATCH_VERSION,
-		hosts, timeout);
+	sd_dprintf("version %d.%d.%d, address %s, timeout %d",
+		   ZOO_MAJOR_VERSION, ZOO_MINOR_VERSION, ZOO_PATCH_VERSION,
+		   hosts, timeout);
 	zhandle = zookeeper_init(hosts, zk_watcher, timeout, NULL, NULL, 0);
 	if (!zhandle) {
-		sd_eprintf("failed to connect to zk server %s\n", option);
+		sd_eprintf("failed to connect to zk server %s", option);
 		return -1;
 	}
 
@@ -785,14 +785,14 @@ static int zk_init(const char *option)
 
 	efd = eventfd(0, EFD_NONBLOCK);
 	if (efd < 0) {
-		sd_eprintf("failed to create an event fd: %m\n");
+		sd_eprintf("failed to create an event fd: %m");
 		return -1;
 	}
 
 	ret = register_event(efd, zk_event_handler, NULL);
 	if (ret) {
-		sd_eprintf("failed to register zookeeper event handler (%d)\n",
-			ret);
+		sd_eprintf("failed to register zookeeper event handler (%d)",
+			   ret);
 		return -1;
 	}
 
diff --git a/sheep/config.c b/sheep/config.c
index cebc4b4..63cfe87 100644
--- a/sheep/config.c
+++ b/sheep/config.c
@@ -40,19 +40,19 @@ static int write_config(void)
 
 	fd = open(config_path, O_DSYNC | O_WRONLY | O_CREAT, def_fmode);
 	if (fd < 0) {
-		sd_eprintf("failed to open config file, %m\n");
+		sd_eprintf("failed to open config file, %m");
 		return SD_RES_EIO;
 	}
 
 	jd = jrnl_begin(&config, sizeof(config), 0, config_path, jrnl_path);
 	if (!jd) {
-		sd_eprintf("failed to write config data to journal, %m\n");
+		sd_eprintf("failed to write config data to journal, %m");
 		ret = SD_RES_EIO;
 		goto out;
 	}
 	ret = xwrite(fd, &config, sizeof(config));
 	if (ret != sizeof(config)) {
-		sd_eprintf("failed to write config data, %m\n");
+		sd_eprintf("failed to write config data, %m");
 		ret = SD_RES_EIO;
 	} else
 		ret = SD_RES_SUCCESS;
@@ -74,7 +74,7 @@ int init_config_path(const char *base_path)
 	fd = open(config_path, O_RDONLY);
 	if (fd < 0) {
 		if (errno != ENOENT) {
-			sd_eprintf("failed to read config file, %m\n");
+			sd_eprintf("failed to read config file, %m");
 			return -1;
 		}
 		goto create;
@@ -86,13 +86,13 @@ int init_config_path(const char *base_path)
 		goto create;
 	}
 	if (ret < 0) {
-		sd_eprintf("failed to read config file, %m\n");
+		sd_eprintf("failed to read config file, %m");
 		goto out;
 	}
 
 	if (config.version != SD_FORMAT_VERSION) {
 		sd_eprintf("This sheep version is not compatible with"
-			" the existing data layout, %d\n", config.version);
+			   " the existing data layout, %d", config.version);
 		if (sys->upgrade) {
 			/* upgrade sheep store */
 			ret = sd_migrate_store(config.version, SD_FORMAT_VERSION);
@@ -101,7 +101,7 @@ int init_config_path(const char *base_path)
 				ret = xpread(fd, &config, sizeof(config), 0);
 				if (ret != sizeof(config)) {
 					sd_eprintf("failed to reload config"
-						" file, %m\n");
+						   " file, %m");
 					ret = -1;
 				} else
 					ret = 0;
@@ -109,7 +109,7 @@ int init_config_path(const char *base_path)
 			goto out;
 		}
 
-		sd_eprintf("use '-u' option to upgrade sheep store\n");
+		sd_eprintf("use '-u' option to upgrade sheep store");
 		ret = -1;
 		goto out;
 	}
diff --git a/sheep/farm/farm.c b/sheep/farm/farm.c
index 90178d3..91d4bc4 100644
--- a/sheep/farm/farm.c
+++ b/sheep/farm/farm.c
@@ -35,7 +35,7 @@ static int create_directory(const char *p)
 	strbuf_addstr(&buf, ".farm");
 	if (mkdir(buf.buf, 0755) < 0) {
 		if (errno != EEXIST) {
-			sd_eprintf("%m\n");
+			sd_eprintf("%m");
 			ret = -1;
 			goto err;
 		}
@@ -47,7 +47,7 @@ static int create_directory(const char *p)
 	strbuf_addstr(&buf, "/objects");
 	if (mkdir(buf.buf, 0755) < 0) {
 		if (errno != EEXIST) {
-			sd_eprintf("%m\n");
+			sd_eprintf("%m");
 			ret = -1;
 			goto err;
 		}
@@ -56,7 +56,7 @@ static int create_directory(const char *p)
 		strbuf_addf(&buf, "/%02x", i);
 		if (mkdir(buf.buf, 0755) < 0) {
 			if (errno != EEXIST) {
-				sd_eprintf("%m\n");
+				sd_eprintf("%m");
 				ret = -1;
 				goto err;
 			}
@@ -79,7 +79,7 @@ static int get_trunk_sha1(uint32_t epoch, unsigned char *outsha1)
 	struct sha1_file_hdr hdr;
 
 	log_free = log_buf = snap_log_read(&nr_logs);
-	sd_dprintf("%d\n", nr_logs);
+	sd_dprintf("%d", nr_logs);
 	if (nr_logs < 0)
 		goto out;
 
@@ -110,12 +110,12 @@ static bool is_xattr_enabled(const char *path)
 
 static int farm_init(const char *p)
 {
-	sd_dprintf("use farm store driver\n");
+	sd_dprintf("use farm store driver");
 	if (create_directory(p) < 0)
 		goto err;
 
 	if (!is_xattr_enabled(p)) {
-		sd_eprintf("xattrs are not enabled on %s\n", p);
+		sd_eprintf("xattrs are not enabled on %s", p);
 		goto err;
 	}
 
@@ -144,7 +144,7 @@ static int farm_snapshot(const struct siocb *iocb)
 		goto out;
 
 	epoch = log_nr + 1;
-	sd_dprintf("user epoch %d\n", epoch);
+	sd_dprintf("user epoch %d", epoch);
 
 	nr_nodes = epoch_log_read(sys->epoch, nodes, sizeof(nodes));
 	if (nr_nodes < 0)
@@ -171,7 +171,7 @@ static int cleanup_working_dir(void)
 	DIR *dir;
 	struct dirent *d;
 
-	sd_dprintf("try clean up working dir\n");
+	sd_dprintf("try clean up working dir");
 	dir = opendir(obj_path);
 	if (!dir)
 		return -1;
@@ -182,10 +182,10 @@ static int cleanup_working_dir(void)
 			continue;
 		snprintf(p, sizeof(p), "%s%s", obj_path, d->d_name);
 		if (unlink(p) < 0) {
-			sd_eprintf("%s:%m\n", p);
+			sd_eprintf("%s:%m", p);
 			continue;
 		}
-		sd_dprintf("remove file %s\n", d->d_name);
+		sd_dprintf("remove file %s", d->d_name);
 	}
 	closedir(dir);
 	return 0;
@@ -217,17 +217,17 @@ static int restore_objects_from_snap(uint32_t epoch)
 		oid = trunk_buf->oid;
 		buffer = sha1_file_read(trunk_buf->sha1, &h);
 		if (!buffer) {
-			sd_eprintf("oid %"PRIx64" not restored\n", oid);
+			sd_eprintf("oid %"PRIx64" not restored", oid);
 			goto out;
 		}
 		io.length = h.size;
 		io.buf = buffer;
 		ret = default_create_and_write(oid, &io);
 		if (ret != SD_RES_SUCCESS) {
-			sd_eprintf("oid %"PRIx64" not restored\n", oid);
+			sd_eprintf("oid %"PRIx64" not restored", oid);
 			goto out;
 		} else
-			sd_dprintf("oid %"PRIx64" restored\n", oid);
+			sd_dprintf("oid %"PRIx64" restored", oid);
 
 		free(buffer);
 	}
@@ -240,10 +240,10 @@ static int farm_restore(const struct siocb *iocb)
 {
 	int ret = SD_RES_EIO, epoch = iocb->epoch;
 
-	sd_dprintf("try recover user epoch %d\n", epoch);
+	sd_dprintf("try recover user epoch %d", epoch);
 
 	if (cleanup_working_dir() < 0) {
-		sd_eprintf("failed to clean up the working dir %m\n");
+		sd_eprintf("failed to clean up the working dir %m");
 		goto out;
 	}
 
@@ -261,7 +261,7 @@ static int farm_get_snap_file(struct siocb *iocb)
 	size_t size;
 	int nr;
 
-	sd_dprintf("try get snap file\n");
+	sd_dprintf("try get snap file");
 	buffer = snap_log_read(&nr);
 	if (!buffer)
 		goto out;
diff --git a/sheep/farm/sha1_file.c b/sheep/farm/sha1_file.c
index b12ecbd..3883d95 100644
--- a/sheep/farm/sha1_file.c
+++ b/sheep/farm/sha1_file.c
@@ -74,14 +74,14 @@ static void get_sha1_file(char *name)
 		if (errno == ENODATA) {
 			count = 1;
 			if (setxattr(name, CNAME, &count, CSIZE, 0) < 0)
-				panic("%m\n");
+				panic("%m");
 			return;
 		} else
-			panic("%m\n");
+			panic("%m");
 	}
 	count++;
 	if (setxattr(name, CNAME, &count, CSIZE, 0) < 0)
-			panic("%m\n");
+		panic("%m");
 }
 
 static int put_sha1_file(char *name)
@@ -90,23 +90,22 @@ static int put_sha1_file(char *name)
 
 	if (getxattr(name, CNAME, &count, CSIZE) < 0) {
 		if (errno == ENOENT) {
-			sd_dprintf("sha1 file doesn't exist\n");
+			sd_dprintf("sha1 file doesn't exist");
 			return -1;
-		} else {
-			panic("%m\n");
-		}
+		} else
+			panic("%m");
 	}
 
 	count--;
 	if (count == 0) {
 		if (unlink(name) < 0) {
-			sd_dprintf("%m\n");
+			sd_dprintf("%m");
 			return -1;
 		}
-		sd_dprintf("%s deleted\n", name);
+		sd_dprintf("%s deleted", name);
 	} else {
 		if (setxattr(name, CNAME, &count, CSIZE, 0) < 0)
-			panic("%m\n");
+			panic("%m");
 	}
 	return 0;
 }
@@ -124,7 +123,7 @@ static int sha1_buffer_write(const unsigned char *sha1, void *buf, unsigned int
 	}
 	len = xwrite(fd, buf, size);
 	if (len != size) {
-		sd_dprintf("%m\n");
+		sd_dprintf("%m");
 		close(fd);
 		return -1;
 	}
@@ -163,14 +162,14 @@ static void *map_sha1_file(const unsigned char *sha1, unsigned long *size)
 		return NULL;
 	}
 	if (fstat(fd, &st) < 0) {
-		sd_dprintf("%m\n");
+		sd_dprintf("%m");
 		close(fd);
 		return NULL;
 	}
 	map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
 	close(fd);
 	if (map == MAP_FAILED) {
-		sd_dprintf("%m\n");
+		sd_dprintf("%m");
 		return NULL;
 	}
 	*size = st.st_size;
@@ -186,7 +185,7 @@ static void *unpack_sha1_file(void *map, unsigned long mapsize, struct sha1_file
 	hdr_len = sizeof(*hdr);
 	buf = valloc(hdr->size);
 	if (!buf) {
-		sd_dprintf("%m\n");
+		sd_dprintf("%m");
 		return NULL;
 	}
 
@@ -204,8 +203,8 @@ static int verify_sha1_file(const unsigned char *sha1, void *buf, unsigned long
 	sha1_final(&c, tmp);
 
 	if (memcmp((char *)tmp, (char *)sha1, SHA1_LEN) != 0) {
-		sd_dprintf("failed, %s != %s\n", sha1_to_hex(sha1),
-			sha1_to_hex(tmp));
+		sd_dprintf("failed, %s != %s", sha1_to_hex(sha1),
+			   sha1_to_hex(tmp));
 		return -1;
 	}
 	return 0;
diff --git a/sheep/farm/snap.c b/sheep/farm/snap.c
index e88d77a..0cc18ba 100644
--- a/sheep/farm/snap.c
+++ b/sheep/farm/snap.c
@@ -57,7 +57,7 @@ int snap_log_write(uint32_t epoch, unsigned char *sha1)
 
 	fd = open(buf.buf, O_WRONLY | O_APPEND);
 	if (fd < 0) {
-		sd_dprintf("%m\n");
+		sd_dprintf("%m");
 		goto out;
 	}
 
@@ -85,11 +85,11 @@ void *snap_log_read(int *out_nr)
 
 	fd = open(buf.buf, O_RDONLY);
 	if (fd < 0) {
-		sd_dprintf("%m\n");
+		sd_dprintf("%m");
 		goto out;
 	}
 	if (fstat(fd, &st) < 0) {
-		sd_dprintf("%m\n");
+		sd_dprintf("%m");
 		goto out_close;
 	}
 
@@ -113,7 +113,7 @@ void *snap_file_read(unsigned char *sha1, struct sha1_file_hdr *outhdr)
 {
 	void *buffer = NULL;
 
-	sd_dprintf("%s\n", sha1_to_hex(sha1));
+	sd_dprintf("%s", sha1_to_hex(sha1));
 	buffer = sha1_file_read(sha1, outhdr);
 	if (!buffer)
 		return NULL;
@@ -145,8 +145,7 @@ int snap_file_write(uint32_t epoch, struct sd_node *nodes, int nr_nodes,
 		goto err;
 	}
 
-	sd_dprintf("epoch: %" PRIu32 ", sha1: %s\n", epoch,
-		sha1_to_hex(outsha1));
+	sd_dprintf("epoch: %" PRIu32 ", sha1: %s", epoch, sha1_to_hex(outsha1));
 err:
 	strbuf_release(&buf);
 	return ret;
diff --git a/sheep/farm/trunk.c b/sheep/farm/trunk.c
index e7d1502..0658511 100644
--- a/sheep/farm/trunk.c
+++ b/sheep/farm/trunk.c
@@ -41,12 +41,12 @@ static int fill_entry_new_sha1(struct trunk_entry *entry)
 	strbuf_reset(&buf);
 
 	if (fd < 0) {
-		sd_dprintf("%m\n");
+		sd_dprintf("%m");
 		ret = -1;
 		goto out;
 	}
 	if (!strbuf_read(&buf, fd, SD_DATA_OBJ_SIZE) == SD_DATA_OBJ_SIZE) {
-		sd_dprintf("strbuf_read fail to read full\n");
+		sd_dprintf("strbuf_read fail to read full");
 		ret = -1;
 		goto out_close;
 	}
@@ -57,8 +57,8 @@ static int fill_entry_new_sha1(struct trunk_entry *entry)
 		ret = -1;
 		goto out_close;
 	}
-	sd_dprintf("data sha1:%s, %"PRIx64"\n", sha1_to_hex(entry->sha1),
-		entry->oid);
+	sd_dprintf("data sha1:%s, %"PRIx64, sha1_to_hex(entry->sha1),
+		   entry->oid);
 out_close:
 	close(fd);
 out:
@@ -120,7 +120,7 @@ int trunk_file_write(unsigned char *outsha1)
 		ret = -1;
 		goto out;
 	}
-	sd_dprintf("trunk sha1: %s\n", sha1_to_hex(outsha1));
+	sd_dprintf("trunk sha1: %s", sha1_to_hex(outsha1));
 out:
 	closedir(dir);
 	strbuf_release(&buf);
@@ -131,7 +131,7 @@ void *trunk_file_read(unsigned char *sha1, struct sha1_file_hdr *outhdr)
 {
 	void *buffer;
 
-	sd_dprintf("%s\n", sha1_to_hex(sha1));
+	sd_dprintf("%s", sha1_to_hex(sha1));
 	buffer = sha1_file_read(sha1, outhdr);
 	if (!buffer)
 		return NULL;
diff --git a/sheep/gateway.c b/sheep/gateway.c
index 604be30..71f87e4 100644
--- a/sheep/gateway.c
+++ b/sheep/gateway.c
@@ -56,7 +56,7 @@ int gateway_read_obj(struct request *req)
 		if (ret == SD_RES_SUCCESS)
 			goto out;
 
-		sd_eprintf("local read fail %x\n", ret);
+		sd_eprintf("local read fail %x", ret);
 		break;
 	}
 
@@ -109,7 +109,7 @@ struct write_info {
 
 static inline void write_info_update(struct write_info *wi, int pos)
 {
-	sd_dprintf("%d, %d\n", wi->nr_sent, pos);
+	sd_dprintf("%d, %d", wi->nr_sent, pos);
 	wi->nr_sent--;
 	memmove(wi->ent + pos, wi->ent + pos + 1,
 		sizeof(struct write_info_entry) * (wi->nr_sent - pos));
@@ -161,9 +161,9 @@ again:
 		if (errno == EINTR)
 			goto again;
 
-		panic("%m\n");
+		panic("%m");
 	} else if (pollret == 0) {
-		sd_eprintf("poll timeout %d\n", wi->nr_sent);
+		sd_eprintf("poll timeout %d", wi->nr_sent);
 		/*
 		 * If IO NIC is down, epoch isn't incremented, so we can't retry
 		 * for ever.
@@ -187,7 +187,7 @@ again:
 			break;
 	if (i < nr_sent) {
 		int re = pi.pfds[i].revents;
-		sd_dprintf("%d, revents %x\n", i, re);
+		sd_dprintf("%d, revents %x", i, re);
 		if (re & (POLLERR | POLLHUP | POLLNVAL)) {
 			err_ret = SD_RES_NETWORK_ERROR;
 			finish_one_write_err(wi, i);
@@ -195,7 +195,7 @@ again:
 		}
 		if (do_read(pi.pfds[i].fd, rsp, sizeof(*rsp), sheep_need_retry,
 			    req->rq.epoch)) {
-			sd_eprintf("remote node might have gone away\n");
+			sd_eprintf("remote node might have gone away");
 			err_ret = SD_RES_NETWORK_ERROR;
 			finish_one_write_err(wi, i);
 			goto finish_write;
@@ -203,7 +203,7 @@ again:
 
 		ret = rsp->result;
 		if (ret != SD_RES_SUCCESS) {
-			sd_eprintf("fail %"PRIx32"\n", ret);
+			sd_eprintf("fail %"PRIx32, ret);
 			err_ret = ret;
 		}
 		finish_one_write(wi, i);
@@ -266,7 +266,7 @@ static int gateway_forward_request(struct request *req, bool all_node)
 	struct sd_req hdr;
 	const struct sd_node *target_nodes[SD_MAX_NODES];
 
-	sd_dprintf("%"PRIx64"\n", oid);
+	sd_dprintf("%"PRIx64, oid);
 
 	gateway_init_fwd_hdr(&hdr, &req->rq);
 	op = get_sd_op(hdr.opcode);
@@ -296,7 +296,7 @@ static int gateway_forward_request(struct request *req, bool all_node)
 		if (ret) {
 			sheep_del_sockfd(nid, sfd);
 			err_ret = SD_RES_NETWORK_ERROR;
-			sd_dprintf("fail %d\n", ret);
+			sd_dprintf("fail %d", ret);
 			break;
 		}
 		write_info_advance(&wi, nid, sfd);
@@ -307,12 +307,12 @@ static int gateway_forward_request(struct request *req, bool all_node)
 		ret = sheep_do_op_work(op, req);
 
 		if (ret != SD_RES_SUCCESS) {
-			sd_eprintf("fail to write local %"PRIx32"\n", ret);
+			sd_eprintf("fail to write local %"PRIx32, ret);
 			err_ret = ret;
 		}
 	}
 
-	sd_dprintf("nr_sent %d, err %x\n", wi.nr_sent, err_ret);
+	sd_dprintf("nr_sent %d, err %x", wi.nr_sent, err_ret);
 	if (wi.nr_sent > 0) {
 		ret = wait_forward_request(&wi, req);
 		if (ret != SD_RES_SUCCESS)
diff --git a/sheep/group.c b/sheep/group.c
index fab9918..1208028 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -95,8 +95,8 @@ bool have_enough_zones(void)
 
 	max_copies = get_max_copy_number();
 
-	sd_dprintf("flags %d, nr_zones %d, min copies %d\n",
-		sys->flags, current_vnode_info->nr_zones, max_copies);
+	sd_dprintf("flags %d, nr_zones %d, min copies %d",
+		   sys->flags, current_vnode_info->nr_zones, max_copies);
 
 	if (!current_vnode_info->nr_zones)
 		return false;
@@ -257,7 +257,7 @@ static void cluster_op_done(struct work *work)
 
 	cluster_op_running = false;
 
-	sd_dprintf("%s (%p)\n", op_name(req->op), req);
+	sd_dprintf("%s (%p)", op_name(req->op), req);
 
 	msg = prepare_cluster_msg(req, &size);
 	sys->cdrv->unblock(msg, size);
@@ -304,7 +304,7 @@ bool sd_block_handler(const struct sd_node *sender)
  */
 void queue_cluster_request(struct request *req)
 {
-	sd_dprintf("%s (%p)\n", op_name(req->op), req);
+	sd_dprintf("%s (%p)", op_name(req->op), req);
 
 	if (has_process_work(req->op)) {
 		list_add_tail(&req->pending_list, &sys->pending_block_list);
@@ -455,33 +455,31 @@ static int cluster_sanity_check(struct join_message *jm)
 	uint8_t local_nr_copies;
 
 	if (get_cluster_copies(&local_nr_copies)) {
-		sd_eprintf("failed to get nr_copies\n");
+		sd_eprintf("failed to get nr_copies");
 		return CJ_RES_FAIL;
 	}
 
 	if (jm->ctime != local_ctime) {
 		sd_eprintf("joining node ctime doesn't match: %"
-			PRIu64 " vs %" PRIu64 "\n",
-			jm->ctime, local_ctime);
+			   PRIu64 " vs %" PRIu64, jm->ctime, local_ctime);
 		return CJ_RES_FAIL;
 	}
 
 	if (jm->epoch > local_epoch) {
 		sd_eprintf("joining node epoch too large: %"
-			PRIu32 " vs %" PRIu32 "\n",
-			jm->epoch, local_epoch);
+			   PRIu32 " vs %" PRIu32, jm->epoch, local_epoch);
 		return CJ_RES_FAIL;
 	}
 
 	if (jm->nr_copies != local_nr_copies) {
-		sd_eprintf("joining node nr_copies doesn't match: %u vs %u\n",
-			jm->nr_copies, local_nr_copies);
+		sd_eprintf("joining node nr_copies doesn't match: %u vs %u",
+			   jm->nr_copies, local_nr_copies);
 		return CJ_RES_FAIL;
 	}
 
 	if (jm->cluster_flags != sys->flags) {
-		sd_eprintf("joining node cluster_flags don't match: %u vs %u\n",
-			jm->cluster_flags, sys->flags);
+		sd_eprintf("joining node cluster_flags don't match: %u vs %u",
+			   jm->cluster_flags, sys->flags);
 		return CJ_RES_FAIL;
 	}
 
@@ -502,8 +500,8 @@ static int cluster_wait_for_join_check(const struct sd_node *joined,
 	ret = cluster_sanity_check(jm);
 	if (ret != CJ_RES_SUCCESS)  {
 		if (jm->epoch > sys->epoch) {
-			sd_eprintf("transfer mastership (%d, %d)\n",
-				jm->epoch, sys->epoch);
+			sd_eprintf("transfer mastership (%d, %d)", jm->epoch,
+				   sys->epoch);
 			return CJ_RES_MASTER_TRANSFER;
 		}
 		return ret;
@@ -516,8 +514,7 @@ static int cluster_wait_for_join_check(const struct sd_node *joined,
 
 	if (jm->epoch < local_epoch) {
 		sd_eprintf("joining node epoch too small: %"
-			PRIu32 " vs %" PRIu32 "\n",
-			jm->epoch, local_epoch);
+			   PRIu32 " vs %" PRIu32, jm->epoch, local_epoch);
 
 		if (bsearch(joined, local_entries, nr_local_entries,
 			    sizeof(struct sd_node), node_id_cmp))
@@ -526,15 +523,15 @@ static int cluster_wait_for_join_check(const struct sd_node *joined,
 	}
 
 	if (jm->nr_nodes != nr_local_entries) {
-		sd_eprintf("epoch log entries do not match: %d vs %d\n",
-			jm->nr_nodes, nr_local_entries);
+		sd_eprintf("epoch log entries do not match: %d vs %d",
+			   jm->nr_nodes, nr_local_entries);
 		return CJ_RES_FAIL;
 	}
 
 
 	if (memcmp(jm->nodes, local_entries,
 		   sizeof(jm->nodes[0]) * jm->nr_nodes) != 0) {
-		sd_eprintf("epoch log entries does not match\n");
+		sd_eprintf("epoch log entries does not match");
 		return CJ_RES_FAIL;
 	}
 
@@ -698,11 +695,11 @@ static void finish_join(const struct join_message *msg,
 		sd_store = find_store_driver((char *)msg->store);
 		if (sd_store) {
 			if (sd_store->init(obj_path) != SD_RES_SUCCESS)
-				panic("failed to initialize store\n");
+				panic("failed to initialize store");
 			if (set_cluster_store(sd_store->name) != SD_RES_SUCCESS)
-				panic("failed to store into config file\n");
+				panic("failed to store into config file");
 		} else
-				panic("backend store %s not supported\n",
+				panic("backend store %s not supported",
 				      msg->store);
 	}
 
@@ -713,7 +710,7 @@ static void finish_join(const struct join_message *msg,
 		if (!sys->gateway_only &&
 		    sd_store->purge_obj &&
 		    sd_store->purge_obj() != SD_RES_SUCCESS)
-			panic("can't remove stale objects\n");
+			panic("can't remove stale objects");
 
 	sockfd_cache_add_group(nodes, nr_nodes);
 }
@@ -736,14 +733,14 @@ static void get_vdis(const struct sd_node *nodes, size_t nr_nodes)
 
 void wait_get_vdis_done(void)
 {
-	sd_dprintf("waiting for vdi list\n");
+	sd_dprintf("waiting for vdi list");
 
 	pthread_mutex_lock(&wait_vdis_lock);
 	while (!is_vdi_list_ready)
 		pthread_cond_wait(&wait_vdis_cond, &wait_vdis_lock);
 	pthread_mutex_unlock(&wait_vdis_lock);
 
-	sd_dprintf("vdi list ready\n");
+	sd_dprintf("vdi list ready");
 }
 
 void recalculate_vnodes(struct sd_node *nodes, int nr_nodes)
@@ -767,8 +764,9 @@ void recalculate_vnodes(struct sd_node *nodes, int nr_nodes)
 	for (i = 0; i < nr_nodes; i++) {
 		factor = (float)nodes[i].space / (float)avg_size;
 		nodes[i].nr_vnodes = rintf(SD_DEFAULT_VNODES * factor);
-		sd_dprintf("node %d has %d vnodes, free space %" PRIu64 "\n",
-			nodes[i].nid.port, nodes[i].nr_vnodes, nodes[i].space);
+		sd_dprintf("node %d has %d vnodes, free space %" PRIu64,
+			   nodes[i].nid.port, nodes[i].nr_vnodes,
+			   nodes[i].space);
 	}
 }
 
@@ -779,8 +777,8 @@ static void update_cluster_info(const struct join_message *msg,
 {
 	struct vnode_info *old_vnode_info;
 
-	sd_eprintf("status = %d, epoch = %d, finished: %d\n",
-		msg->cluster_status, msg->epoch, sys->join_finished);
+	sd_eprintf("status = %d, epoch = %d, finished: %d",
+		   msg->cluster_status, msg->epoch, sys->join_finished);
 
 	if (!sys->join_finished)
 		finish_join(msg, joined, nodes, nr_nodes);
@@ -850,8 +848,8 @@ void sd_notify_handler(const struct sd_node *sender, void *data,
 	int ret = msg->rsp.result;
 	struct request *req = NULL;
 
-	sd_dprintf("op %s, size: %zd, from: %s\n",
-		op_name(op), data_len, node_to_str(sender));
+	sd_dprintf("op %s, size: %zd, from: %s", op_name(op), data_len,
+		   node_to_str(sender));
 
 	if (node_is_local(sender)) {
 		if (has_process_work(op))
@@ -885,8 +883,7 @@ enum cluster_join_result sd_check_join_cb(const struct sd_node *joining,
 	int ret;
 
 	if (jm->proto_ver != SD_SHEEP_PROTO_VER) {
-		sd_eprintf("%s: invalid protocol version: %d\n", __func__,
-			jm->proto_ver);
+		sd_eprintf("invalid protocol version: %d", jm->proto_ver);
 		return CJ_RES_FAIL;
 	}
 
@@ -900,7 +897,7 @@ enum cluster_join_result sd_check_join_cb(const struct sd_node *joining,
 		 * becomes the master without sending JOIN.
 		 */
 
-		sd_printf(SDOG_DEBUG, "%s\n", node_to_str(&sys->this_node));
+		sd_printf(SDOG_DEBUG, "%s", node_to_str(&sys->this_node));
 
 		jm->cluster_status = sys->status;
 
@@ -909,8 +906,8 @@ enum cluster_join_result sd_check_join_cb(const struct sd_node *joining,
 			return CJ_RES_SUCCESS;
 
 		if (sys->status != SD_STATUS_WAIT_FOR_JOIN) {
-			sd_eprintf("unexpected cluster status 0x%x\n",
-				sys->status);
+			sd_eprintf("unexpected cluster status 0x%x",
+				   sys->status);
 			return CJ_RES_FAIL;
 		}
 
@@ -949,13 +946,13 @@ enum cluster_join_result sd_check_join_cb(const struct sd_node *joining,
 		ret = cluster_running_check(jm);
 		break;
 	default:
-		sd_eprintf("invalid system status: 0x%x\n", sys->status);
-		abort();
+		panic("invalid system status: 0x%x", sys->status);
 	}
 
-	sd_eprintf("%s: ret = 0x%x, cluster_status = 0x%x\n",
-		addr_to_str(str, sizeof(str), joining->nid.addr, joining->nid.port),
-		ret, jm->cluster_status);
+	sd_eprintf("%s: ret = 0x%x, cluster_status = 0x%x",
+		   addr_to_str(str, sizeof(str), joining->nid.addr,
+			       joining->nid.port),
+		   ret, jm->cluster_status);
 
 	jm->nr_copies = sys->nr_copies;
 	jm->cluster_flags = sys->flags;
@@ -995,7 +992,7 @@ static int send_join_request(struct sd_node *ent)
 
 	ret = sys->cdrv->join(ent, msg, get_join_message_size(msg));
 
-	sd_printf(SDOG_INFO, "%s\n", node_to_str(&sys->this_node));
+	sd_printf(SDOG_INFO, "%s", node_to_str(&sys->this_node));
 
 	free(msg);
 
@@ -1014,7 +1011,7 @@ void sd_join_handler(const struct sd_node *joined,
 
 	if (node_eq(joined, &sys->this_node)) {
 		if (result == CJ_RES_FAIL) {
-			sd_eprintf("Failed to join, exiting.\n");
+			sd_eprintf("Failed to join, exiting.");
 			sys->cdrv->leave();
 			exit(1);
 		}
@@ -1025,9 +1022,9 @@ void sd_join_handler(const struct sd_node *joined,
 		add_delayed_node(le, joined);
 		/*FALLTHRU*/
 	case CJ_RES_SUCCESS:
-		sd_dprintf("join %s\n", node_to_str(joined));
+		sd_dprintf("join %s", node_to_str(joined));
 		for (i = 0; i < nr_members; i++)
-			sd_dprintf("[%x] %s\n", i, node_to_str(members + i));
+			sd_dprintf("[%x] %s", i, node_to_str(members + i));
 
 		if (sys->status == SD_STATUS_SHUTDOWN)
 			break;
@@ -1036,7 +1033,7 @@ void sd_join_handler(const struct sd_node *joined,
 
 		if (node_eq(joined, &sys->this_node))
 			/* this output is used for testing */
-			sd_printf(SDOG_DEBUG, "join Sheepdog cluster\n");
+			sd_printf(SDOG_DEBUG, "join Sheepdog cluster");
 		break;
 	case CJ_RES_FAIL:
 		if (sys->status != SD_STATUS_WAIT_FOR_JOIN)
@@ -1050,7 +1047,7 @@ void sd_join_handler(const struct sd_node *joined,
 		nr_failed = get_nodes_nr_from(&sys->failed_nodes);
 		nr_delayed_nodes = get_nodes_nr_from(&sys->delayed_nodes);
 
-		sd_dprintf("%d == %d + %d\n", nr_local, nr, nr_failed);
+		sd_dprintf("%d == %d + %d", nr_local, nr, nr_failed);
 		if (nr_local == nr + nr_failed - nr_delayed_nodes) {
 			sys->status = SD_STATUS_OK;
 			log_current_epoch();
@@ -1075,7 +1072,7 @@ void sd_join_handler(const struct sd_node *joined,
 		nr_failed = get_nodes_nr_from(&sys->failed_nodes);
 		nr_delayed_nodes = get_nodes_nr_from(&sys->delayed_nodes);
 
-		sd_dprintf("%d == %d + %d\n", nr_local, nr, nr_failed);
+		sd_dprintf("%d == %d + %d", nr_local, nr, nr_failed);
 		if (nr_local == nr + nr_failed - nr_delayed_nodes) {
 			sys->status = SD_STATUS_OK;
 			log_current_epoch();
@@ -1083,11 +1080,11 @@ void sd_join_handler(const struct sd_node *joined,
 
 		if (node_eq(joined, &sys->this_node))
 			/* this output is used for testing */
-			sd_printf(SDOG_DEBUG, "join Sheepdog cluster\n");
+			sd_printf(SDOG_DEBUG, "join Sheepdog cluster");
 		break;
 	default:
 		/* this means sd_check_join_cb() is buggy */
-		panic("unknown cluster join result: %d\n", result);
+		panic("unknown cluster join result: %d", result);
 		break;
 	}
 }
@@ -1098,9 +1095,9 @@ void sd_leave_handler(const struct sd_node *left, const struct sd_node *members,
 	struct vnode_info *old_vnode_info;
 	int i;
 
-	sd_dprintf("leave %s\n", node_to_str(left));
+	sd_dprintf("leave %s", node_to_str(left));
 	for (i = 0; i < nr_members; i++)
-		sd_dprintf("[%x] %s\n", i, node_to_str(members + i));
+		sd_dprintf("[%x] %s", i, node_to_str(members + i));
 
 	if (sys->status == SD_STATUS_SHUTDOWN)
 		return;
@@ -1135,11 +1132,11 @@ int create_cluster(int port, int64_t zone, int nr_vnodes,
 	if (!sys->cdrv) {
 		sys->cdrv = find_cdrv("corosync");
 		if (sys->cdrv)
-			sd_dprintf("use corosync cluster driver as default\n");
+			sd_dprintf("use corosync cluster driver as default");
 		else {
 			/* corosync cluster driver is not compiled */
 			sys->cdrv = find_cdrv("local");
-			sd_dprintf("use local cluster driver as default\n");
+			sd_dprintf("use local cluster driver as default");
 		}
 	}
 
@@ -1164,7 +1161,7 @@ int create_cluster(int port, int64_t zone, int nr_vnodes,
 		sys->this_node.zone = b[0] | b[1] << 8 | b[2] << 16 | b[3] << 24;
 	} else
 		sys->this_node.zone = zone;
-	sd_dprintf("zone id = %u\n", sys->this_node.zone);
+	sd_dprintf("zone id = %u", sys->this_node.zone);
 
 	sys->this_node.space = sys->disk_space;
 
diff --git a/sheep/journal.c b/sheep/journal.c
index e9ec3b2..1f092e5 100644
--- a/sheep/journal.c
+++ b/sheep/journal.c
@@ -43,7 +43,7 @@ static int jrnl_open(struct jrnl_descriptor *jd, const char *path)
 	jd->fd = open(path, O_RDONLY);
 
 	if (jd->fd < 0) {
-		sd_eprintf("failed to open %s: %m\n", jd->path);
+		sd_eprintf("failed to open %s: %m", jd->path);
 		if (errno == ENOENT)
 			return SD_RES_NO_OBJ;
 		else
@@ -67,7 +67,7 @@ static int jrnl_create(struct jrnl_descriptor *jd, const char *jrnl_dir)
 	jd->fd = mkostemp(jd->path, O_DSYNC);
 
 	if (jd->fd < 0) {
-		sd_eprintf("failed to create %s: %m\n", jd->path);
+		sd_eprintf("failed to create %s: %m", jd->path);
 		return SD_RES_UNKNOWN;
 	}
 
@@ -80,7 +80,7 @@ static int jrnl_remove(struct jrnl_descriptor *jd)
 
 	ret = unlink(jd->path);
 	if (ret) {
-		sd_eprintf("failed to remove %s: %m\n", jd->path);
+		sd_eprintf("failed to remove %s: %m", jd->path);
 		ret = SD_RES_EIO;
 	} else
 		ret = SD_RES_SUCCESS;
@@ -227,12 +227,12 @@ int jrnl_recover(const char *jrnl_dir)
 	struct dirent *d;
 	char jrnl_file_path[PATH_MAX];
 
-	sd_eprintf("opening the directory %s\n", jrnl_dir);
+	sd_eprintf("opening the directory %s", jrnl_dir);
 	dir = opendir(jrnl_dir);
 	if (!dir)
 		return -1;
 
-	sd_printf(SDOG_NOTICE, "starting journal recovery\n");
+	sd_printf(SDOG_NOTICE, "starting journal recovery");
 	while ((d = readdir(dir))) {
 		struct jrnl_descriptor jd;
 		uint32_t end_mark = 0;
@@ -246,21 +246,21 @@ int jrnl_recover(const char *jrnl_dir)
 		ret = jrnl_open(&jd, jrnl_file_path);
 		if (ret) {
 			sd_eprintf("unable to open the journal file %s for"
-				" reading\n", jrnl_file_path);
+				   " reading", jrnl_file_path);
 			goto end_while_3;
 		}
 
 		ret = xpread(jd.fd, &jd.head, sizeof(jd.head), 0);
 		if (ret != sizeof(jd.head)) {
-			sd_eprintf("can't read journal head\n");
+			sd_eprintf("can't read journal head");
 			goto end_while_2;
 		}
 
 		ret = xpread(jd.fd, &end_mark, sizeof(end_mark),
 				sizeof(jd.head) + jd.head.size);
 		if (ret != sizeof(end_mark)) {
-			sd_eprintf("can't read journal end mark for object"
-				" %s\n", jd.head.target_path);
+			sd_eprintf("can't read journal end mark for object %s",
+				   jd.head.target_path);
 			goto end_while_2;
 		}
 
@@ -270,25 +270,25 @@ int jrnl_recover(const char *jrnl_dir)
 		jd.target_fd = open(jd.head.target_path, O_DSYNC | O_RDWR);
 		if (jd.target_fd < 0) {
 			sd_eprintf("unable to open the object file %s for"
-				" recovery\n", jd.head.target_path);
+				   " recovery", jd.head.target_path);
 			goto end_while_2;
 		}
 		ret = jrnl_apply_to_target_object(&jd);
 		if (ret)
-			sd_eprintf("unable to recover the object %s\n",
-				jd.head.target_path);
+			sd_eprintf("unable to recover the object %s",
+				   jd.head.target_path);
 
 		close(jd.target_fd);
 		jd.target_fd = -1;
 end_while_2:
 		jrnl_close(&jd);
 end_while_3:
-		sd_printf(SDOG_INFO, "recovered the object %s from"
-			" the journal\n", jrnl_file_path);
+		sd_printf(SDOG_INFO, "recovered the object %s from the journal",
+			  jrnl_file_path);
 		jrnl_remove(&jd);
 	}
 	closedir(dir);
-	sd_printf(SDOG_NOTICE, "journal recovery complete\n");
+	sd_printf(SDOG_NOTICE, "journal recovery complete");
 
 	return 0;
 }
diff --git a/sheep/journal_file.c b/sheep/journal_file.c
index f83af16..7d7773f 100644
--- a/sheep/journal_file.c
+++ b/sheep/journal_file.c
@@ -61,11 +61,11 @@ static int create_journal_file(const char *root, const char *name)
 	snprintf(path, sizeof(path), "%s/%s", root, name);
 	fd = open(path, flags, 0644);
 	if (fd < 0) {
-		sd_eprintf("open %s %m\n", name);
+		sd_eprintf("open %s %m", name);
 		return -1;
 	}
 	if (prealloc(fd, jfile_size) < 0) {
-		sd_eprintf("prealloc %s %m\n", name);
+		sd_eprintf("prealloc %s %m", name);
 		return -1;
 	}
 
@@ -86,19 +86,19 @@ static int get_old_new_jfile(const char *p, int *old, int *new)
 		if (errno == ENOENT)
 			return 0;
 
-		sd_eprintf("open1 %m\n");
+		sd_eprintf("open1 %m");
 		return -1;
 	}
 	snprintf(path, sizeof(path), "%s/%s", p, jfile_name[1]);
 	fd2 = open(path, flags);
 	if (fd2 < 0) {
-		sd_eprintf("open2 %m\n");
+		sd_eprintf("open2 %m");
 		close(fd1);
 		return -1;
 	}
 
 	if (fstat(fd1, &st1) < 0 || fstat(fd2, &st2) < 0) {
-		sd_eprintf("stat %m\n");
+		sd_eprintf("stat %m");
 		goto out;
 	}
 
@@ -136,15 +136,15 @@ static int replay_journal_entry(struct journal_descriptor *jd)
 	void *buf;
 	char *p = (char *)jd;
 
-	sd_dprintf("%"PRIx64", size %"PRIu64", off %"PRIu64", %d\n",
-		jd->oid, jd->size, jd->offset, jd->create);
+	sd_dprintf("%"PRIx64", size %"PRIu64", off %"PRIu64", %d", jd->oid,
+		   jd->size, jd->offset, jd->create);
 
 	if (jd->create)
 		flags |= O_CREAT;
 	snprintf(path, sizeof(path), "%s%016" PRIx64, obj_path, jd->oid);
 	fd = open(path, flags, def_fmode);
 	if (fd < 0) {
-		sd_eprintf("open %m\n");
+		sd_eprintf("open %m");
 		return -1;
 	}
 
@@ -158,7 +158,7 @@ static int replay_journal_entry(struct journal_descriptor *jd)
 	memcpy(buf, p, jd->size);
 	size = xpwrite(fd, buf, jd->size, jd->offset);
 	if (size != jd->size) {
-		sd_eprintf("write %zd, size %zu, errno %m\n", size, jd->size);
+		sd_eprintf("write %zd, size %zu, errno %m", size, jd->size);
 		ret = -1;
 		goto out;
 	}
@@ -175,14 +175,14 @@ static int do_recover(int fd)
 	struct stat st;
 
 	if (fstat(fd, &st) < 0) {
-		sd_eprintf("fstat %m\n");
+		sd_eprintf("fstat %m");
 		return -1;
 	}
 
 	map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
 	close(fd);
 	if (map == MAP_FAILED) {
-		sd_eprintf("%m\n");
+		sd_eprintf("%m");
 		return -1;
 	}
 
@@ -275,13 +275,13 @@ static void *commit_data(void *ignored)
 	/* Tell runtime to release resources after termination */
 	err = pthread_detach(pthread_self());
 	if (err)
-		panic("%s\n", strerror(err));
+		panic("%s", strerror(err));
 
 	sync();
 	if (ftruncate(jfile.commit_fd, 0) < 0)
-		panic("truncate %m\n");
+		panic("truncate %m");
 	if (prealloc(jfile.commit_fd, jfile_size) < 0)
-		panic("prealloc\n");
+		panic("prealloc");
 
 	uatomic_set_false(&jfile.in_commit);
 
@@ -297,7 +297,7 @@ static void switch_journal_file(void)
 retry:
 	if (!uatomic_set_true(&jfile.in_commit)) {
 		sd_eprintf("journal file in committing, "
-			"you might need enlarge jfile size\n");
+			   "you might need enlarge jfile size");
 		usleep(100000); /* Wait until committing is finished */
 		goto retry;
 	}
@@ -311,7 +311,7 @@ retry:
 
 	err = pthread_create(&thread, NULL, commit_data, NULL);
 	if (err)
-		panic("%s\n", strerror(err));
+		panic("%s", strerror(err));
 }
 
 int journal_file_write(uint64_t oid, const char *buf, size_t size,
@@ -349,7 +349,7 @@ int journal_file_write(uint64_t oid, const char *buf, size_t size,
 	}
 	memcpy(p, &marker, JOURNAL_MARKER_SIZE);
 
-	sd_dprintf("oid %lx, pos %zu, wsize %zu\n", oid, jfile.pos, wsize);
+	sd_dprintf("oid %lx, pos %zu, wsize %zu", oid, jfile.pos, wsize);
 	/*
 	 * Concurrent writes with the same FD is okay because we don't have any
 	 * critical sections that need lock inside kernel write path, since we
@@ -359,7 +359,7 @@ int journal_file_write(uint64_t oid, const char *buf, size_t size,
 	 */
 	written = xpwrite(jfile.fd, wbuffer, wsize, woff);
 	if (written != wsize) {
-		sd_eprintf("failed, written %zd, len %zu\n", written, wsize);
+		sd_eprintf("failed, written %zd, len %zu", written, wsize);
 		ret = err_to_sderr(oid, errno);
 		goto out;
 	}
diff --git a/sheep/migrate.c b/sheep/migrate.c
index a8a7617..35cb70b 100644
--- a/sheep/migrate.c
+++ b/sheep/migrate.c
@@ -73,7 +73,7 @@ static int backup_file(char *fname, char *suffix)
 	fd = open(fname, O_RDONLY);
 	if (fd < 0) {
 		if (errno != ENOENT) {
-			sd_eprintf("failed to open %s, %m\n", fname);
+			sd_eprintf("failed to open %s, %m", fname);
 			ret = -1;
 		} else
 			ret = 0;
@@ -82,7 +82,7 @@ static int backup_file(char *fname, char *suffix)
 
 	ret = stat(fname, &stbuf);
 	if (ret < 0) {
-		sd_eprintf("failed to stat %s, %m\n", fname);
+		sd_eprintf("failed to stat %s, %m", fname);
 		goto out;
 	}
 	len = stbuf.st_size;
@@ -90,7 +90,7 @@ static int backup_file(char *fname, char *suffix)
 	buf = xmalloc(len);
 	ret = xread(fd, buf, len);
 	if (ret != len) {
-		sd_eprintf("failed to read %s, %d %m\n", fname, ret);
+		sd_eprintf("failed to read %s, %d %m", fname, ret);
 		ret = -1;
 		goto out;
 	}
@@ -99,14 +99,14 @@ static int backup_file(char *fname, char *suffix)
 
 	fd = open(dst_file, O_CREAT | O_WRONLY | O_DSYNC, 0644);
 	if (fd < 0) {
-		sd_eprintf("failed to create %s, %m\n", dst_file);
+		sd_eprintf("failed to create %s, %m", dst_file);
 		ret = -1;
 		goto out;
 	}
 
 	ret = xwrite(fd, buf, len);
 	if (ret != len) {
-		sd_eprintf("failed to write to %s, %d %m\n", dst_file, ret);
+		sd_eprintf("failed to write to %s, %d %m", dst_file, ret);
 		ret = -1;
 	}
 out:
@@ -154,14 +154,14 @@ static int migrate_from_v0_to_v1(void)
 
 	fd = open(config_path, O_RDWR);
 	if (fd < 0) {
-		sd_eprintf("failed to open config file, %m\n");
+		sd_eprintf("failed to open config file, %m");
 		return -1;
 	}
 
 	memset(&config, 0, sizeof(config));
 	ret = xread(fd, &config, sizeof(config));
 	if (ret < 0) {
-		sd_eprintf("failed to read config file, %m\n");
+		sd_eprintf("failed to read config file, %m");
 		close(fd);
 		return ret;
 	}
@@ -169,7 +169,7 @@ static int migrate_from_v0_to_v1(void)
 	config.version = 1;
 	ret = xpwrite(fd, &config, sizeof(config), 0);
 	if (ret != sizeof(config)) {
-		sd_eprintf("failed to write config data, %m\n");
+		sd_eprintf("failed to write config data, %m");
 		close(fd);
 		return -1;
 	}
@@ -177,7 +177,7 @@ static int migrate_from_v0_to_v1(void)
 	/* 0.5.1 could wrongly extend the config file, so truncate it here */
 	ret = ftruncate(fd, sizeof(config));
 	if (ret != 0) {
-		sd_eprintf("failed to truncate config data, %m\n");
+		sd_eprintf("failed to truncate config data, %m");
 		close(fd);
 		return -1;
 	}
@@ -205,15 +205,13 @@ static int migrate_from_v0_to_v1(void)
 			if (errno == ENOENT)
 				continue;
 
-			sd_eprintf("failed to open epoch %"PRIu32" log\n",
-				epoch);
+			sd_eprintf("failed to open epoch %"PRIu32" log", epoch);
 			return -1;
 		}
 
 		ret = xread(fd, nodes_v0, sizeof(nodes_v0));
 		if (ret < 0) {
-			sd_eprintf("failed to read epoch %"PRIu32" log\n",
-				epoch);
+			sd_eprintf("failed to read epoch %"PRIu32" log", epoch);
 			close(fd);
 			return ret;
 		}
@@ -230,8 +228,8 @@ static int migrate_from_v0_to_v1(void)
 		len = sizeof(nodes_v1[0]) * nr_nodes;
 		ret = xpwrite(fd, nodes_v1, len, 0);
 		if (ret != len) {
-			sd_eprintf("failed to write epoch %"PRIu32" log\n",
-				epoch);
+			sd_eprintf("failed to write epoch %"PRIu32" log",
+				   epoch);
 			close(fd);
 			return -1;
 		}
@@ -241,7 +239,7 @@ static int migrate_from_v0_to_v1(void)
 		ret = xpwrite(fd, t, sizeof(*t), len);
 		if (ret != sizeof(*t)) {
 			sd_eprintf("failed to write time to epoch %"
-				PRIu32" log\n", epoch);
+				   PRIu32" log", epoch);
 			close(fd);
 			return -1;
 		}
@@ -264,7 +262,7 @@ int sd_migrate_store(int from, int to)
 
 	ret = backup_store();
 	if (ret != 0) {
-		sd_eprintf("failed to backup the old store\n");
+		sd_eprintf("failed to backup the old store");
 		return ret;
 	}
 
diff --git a/sheep/object_cache.c b/sheep/object_cache.c
index 3f2cd60..214ce1c 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -266,9 +266,9 @@ static int remove_cache_object(struct object_cache *oc, uint32_t idx)
 
 	snprintf(path, sizeof(path), "%s/%06"PRIx32"/%08"PRIx32,
 		 object_cache_dir, oc->vid, idx);
-	sd_dprintf("%"PRIx64"\n", idx_to_oid(oc->vid, idx));
+	sd_dprintf("%"PRIx64, idx_to_oid(oc->vid, idx));
 	if (unlink(path) < 0) {
-		sd_eprintf("failed to remove cached object %m\n");
+		sd_eprintf("failed to remove cached object %m");
 		if (errno == ENOENT)
 			return SD_RES_SUCCESS;
 		ret = SD_RES_EIO;
@@ -293,7 +293,7 @@ static int read_cache_object_noupdate(uint32_t vid, uint32_t idx, void *buf,
 
 	fd = open(p, flags, def_fmode);
 	if (fd < 0) {
-		sd_eprintf("%m\n");
+		sd_eprintf("%m");
 		ret = SD_RES_EIO;
 		goto out;
 	}
@@ -301,8 +301,8 @@ static int read_cache_object_noupdate(uint32_t vid, uint32_t idx, void *buf,
 	size = xpread(fd, buf, count, offset);
 
 	if (size != count) {
-		sd_eprintf("size %zu, count:%zu, offset %jd %m\n",
-			   size, count, (intmax_t)offset);
+		sd_eprintf("size %zu, count:%zu, offset %jd %m", size, count,
+			   (intmax_t)offset);
 		ret = SD_RES_EIO;
 		goto out_close;
 	}
@@ -327,7 +327,7 @@ static int write_cache_object_noupdate(uint32_t vid, uint32_t idx, void *buf,
 
 	fd = open(p, flags, def_fmode);
 	if (fd < 0) {
-		sd_eprintf("%m\n");
+		sd_eprintf("%m");
 		ret = SD_RES_EIO;
 		goto out;
 	}
@@ -335,8 +335,8 @@ static int write_cache_object_noupdate(uint32_t vid, uint32_t idx, void *buf,
 	size = xpwrite(fd, buf, count, offset);
 
 	if (size != count) {
-		sd_eprintf("size %zu, count:%zu, offset %jd %m\n",
-			   size, count, (intmax_t)offset);
+		sd_eprintf("size %zu, count:%zu, offset %jd %m", size, count,
+			   (intmax_t)offset);
 		ret = SD_RES_EIO;
 		goto out_close;
 	}
@@ -407,8 +407,7 @@ static int write_cache_object(struct object_cache_entry *entry, void *buf,
 
 	ret = exec_local_req(&hdr, buf);
 	if (ret != SD_RES_SUCCESS) {
-		sd_eprintf("failed to write object %" PRIx64 ", %x\n",
-			   oid, ret);
+		sd_eprintf("failed to write object %" PRIx64 ", %x", oid, ret);
 		return ret;
 	}
 out:
@@ -426,18 +425,18 @@ static int push_cache_object(uint32_t vid, uint32_t idx, uint64_t bmap,
 	uint64_t oid = idx_to_oid(vid, idx);
 	int first_bit, last_bit;
 
-	sd_dprintf("%"PRIx64", create %d\n", oid, create);
+	sd_dprintf("%"PRIx64", create %d", oid, create);
 
 	if (!bmap) {
-		sd_dprintf("WARN: nothing to flush\n");
+		sd_dprintf("WARN: nothing to flush");
 		return SD_RES_SUCCESS;
 	}
 
 	first_bit = ffsll(bmap) - 1;
 	last_bit = fls64(bmap) - 1;
 
-	sd_dprintf("bmap:0x%"PRIx64", first_bit:%d, last_bit:%d\n",
-		   bmap, first_bit, last_bit);
+	sd_dprintf("bmap:0x%"PRIx64", first_bit:%d, last_bit:%d", bmap,
+		   first_bit, last_bit);
 	offset = first_bit * CACHE_BLOCK_SIZE;
 	data_length = (last_bit - first_bit + 1) * CACHE_BLOCK_SIZE;
 
@@ -464,7 +463,7 @@ static int push_cache_object(uint32_t vid, uint32_t idx, uint64_t bmap,
 
 	ret = exec_local_req(&hdr, buf);
 	if (ret != SD_RES_SUCCESS)
-		sd_eprintf("failed to push object %x\n", ret);
+		sd_eprintf("failed to push object %x", ret);
 out:
 	free(buf);
 	return ret;
@@ -494,19 +493,18 @@ static void do_reclaim_object(struct object_cache *oc)
 	list_for_each_entry_safe(entry, t, &oc->lru_head, lru_list) {
 		oid = idx_to_oid(oc->vid, entry_idx(entry));
 		if (entry_in_use(entry)) {
-			sd_dprintf("%"PRIx64" is in use, skip...\n", oid);
+			sd_dprintf("%"PRIx64" is in use, skip...", oid);
 			continue;
 		}
 		if (entry_is_dirty(entry)) {
-			sd_dprintf("%"PRIx64" is dirty, skip...\n", oid);
+			sd_dprintf("%"PRIx64" is dirty, skip...", oid);
 			continue;
 		}
 		if (remove_cache_object(oc, entry_idx(entry)) != SD_RES_SUCCESS)
 			continue;
 		free_cache_entry(entry);
 		cap = uatomic_sub_return(&gcache.capacity, CACHE_OBJECT_SIZE);
-		sd_dprintf("%"PRIx64" reclaimed. capacity:%"PRId32"\n",
-			   oid, cap);
+		sd_dprintf("%"PRIx64" reclaimed. capacity:%"PRId32, oid, cap);
 		if (cap <= HIGH_WATERMARK)
 			break;
 	}
@@ -541,14 +539,13 @@ static void do_reclaim(struct work *work)
 			cap = uatomic_read(&gcache.capacity);
 			if (cap <= HIGH_WATERMARK) {
 				pthread_rwlock_unlock(&hashtable_lock[idx]);
-				sd_dprintf("complete, capacity %"PRIu32"\n",
-					   cap);
+				sd_dprintf("complete, capacity %"PRIu32, cap);
 				return;
 			}
 		}
 		pthread_rwlock_unlock(&hashtable_lock[idx]);
 	}
-	sd_dprintf("finished\n");
+	sd_dprintf("finished");
 }
 
 static void reclaim_done(struct work *work)
@@ -566,7 +563,7 @@ static int create_dir_for(uint32_t vid)
 	snprintf(p, sizeof(p), "%s/%06"PRIx32, object_cache_dir, vid);
 	if (mkdir(p, def_dmode) < 0)
 		if (errno != EEXIST) {
-			sd_eprintf("%s, %m\n", p);
+			sd_eprintf("%s, %m", p);
 			ret = -1;
 			goto err;
 		}
@@ -654,11 +651,11 @@ static void add_to_lru_cache(struct object_cache *oc, uint32_t idx, bool create)
 {
 	struct object_cache_entry *entry = alloc_cache_entry(oc, idx);
 
-	sd_dprintf("oid %"PRIx64" added\n", idx_to_oid(oc->vid, idx));
+	sd_dprintf("oid %"PRIx64" added", idx_to_oid(oc->vid, idx));
 
 	write_lock_cache(oc);
 	if (lru_tree_insert(&oc->lru_tree, entry))
-		panic("the object already exist\n");
+		panic("the object already exist");
 	uatomic_add(&gcache.capacity, CACHE_OBJECT_SIZE);
 	list_add_tail(&entry->lru_list, &oc->lru_head);
 	if (create) {
@@ -676,7 +673,7 @@ static inline int lookup_path(char *path)
 
 	if (access(path, R_OK | W_OK) < 0) {
 		if (errno != ENOENT) {
-			sd_dprintf("%m\n");
+			sd_dprintf("%m");
 			ret = SD_RES_EIO;
 		} else {
 			ret = SD_RES_NO_CACHE;
@@ -699,7 +696,7 @@ static int object_cache_lookup(struct object_cache *oc, uint32_t idx,
 	flags |= O_CREAT | O_TRUNC;
 	fd = open(path, flags, def_fmode);
 	if (fd < 0) {
-		sd_dprintf("%s, %m\n", path);
+		sd_dprintf("%s, %m", path);
 		ret = SD_RES_EIO;
 		goto out;
 	}
@@ -729,10 +726,10 @@ static int create_cache_object(struct object_cache *oc, uint32_t idx,
 	fd = open(tmp_path, flags, def_fmode);
 	if (fd < 0) {
 		if (errno == EEXIST) {
-			sd_dprintf("%08"PRIx32" already created\n", idx);
+			sd_dprintf("%08"PRIx32" already created", idx);
 			goto out;
 		}
-		sd_dprintf("%m\n");
+		sd_dprintf("%m");
 		ret = SD_RES_EIO;
 		goto out;
 	}
@@ -742,7 +739,7 @@ static int create_cache_object(struct object_cache *oc, uint32_t idx,
 		ret = prealloc(fd, obj_size);
 		if (ret < 0) {
 			ret = SD_RES_EIO;
-			sd_eprintf("%m\n");
+			sd_eprintf("%m");
 			goto out_close;
 		}
 	}
@@ -750,8 +747,7 @@ static int create_cache_object(struct object_cache *oc, uint32_t idx,
 	ret = xpwrite(fd, buffer, buf_size, offset);
 	if (ret != buf_size) {
 		ret = SD_RES_EIO;
-		sd_eprintf("failed, vid %"PRIx32", idx %"PRIx32"\n",
-			   oc->vid, idx);
+		sd_eprintf("failed, vid %"PRIx32", idx %"PRIx32, oc->vid, idx);
 		goto out_close;
 	}
 	/* This is intended to take care of partial write due to crash */
@@ -763,12 +759,12 @@ static int create_cache_object(struct object_cache *oc, uint32_t idx,
 			ret = SD_RES_OID_EXIST;
 			goto out_close;
 		}
-		sd_dprintf("failed to link %s to %s: %m\n", tmp_path, path);
+		sd_dprintf("failed to link %s to %s: %m", tmp_path, path);
 		ret = err_to_sderr(idx_to_oid(oc->vid, idx), errno);
 		goto out_close;
 	}
 	ret = SD_RES_SUCCESS;
-	sd_dprintf("%08"PRIx32" size %zu\n", idx, obj_size);
+	sd_dprintf("%08"PRIx32" size %zu", idx, obj_size);
 out_close:
 	close(fd);
 	unlink(tmp_path);
@@ -795,7 +791,7 @@ static int object_cache_pull(struct object_cache *oc, uint32_t idx)
 	if (ret != SD_RES_SUCCESS)
 		goto err;
 
-	sd_dprintf("oid %"PRIx64" pulled successfully\n", oid);
+	sd_dprintf("oid %"PRIx64" pulled successfully", oid);
 	ret = create_cache_object(oc, idx, buf, rsp->data_length,
 				  rsp->obj.offset, data_length);
 	/*
@@ -833,20 +829,20 @@ static void do_push_object(struct work *work)
 	struct object_cache *oc = entry->oc;
 	uint64_t oid = idx_to_oid(oc->vid, entry_idx(entry));
 
-	sd_dprintf("%"PRIx64"\n", oid);
+	sd_dprintf("%"PRIx64, oid);
 
 	read_lock_entry(entry);
 	if (push_cache_object(oc->vid, entry_idx(entry), entry->bmap,
 			      !!(entry->idx & CACHE_CREATE_BIT))
 	    != SD_RES_SUCCESS)
-		panic("push failed but should never fail\n");
+		panic("push failed but should never fail");
 	if (uatomic_sub_return(&oc->push_count, 1) == 0)
 		eventfd_write(oc->push_efd, 1);
 	entry->idx &= ~CACHE_CREATE_BIT;
 	entry->bmap = 0;
 	unlock_entry(entry);
 
-	sd_dprintf("%"PRIx64" done\n", oid);
+	sd_dprintf("%"PRIx64" done", oid);
 	put_cache_entry(entry);
 }
 
@@ -890,10 +886,10 @@ static int object_cache_push(struct object_cache *oc)
 	unlock_cache(oc);
 reread:
 	if (eventfd_read(oc->push_efd, &value) < 0) {
-		sd_eprintf("eventfd read failed, %m\n");
+		sd_eprintf("eventfd read failed, %m");
 		goto reread;
 	}
-	sd_dprintf("%"PRIx32" completed\n", oc->vid);
+	sd_dprintf("%"PRIx32" completed", oc->vid);
 	return SD_RES_SUCCESS;
 }
 
@@ -968,11 +964,11 @@ static int object_cache_flush_and_delete(struct object_cache *oc)
 	int ret = 0;
 	char p[PATH_MAX];
 
-	sd_dprintf("%"PRIx32"\n", vid);
+	sd_dprintf("%"PRIx32, vid);
 	snprintf(p, sizeof(p), "%s/%06"PRIx32, object_cache_dir, vid);
 	dir = opendir(p);
 	if (!dir) {
-		sd_dprintf("%m\n");
+		sd_dprintf("%m");
 		ret = -1;
 		goto out;
 	}
@@ -981,9 +977,9 @@ static int object_cache_flush_and_delete(struct object_cache *oc)
 		if (!strncmp(d->d_name, ".", 1))
 			continue;
 		if (strcmp(d->d_name + 8, ".tmp") == 0) {
-			sd_dprintf("try to del %s\n", d->d_name);
+			sd_dprintf("try to del %s", d->d_name);
 			if (unlinkat(dirfd(dir), d->d_name, 0) < 0)
-				sd_eprintf("%m\n");
+				sd_eprintf("%m");
 			continue;
 		}
 
@@ -992,7 +988,7 @@ static int object_cache_flush_and_delete(struct object_cache *oc)
 			continue;
 		if (push_cache_object(vid, idx, all, true) !=
 		    SD_RES_SUCCESS) {
-			sd_dprintf("failed to push %"PRIx64"\n",
+			sd_dprintf("failed to push %"PRIx64,
 				   idx_to_oid(vid, idx));
 			ret = -1;
 			goto out_close_dir;
@@ -1054,7 +1050,7 @@ int object_cache_handle_request(struct request *req)
 	int ret;
 	bool create = false;
 
-	sd_dprintf("%08"PRIx32", len %"PRIu32", off %"PRIu64"\n", idx,
+	sd_dprintf("%08"PRIx32", len %"PRIu32", off %"PRIu64, idx,
 		   hdr->data_length, hdr->obj.offset);
 
 	cache = find_object_cache(vid, true);
@@ -1076,7 +1072,7 @@ retry:
 
 	entry = get_cache_entry_from(cache, idx);
 	if (!entry) {
-		sd_dprintf("retry oid %"PRIx64"\n", oid);
+		sd_dprintf("retry oid %"PRIx64, oid);
 		/*
 		 * For the case that object exists but isn't added to object
 		 * list yet, we call pthread_yield() to expect other thread can
@@ -1113,11 +1109,11 @@ int object_cache_write(uint64_t oid, char *data, unsigned int datalen,
 	struct object_cache_entry *entry;
 	int ret;
 
-	sd_dprintf("%" PRIx64 "\n", oid);
+	sd_dprintf("%" PRIx64, oid);
 	cache = find_object_cache(vid, false);
 	entry = get_cache_entry_from(cache, idx);
 	if (!entry) {
-		sd_dprintf("%" PRIx64 " doesn't exist\n", oid);
+		sd_dprintf("%" PRIx64 " doesn't exist", oid);
 		return SD_RES_NO_CACHE;
 	}
 
@@ -1135,11 +1131,11 @@ int object_cache_read(uint64_t oid, char *data, unsigned int datalen,
 	struct object_cache_entry *entry;
 	int ret;
 
-	sd_dprintf("%" PRIx64 "\n", oid);
+	sd_dprintf("%" PRIx64, oid);
 	cache = find_object_cache(vid, false);
 	entry = get_cache_entry_from(cache, idx);
 	if (!entry) {
-		sd_dprintf("%" PRIx64 " doesn't exist\n", oid);
+		sd_dprintf("%" PRIx64 " doesn't exist", oid);
 		return SD_RES_NO_CACHE;
 	}
 
@@ -1154,7 +1150,7 @@ int object_cache_flush_vdi(uint32_t vid)
 
 	cache = find_object_cache(vid, false);
 	if (!cache) {
-		sd_dprintf("%"PRIx32" not found\n", vid);
+		sd_dprintf("%"PRIx32" not found", vid);
 		return SD_RES_SUCCESS;
 	}
 
@@ -1186,7 +1182,7 @@ static int load_cache_object(struct object_cache *cache)
 		 cache->vid);
 	dir = opendir(path);
 	if (!dir) {
-		sd_dprintf("%m\n");
+		sd_dprintf("%m");
 		ret = -1;
 		goto out;
 	}
@@ -1196,9 +1192,9 @@ static int load_cache_object(struct object_cache *cache)
 			continue;
 
 		if (strcmp(d->d_name + 8, ".tmp") == 0) {
-			sd_dprintf("try to del %s\n", d->d_name);
+			sd_dprintf("try to del %s", d->d_name);
 			if (unlinkat(dirfd(dir), d->d_name, 0) < 0)
-				sd_eprintf("%m\n");
+				sd_eprintf("%m");
 			continue;
 		}
 
@@ -1213,7 +1209,7 @@ static int load_cache_object(struct object_cache *cache)
 		 * cluster isn't fully working.
 		 */
 		add_to_lru_cache(cache, idx, true);
-		sd_dprintf("%"PRIx64"\n", idx_to_oid(cache->vid, idx));
+		sd_dprintf("%"PRIx64, idx_to_oid(cache->vid, idx));
 	}
 
 	closedir(dir);
@@ -1232,7 +1228,7 @@ static int load_cache(void)
 	snprintf(path, sizeof(path), "%s", object_cache_dir);
 	dir = opendir(path);
 	if (!dir) {
-		sd_dprintf("%m\n");
+		sd_dprintf("%m");
 		ret = -1;
 		goto out;
 	}
@@ -1260,7 +1256,7 @@ int object_cache_init(const char *p)
 	strbuf_addstr(&buf, p);
 	if (mkdir(buf.buf, def_dmode) < 0) {
 		if (errno != EEXIST) {
-			sd_eprintf("%s %m\n", buf.buf);
+			sd_eprintf("%s %m", buf.buf);
 			ret = -1;
 			goto err;
 		}
@@ -1268,7 +1264,7 @@ int object_cache_init(const char *p)
 	strbuf_addstr(&buf, "/cache");
 	if (mkdir(buf.buf, def_dmode) < 0) {
 		if (errno != EEXIST) {
-			sd_eprintf("%s %m\n", buf.buf);
+			sd_eprintf("%s %m", buf.buf);
 			ret = -1;
 			goto err;
 		}
diff --git a/sheep/object_list_cache.c b/sheep/object_list_cache.c
index 20093f3..e3bfe3c 100644
--- a/sheep/object_list_cache.c
+++ b/sheep/object_list_cache.c
@@ -157,7 +157,7 @@ int get_obj_list(const struct sd_list_req *hdr, struct sd_list_rsp *rsp, void *d
 out:
 	if (hdr->data_length < obj_list_cache.cache_size * sizeof(uint64_t)) {
 		pthread_rwlock_unlock(&obj_list_cache.lock);
-		sd_eprintf("GET_OBJ_LIST buffer too small\n");
+		sd_eprintf("GET_OBJ_LIST buffer too small");
 		return SD_RES_BUFFER_SMALL;
 	}
 
@@ -182,7 +182,7 @@ static void objlist_deletion_work(struct work *work)
 	 */
 	if (vdi_exist(vid)) {
 		sd_eprintf("VDI (%" PRIx32 ") is still in use, can not be"
-			" deleted\n", vid);
+			" deleted", vid);
 		return;
 	}
 
@@ -191,7 +191,7 @@ static void objlist_deletion_work(struct work *work)
 		entry_vid = oid_to_vid(entry->oid);
 		if (entry_vid != vid)
 			continue;
-		sd_dprintf("delete object entry %" PRIx64 "\n", entry->oid);
+		sd_dprintf("delete object entry %" PRIx64, entry->oid);
 		list_del(&entry->list);
 		rb_erase(&entry->node, &obj_list_cache.root);
 		free(entry);
diff --git a/sheep/ops.c b/sheep/ops.c
index c1940c8..de2fab8 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -136,7 +136,7 @@ static int post_cluster_new_vdi(const struct sd_req *req, struct sd_rsp *rsp,
 	unsigned long nr = rsp->vdi.vdi_id;
 	int ret = rsp->result;
 
-	sd_dprintf("done %d %ld\n", ret, nr);
+	sd_dprintf("done %d %ld", ret, nr);
 	if (ret == SD_RES_SUCCESS)
 		set_bit(nr, sys->vdi_inuse);
 
@@ -231,18 +231,18 @@ static int remove_epoch(uint32_t epoch)
 	int ret;
 	char path[PATH_MAX];
 
-	sd_dprintf("remove epoch %"PRIu32"\n", epoch);
+	sd_dprintf("remove epoch %"PRIu32, epoch);
 	snprintf(path, sizeof(path), "%s%08u", epoch_path, epoch);
 	ret = unlink(path);
 	if (ret && ret != -ENOENT) {
-		sd_eprintf("failed to remove %s: %s\n", path, strerror(-ret));
+		sd_eprintf("failed to remove %s: %s", path, strerror(-ret));
 		return SD_RES_EIO;
 	}
 
 	snprintf(path, sizeof(path), "%s%08u/", jrnl_path, epoch);
 	ret = rmdir_r(path);
 	if (ret && ret != -ENOENT) {
-		sd_eprintf("failed to remove %s: %s\n", path, strerror(-ret));
+		sd_eprintf("failed to remove %s: %s", path, strerror(-ret));
 		return SD_RES_EIO;
 	}
 	return 0;
@@ -365,7 +365,7 @@ static int local_release_vdi(struct request *req)
 
 	if (!vid) {
 		sd_iprintf("Some VDI failed to release the object cache. "
-			   "Probably you are running old QEMU.\n");
+			   "Probably you are running old QEMU.");
 		return SD_RES_SUCCESS;
 	}
 
@@ -478,7 +478,7 @@ static int local_get_epoch(struct request *req)
 	uint32_t epoch = req->rq.obj.tgt_epoch;
 	int nr_nodes;
 
-	sd_dprintf("%d\n", epoch);
+	sd_dprintf("%d", epoch);
 
 	nr_nodes = epoch_log_read(epoch, req->data, req->rq.data_length);
 	if (nr_nodes == -1)
@@ -516,7 +516,7 @@ static int cluster_force_recover(const struct sd_req *req, struct sd_rsp *rsp,
 
 	old_vnode_info = get_vnode_info_epoch(sys->epoch);
 	if (!old_vnode_info) {
-		sd_eprintf("cannot get vnode info for epoch %d\n", sys->epoch);
+		sd_eprintf("cannot get vnode info for epoch %d", sys->epoch);
 		return SD_RES_EIO;
 	}
 
@@ -620,7 +620,7 @@ static int cluster_recovery_completion(const struct sd_req *req,
 		return SD_RES_SUCCESS;
 
 	if (latest_epoch < epoch) {
-		sd_dprintf("new epoch %d\n", epoch);
+		sd_dprintf("new epoch %d", epoch);
 		latest_epoch = epoch;
 		nr_recovereds = 0;
 	}
@@ -628,9 +628,9 @@ static int cluster_recovery_completion(const struct sd_req *req,
 	recovereds[nr_recovereds++] = *(struct sd_node *)node;
 	qsort(recovereds, nr_recovereds, sizeof(*recovereds), node_id_cmp);
 
-	sd_dprintf("%s is recovered at epoch %d\n", node_to_str(node), epoch);
+	sd_dprintf("%s is recovered at epoch %d", node_to_str(node), epoch);
 	for (i = 0; i < nr_recovereds; i++)
-		sd_dprintf("[%x] %s\n", i, node_to_str(recovereds + i));
+		sd_dprintf("[%x] %s", i, node_to_str(recovereds + i));
 
 	if (sys->epoch != latest_epoch)
 		return SD_RES_SUCCESS;
@@ -640,7 +640,7 @@ static int cluster_recovery_completion(const struct sd_req *req,
 	if (vnode_info->nr_nodes == nr_recovereds &&
 	    memcmp(vnode_info->nodes, recovereds,
 		   sizeof(*recovereds) * nr_recovereds) == 0) {
-		sd_dprintf("all nodes are recovered at epoch %d\n", epoch);
+		sd_dprintf("all nodes are recovered at epoch %d", epoch);
 		if (sd_store->cleanup)
 			sd_store->cleanup();
 	}
@@ -656,7 +656,7 @@ static int local_set_cache_size(const struct sd_req *req, struct sd_rsp *rsp,
 	uint32_t cache_size = *(uint32_t *)data;
 
 	uatomic_set(&sys->object_cache_size, cache_size);
-	sd_dprintf("Max cache size set to %dM\n", cache_size);
+	sd_dprintf("Max cache size set to %dM", cache_size);
 
 	object_cache_try_to_reclaim(0);
 
@@ -742,7 +742,7 @@ static int local_trace_read_buf(struct request *request)
 		return SD_RES_AGAIN;
 
 	rsp->data_length = ret;
-	sd_dprintf("%u\n", rsp->data_length);
+	sd_dprintf("%u", rsp->data_length);
 	return SD_RES_SUCCESS;
 }
 
@@ -867,14 +867,14 @@ int peer_create_and_write_obj(struct request *req)
 	iocb.flags = hdr->flags;
 	iocb.length = get_objsize(oid);
 	if (hdr->flags & SD_FLAG_CMD_COW) {
-		sd_dprintf("%" PRIx64 ", %" PRIx64 "\n", oid, hdr->obj.cow_oid);
+		sd_dprintf("%" PRIx64 ", %" PRIx64, oid, hdr->obj.cow_oid);
 
 		buf = xvalloc(SD_DATA_OBJ_SIZE);
 		if (hdr->data_length != SD_DATA_OBJ_SIZE) {
 			ret = read_copy_from_replica(req, hdr->epoch,
 						     hdr->obj.cow_oid, buf);
 			if (ret != SD_RES_SUCCESS) {
-				sd_eprintf("failed to read cow object\n");
+				sd_eprintf("failed to read cow object");
 				goto out;
 			}
 		}
@@ -1248,15 +1248,15 @@ void do_process_work(struct work *work)
 	struct request *req = container_of(work, struct request, work);
 	int ret = SD_RES_SUCCESS;
 
-	sd_dprintf("%x, %" PRIx64", %"PRIu32"\n",
-		req->rq.opcode, req->rq.obj.oid, req->rq.epoch);
+	sd_dprintf("%x, %" PRIx64", %"PRIu32, req->rq.opcode, req->rq.obj.oid,
+		   req->rq.epoch);
 
 	if (req->op->process_work)
 		ret = req->op->process_work(req);
 
 	if (ret != SD_RES_SUCCESS) {
-		sd_dprintf("failed: %x, %" PRIx64" , %u, %"PRIx32"\n",
-			req->rq.opcode, req->rq.obj.oid, req->rq.epoch, ret);
+		sd_dprintf("failed: %x, %" PRIx64" , %u, %"PRIx32,
+			   req->rq.opcode, req->rq.obj.oid, req->rq.epoch, ret);
 	}
 
 	req->rp.result = ret;
diff --git a/sheep/plain_store.c b/sheep/plain_store.c
index 53dea60..3ef22eb 100644
--- a/sheep/plain_store.c
+++ b/sheep/plain_store.c
@@ -70,7 +70,7 @@ int for_each_object_in_wd(int (*func)(uint64_t oid, void *arg), bool cleanup,
 
 	dir = opendir(obj_path);
 	if (!dir) {
-		sd_eprintf("failed to open %s, %m\n", obj_path);
+		sd_eprintf("failed to open %s, %m", obj_path);
 		return SD_RES_EIO;
 	}
 
@@ -87,7 +87,7 @@ int for_each_object_in_wd(int (*func)(uint64_t oid, void *arg), bool cleanup,
 		    strcmp(d->d_name + 16, ".tmp") == 0) {
 			if (cleanup) {
 				get_tmp_obj_path(oid, path);
-				sd_dprintf("remove tmp object %s\n", path);
+				sd_dprintf("remove tmp object %s", path);
 				unlink(path);
 			}
 			continue;
@@ -108,8 +108,7 @@ bool default_exist(uint64_t oid)
 	get_obj_path(oid, path);
 	if (access(path, R_OK | W_OK) < 0) {
 		if (errno != ENOENT)
-			sd_eprintf("failed to check object %"PRIx64", %m\n",
-				oid);
+			sd_eprintf("failed to check object %"PRIx64", %m", oid);
 		return false;
 	}
 
@@ -123,17 +122,17 @@ int err_to_sderr(uint64_t oid, int err)
 	switch (err) {
 	case ENOENT:
 		if (stat(obj_path, &s) < 0) {
-			sd_eprintf("corrupted\n");
+			sd_eprintf("corrupted");
 			return SD_RES_EIO;
 		}
-		sd_dprintf("object %016" PRIx64 " not found locally\n", oid);
+		sd_dprintf("object %016" PRIx64 " not found locally", oid);
 		return SD_RES_NO_OBJ;
 	case ENOSPC:
 		/* TODO: stop automatic recovery */
-		sd_eprintf("diskfull, oid=%"PRIx64"\n", oid);
+		sd_eprintf("diskfull, oid=%"PRIx64, oid);
 		return SD_RES_NO_SPACE;
 	default:
-		sd_eprintf("oid=%"PRIx64", %m\n", oid);
+		sd_eprintf("oid=%"PRIx64", %m", oid);
 		return SD_RES_EIO;
 	}
 }
@@ -146,8 +145,7 @@ int default_write(uint64_t oid, const struct siocb *iocb)
 	ssize_t size;
 
 	if (iocb->epoch < sys_epoch()) {
-		sd_dprintf("%"PRIu32" sys %"PRIu32"\n",
-			iocb->epoch, sys_epoch());
+		sd_dprintf("%"PRIu32" sys %"PRIu32, iocb->epoch, sys_epoch());
 		return SD_RES_OLD_NODE_VER;
 	}
 
@@ -157,7 +155,7 @@ int default_write(uint64_t oid, const struct siocb *iocb)
 	    journal_file_write(oid, iocb->buf, iocb->length, iocb->offset,
 			       false)
 	    != SD_RES_SUCCESS) {
-		sd_eprintf("turn off journaling\n");
+		sd_eprintf("turn off journaling");
 		uatomic_set_false(&sys->use_journal);
 		flags |= O_DSYNC;
 		sync();
@@ -170,7 +168,7 @@ int default_write(uint64_t oid, const struct siocb *iocb)
 	size = xpwrite(fd, iocb->buf, iocb->length, iocb->offset);
 	if (size != iocb->length) {
 		sd_eprintf("failed to write object %"PRIx64", path=%s, offset=%"
-			PRId64", size=%"PRId32", result=%zd, %m\n", oid, path,
+			PRId64", size=%"PRId32", result=%zd, %m", oid, path,
 			iocb->offset, iocb->length, size);
 		ret = err_to_sderr(oid, errno);
 		goto out;
@@ -184,7 +182,7 @@ int default_cleanup(void)
 {
 	rmdir_r(stale_dir);
 	if (mkdir(stale_dir, 0755) < 0) {
-		sd_eprintf("%m\n");
+		sd_eprintf("%m");
 		return SD_RES_EIO;
 	}
 
@@ -201,14 +199,14 @@ static int init_vdi_copy_number(uint64_t oid)
 
 	fd = open(path, flags);
 	if (fd < 0) {
-		sd_eprintf("failed to open %s, %m\n", path);
+		sd_eprintf("failed to open %s, %m", path);
 		ret = SD_RES_EIO;
 		goto out;
 	}
 
 	ret = xpread(fd, inode, SD_INODE_HEADER_SIZE, 0);
 	if (ret != SD_INODE_HEADER_SIZE) {
-		sd_eprintf("failed to read inode header, path=%s, %m\n", path);
+		sd_eprintf("failed to read inode header, path=%s, %m", path);
 		ret = SD_RES_EIO;
 		goto out;
 	}
@@ -227,7 +225,7 @@ static int init_objlist_and_vdi_bitmap(uint64_t oid, void *arg)
 	objlist_cache_insert(oid);
 
 	if (is_vdi_obj(oid)) {
-		sd_dprintf("found the VDI object %" PRIx64 "\n", oid);
+		sd_dprintf("found the VDI object %" PRIx64, oid);
 		set_bit(oid_to_vid(oid), sys->vdi_inuse);
 		ret = init_vdi_copy_number(oid);
 		if (ret != SD_RES_SUCCESS)
@@ -238,13 +236,13 @@ static int init_objlist_and_vdi_bitmap(uint64_t oid, void *arg)
 
 int default_init(const char *p)
 {
-	sd_dprintf("use plain store driver\n");
+	sd_dprintf("use plain store driver");
 
 	/* create a stale directory */
 	snprintf(stale_dir, sizeof(stale_dir), "%s/.stale", p);
 	if (mkdir(stale_dir, 0755) < 0) {
 		if (errno != EEXIST) {
-			sd_eprintf("%m\n");
+			sd_eprintf("%m");
 			return SD_RES_EIO;
 		}
 	}
@@ -267,7 +265,7 @@ static int default_read_from_path(uint64_t oid, const char *path,
 	size = xpread(fd, iocb->buf, iocb->length, iocb->offset);
 	if (size != iocb->length) {
 		sd_eprintf("failed to read object %"PRIx64", path=%s, offset=%"
-			PRId64", size=%"PRId32", result=%zd, %m\n", oid, path,
+			PRId64", size=%"PRId32", result=%zd, %m", oid, path,
 			iocb->offset, iocb->length, size);
 		ret = err_to_sderr(oid, errno);
 	}
@@ -305,7 +303,7 @@ int prealloc(int fd, uint32_t size)
 	int ret = fallocate(fd, 0, 0, size);
 	if (ret < 0) {
 		if (errno != ENOSYS && errno != EOPNOTSUPP) {
-			sd_eprintf("failed to preallocate space, %m\n");
+			sd_eprintf("failed to preallocate space, %m");
 			return ret;
 		}
 
@@ -328,7 +326,7 @@ int default_create_and_write(uint64_t oid, const struct siocb *iocb)
 	if (uatomic_is_true(&sys->use_journal) &&
 	    journal_file_write(oid, iocb->buf, iocb->length, iocb->offset, true)
 	    != SD_RES_SUCCESS) {
-		sd_eprintf("turn off journaling\n");
+		sd_eprintf("turn off journaling");
 		uatomic_set_false(&sys->use_journal);
 		flags |= O_DSYNC;
 		sync();
@@ -342,11 +340,11 @@ int default_create_and_write(uint64_t oid, const struct siocb *iocb)
 			 * recovery process could also recover the object at the
 			 * same time.  They should try to write the same date,
 			 * so it is okay to simply return success here. */
-			sd_dprintf("%s exists\n", tmp_path);
+			sd_dprintf("%s exists", tmp_path);
 			return SD_RES_SUCCESS;
 		}
 
-		sd_eprintf("failed to open %s: %m\n", tmp_path);
+		sd_eprintf("failed to open %s: %m", tmp_path);
 		return err_to_sderr(oid, errno);
 	}
 
@@ -360,18 +358,18 @@ int default_create_and_write(uint64_t oid, const struct siocb *iocb)
 
 	ret = xpwrite(fd, iocb->buf, len, iocb->offset);
 	if (ret != len) {
-		sd_eprintf("failed to write object. %m\n");
+		sd_eprintf("failed to write object. %m");
 		ret = err_to_sderr(oid, errno);
 		goto out;
 	}
 
 	ret = rename(tmp_path, path);
 	if (ret < 0) {
-		sd_eprintf("failed to rename %s to %s: %m\n", tmp_path, path);
+		sd_eprintf("failed to rename %s to %s: %m", tmp_path, path);
 		ret = err_to_sderr(oid, errno);
 		goto out;
 	}
-	sd_dprintf("%"PRIx64"\n", oid);
+	sd_dprintf("%"PRIx64, oid);
 	ret = SD_RES_SUCCESS;
 out:
 	if (ret != SD_RES_SUCCESS)
@@ -384,15 +382,15 @@ int default_link(uint64_t oid, uint32_t tgt_epoch)
 {
 	char path[PATH_MAX], stale_path[PATH_MAX];
 
-	sd_dprintf("try link %"PRIx64" from snapshot with epoch %d\n", oid,
-		tgt_epoch);
+	sd_dprintf("try link %"PRIx64" from snapshot with epoch %d", oid,
+		   tgt_epoch);
 
 	get_obj_path(oid, path);
 	get_stale_obj_path(oid, tgt_epoch, stale_path);
 
 	if (link(stale_path, path) < 0) {
-		sd_eprintf("failed to link from %s to %s, %m\n", stale_path,
-			path);
+		sd_eprintf("failed to link from %s to %s, %m", stale_path,
+			   path);
 		return err_to_sderr(oid, errno);
 	}
 
@@ -437,12 +435,12 @@ static int move_object_to_stale_dir(uint64_t oid, void *arg)
 	get_stale_obj_path(oid, tgt_epoch, stale_path);
 
 	if (rename(path, stale_path) < 0) {
-		sd_eprintf("failed to move stale object %"PRIX64" to %s, %m\n",
-			oid, path);
+		sd_eprintf("failed to move stale object %"PRIX64" to %s, %m",
+			   oid, path);
 		return SD_RES_EIO;
 	}
 
-	sd_dprintf("moved object %"PRIx64"\n", oid);
+	sd_dprintf("moved object %"PRIx64, oid);
 	return SD_RES_SUCCESS;
 }
 
@@ -467,15 +465,14 @@ int default_format(void)
 {
 	unsigned ret;
 
-	sd_dprintf("try get a clean store\n");
+	sd_dprintf("try get a clean store");
 	ret = rmdir_r(obj_path);
 	if (ret && ret != -ENOENT) {
-		sd_eprintf("failed to remove %s: %s\n",
-			obj_path, strerror(-ret));
+		sd_eprintf("failed to remove %s: %s", obj_path, strerror(-ret));
 		return SD_RES_EIO;
 	}
 	if (mkdir(obj_path, def_dmode) < 0) {
-		sd_eprintf("%m\n");
+		sd_eprintf("%m");
 		return SD_RES_EIO;
 	}
 	if (is_object_cache_enabled())
@@ -494,7 +491,7 @@ int default_remove_object(uint64_t oid)
 		if (errno == ENOENT)
 			return SD_RES_NO_OBJ;
 
-		sd_eprintf("failed to remove object %"PRIx64", %m\n", oid);
+		sd_eprintf("failed to remove object %"PRIx64", %m", oid);
 		return SD_RES_EIO;
 	}
 
@@ -522,13 +519,12 @@ int default_flush(void)
 
 	fd = open(obj_path, O_RDONLY);
 	if (fd < 0) {
-		sd_eprintf("error at open() %s, %s\n",
-			obj_path, strerror(errno));
+		sd_eprintf("error at open() %s, %m", obj_path);
 		return SD_RES_NO_OBJ;
 	}
 
 	if (syncfs(fd)) {
-		sd_eprintf("error at syncfs(), %s\n", strerror(errno));
+		sd_eprintf("error at syncfs(), %m");
 		ret = SD_RES_EIO;
 	}
 
diff --git a/sheep/recovery.c b/sheep/recovery.c
index f30bd72..54966fe 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -82,7 +82,7 @@ static int recover_object_from_replica(uint64_t oid,
 	rlen = get_objsize(oid);
 	buf = valloc(rlen);
 	if (!buf) {
-		sd_eprintf("%m\n");
+		sd_eprintf("%m");
 		goto out;
 	}
 
@@ -103,7 +103,7 @@ static int recover_object_from_replica(uint64_t oid,
 	ret = sd_store->create_and_write(oid, &iocb);
 out:
 	if (ret == SD_RES_SUCCESS) {
-		sd_dprintf("recovered oid %"PRIx64" from %d to epoch %d\n", oid,
+		sd_dprintf("recovered oid %"PRIx64" from %d to epoch %d", oid,
 			tgt_epoch, epoch);
 		objlist_cache_insert(oid);
 	}
@@ -139,8 +139,8 @@ static int do_recover_object(struct recovery_work *rw)
 	old = grab_vnode_info(rw->old_vinfo);
 
 again:
-	sd_dprintf("try recover object %"PRIx64" from epoch %"PRIu32"\n",
-		oid, tgt_epoch);
+	sd_dprintf("try recover object %"PRIx64" from epoch %"PRIu32, oid,
+		   tgt_epoch);
 
 	/* Let's do a breadth-first search */
 	nr_copies = get_obj_copy_number(oid, old->nr_zones);
@@ -171,7 +171,7 @@ again:
 rollback:
 		tgt_epoch--;
 		if (tgt_epoch < 1) {
-			sd_eprintf("can not recover oid %"PRIx64"\n", oid);
+			sd_eprintf("can not recover oid %"PRIx64, oid);
 			ret = -1;
 			goto err;
 		}
@@ -197,17 +197,17 @@ static void recover_object_work(struct work *work)
 	uint64_t oid = rw->oids[rw->done];
 	int ret;
 
-	sd_eprintf("done:%"PRIu32" count:%"PRIu32", oid:%"PRIx64"\n",
-		rw->done, rw->count, oid);
+	sd_eprintf("done:%"PRIu32" count:%"PRIu32", oid:%"PRIx64, rw->done,
+		   rw->count, oid);
 
 	if (sd_store->exist(oid)) {
-		sd_dprintf("the object is already recovered\n");
+		sd_dprintf("the object is already recovered");
 		return;
 	}
 
 	ret = do_recover_object(rw);
 	if (ret < 0)
-		sd_eprintf("failed to recover object %"PRIx64"\n", oid);
+		sd_eprintf("failed to recover object %"PRIx64, oid);
 }
 
 bool node_in_recovery(void)
@@ -236,8 +236,8 @@ static inline void prepare_schedule_oid(uint64_t oid)
 	 */
 	for (i = 0; i < rw->done; i++)
 		if (rw->oids[i] == oid) {
-			sd_dprintf("%"PRIx64" not recovered, don't"
-				" schedule it\n", oid);
+			sd_dprintf("%"PRIx64" not recovered, don't schedule it",
+				   oid);
 			return;
 		}
 	/* When auto recovery is enabled, the oid is currently being
@@ -250,7 +250,7 @@ static inline void prepare_schedule_oid(uint64_t oid)
 	rw->prio_oids[rw->nr_prio_oids - 1] = oid;
 	resume_suspended_recovery();
 
-	sd_dprintf("%"PRIx64" nr_prio_oids %d\n", oid, rw->nr_prio_oids);
+	sd_dprintf("%"PRIx64" nr_prio_oids %d", oid, rw->nr_prio_oids);
 }
 
 bool oid_in_recovery(uint64_t oid)
@@ -262,7 +262,7 @@ bool oid_in_recovery(uint64_t oid)
 		return false;
 
 	if (sd_store->exist(oid)) {
-		sd_dprintf("the object %" PRIx64 " is already recoverd\n", oid);
+		sd_dprintf("the object %" PRIx64 " is already recoverd", oid);
 		return false;
 	}
 
@@ -287,7 +287,7 @@ bool oid_in_recovery(uint64_t oid)
 	 * in the list
 	 */
 	if (i == rw->count) {
-		sd_eprintf("%"PRIx64" is not in the recovery list\n", oid);
+		sd_eprintf("%"PRIx64" is not in the recovery list", oid);
 		return false;
 	}
 
@@ -311,7 +311,7 @@ static inline void run_next_rw(struct recovery_work *rw)
 	recovering_work = rw;
 	flush_wait_obj_requests();
 	queue_work(sys->recovery_wqueue, &rw->work);
-	sd_dprintf("recovery work is superseded\n");
+	sd_dprintf("recovery work is superseded");
 }
 
 static void notify_recovery_completion_work(struct work *work)
@@ -328,8 +328,8 @@ static void notify_recovery_completion_work(struct work *work)
 
 	ret = exec_local_req(&hdr, &sys->this_node);
 	if (ret != SD_RES_SUCCESS)
-		sd_eprintf("failed to notify recovery completion, %d\n",
-			rw->epoch);
+		sd_eprintf("failed to notify recovery completion, %d",
+			   rw->epoch);
 }
 
 static void notify_recovery_completion_main(struct work *work)
@@ -352,8 +352,8 @@ static inline void finish_recovery(struct recovery_work *rw)
 	rw->work.done = notify_recovery_completion_main;
 	queue_work(sys->recovery_wqueue, &rw->work);
 
-	sd_dprintf("recovery complete: new epoch %"PRIu32"\n",
-		sys->recovered_epoch);
+	sd_dprintf("recovery complete: new epoch %"PRIu32,
+		   sys->recovered_epoch);
 }
 
 static inline bool oid_in_prio_oids(struct recovery_work *rw, uint64_t oid)
@@ -395,9 +395,9 @@ static inline void finish_schedule_oids(struct recovery_work *rw)
 		new_oids[new_idx++] = rw->oids[i];
 	}
 	/* rw->count should eq new_idx, otherwise something is wrong */
-	sd_dprintf("%snr_recovered %d, nr_prio_oids %d, count %d = new %d\n",
-		rw->count == new_idx ? "" : "WARN: ", nr_recovered,
-		rw->nr_prio_oids, rw->count, new_idx);
+	sd_dprintf("%snr_recovered %d, nr_prio_oids %d, count %d = new %d",
+		   rw->count == new_idx ? "" : "WARN: ", nr_recovered,
+		   rw->nr_prio_oids, rw->count, new_idx);
 
 	free(rw->oids);
 	rw->oids = new_oids;
@@ -431,7 +431,7 @@ static void recover_next_object(struct recovery_work *rw)
 		finish_schedule_oids(rw);
 
 	if (sys->disable_recovery && !has_scheduled_objects(rw)) {
-		sd_dprintf("suspended\n");
+		sd_dprintf("suspended");
 		rw->suspended = true;
 		/* suspend until resume_suspended_recovery() is called */
 		return;
@@ -465,7 +465,7 @@ static void recover_object_main(struct work *work)
 		 * requests
 		 */
 		flush_wait_obj_requests();
-		sd_dprintf("recovery is stopped\n");
+		sd_dprintf("recovery is stopped");
 		return;
 	}
 
@@ -517,7 +517,7 @@ static uint64_t *fetch_object_list(struct sd_node *e, uint32_t epoch,
 	int ret;
 
 	addr_to_str(name, sizeof(name), e->nid.addr, 0);
-	sd_dprintf("%s %"PRIu32"\n", name, e->nid.port);
+	sd_dprintf("%s %"PRIu32, name, e->nid.port);
 
 retry:
 	sd_init_req((struct sd_req *)&hdr, SD_OP_GET_OBJ_LIST);
@@ -539,7 +539,7 @@ retry:
 	}
 
 	*nr_oids = rsp->data_length / sizeof(uint64_t);
-	sd_dprintf("%zu\n", *nr_oids);
+	sd_dprintf("%zu", *nr_oids);
 	return buf;
 }
 
@@ -556,7 +556,7 @@ static void screen_object_list(struct recovery_work *rw,
 		nr_objs = get_obj_copy_number(oids[i], rw->cur_vinfo->nr_zones);
 		if (!nr_objs) {
 			sd_eprintf("ERROR: can not find copy number for object"
-				" %" PRIx64 "\n", oids[i]);
+				   " %" PRIx64, oids[i]);
 			continue;
 		}
 		oid_to_vnodes(rw->cur_vinfo->vnodes, rw->cur_vinfo->nr_vnodes,
@@ -599,7 +599,7 @@ static void prepare_object_list(struct work *work)
 	int start = random() % cur_nr, i, end = cur_nr;
 	uint64_t *oids;
 
-	sd_dprintf("%u\n", rw->epoch);
+	sd_dprintf("%u", rw->epoch);
 	wait_get_vdis_done();
 again:
 	/* We need to start at random node for better load balance */
@@ -608,7 +608,7 @@ again:
 		struct sd_node *node = cur + i;
 
 		if (next_rw) {
-			sd_dprintf("go to the next recovery\n");
+			sd_dprintf("go to the next recovery");
 			return;
 		}
 		if (newly_joined(node, rw))
@@ -628,7 +628,7 @@ again:
 		goto again;
 	}
 
-	sd_dprintf("%d\n", rw->count);
+	sd_dprintf("%d", rw->count);
 }
 
 static inline bool node_is_gateway_only(void)
@@ -645,7 +645,7 @@ int start_recovery(struct vnode_info *cur_vinfo, struct vnode_info *old_vinfo)
 
 	rw = zalloc(sizeof(struct recovery_work));
 	if (!rw) {
-		sd_eprintf("%m\n");
+		sd_eprintf("%m");
 		return -1;
 	}
 
@@ -670,7 +670,7 @@ int start_recovery(struct vnode_info *cur_vinfo, struct vnode_info *old_vinfo)
 		/* skip the previous epoch recovery */
 		if (next_rw)
 			free_recovery_work(next_rw);
-		sd_dprintf("recovery skipped\n");
+		sd_dprintf("recovery skipped");
 		next_rw = rw;
 
 		/* This is necesary to invoke run_next_rw when
diff --git a/sheep/request.c b/sheep/request.c
index daabb41..6821167 100644
--- a/sheep/request.c
+++ b/sheep/request.c
@@ -51,13 +51,13 @@ static void io_op_done(struct work *work)
 	case SD_RES_EIO:
 		req->rp.result = SD_RES_NETWORK_ERROR;
 
-		sd_eprintf("leaving sheepdog cluster\n");
+		sd_eprintf("leaving sheepdog cluster");
 		leave_cluster();
 		break;
 	case SD_RES_SUCCESS:
 		break;
 	default:
-		sd_dprintf("unhandled error %d\n", req->rp.result);
+		sd_dprintf("unhandled error %d", req->rp.result);
 		break;
 	}
 
@@ -87,16 +87,13 @@ static void gateway_op_done(struct work *work)
 	case SD_RES_WAIT_FOR_JOIN:
 	case SD_RES_WAIT_FOR_FORMAT:
 	case SD_RES_KILLED:
-		sd_dprintf("retrying failed I/O request "
-			"op %s result %x epoch %"PRIu32", sys epoch %"PRIu32"\n",
-			op_name(req->op),
-			req->rp.result,
-			req->rq.epoch,
-			sys->epoch);
+		sd_dprintf("retrying failed I/O request op %s result %x epoch %"
+			   PRIu32", sys epoch %"PRIu32, op_name(req->op),
+			   req->rp.result, req->rq.epoch, sys->epoch);
 		goto retry;
 	case SD_RES_EIO:
 		if (is_access_local(req, hdr->obj.oid)) {
-			sd_eprintf("leaving sheepdog cluster\n");
+			sd_eprintf("leaving sheepdog cluster");
 			leave_cluster();
 			goto retry;
 		}
@@ -104,7 +101,7 @@ static void gateway_op_done(struct work *work)
 	case SD_RES_SUCCESS:
 		break;
 	default:
-		sd_dprintf("unhandled error %d\n", req->rp.result);
+		sd_dprintf("unhandled error %d", req->rp.result);
 		break;
 	}
 
@@ -129,16 +126,16 @@ static void local_op_done(struct work *work)
 static int check_request_epoch(struct request *req)
 {
 	if (before(req->rq.epoch, sys->epoch)) {
-		sd_eprintf("old node version %u, %u (%s)\n",
-			sys->epoch, req->rq.epoch, op_name(req->op));
+		sd_eprintf("old node version %u, %u (%s)",
+			   sys->epoch, req->rq.epoch, op_name(req->op));
 		/* ask gateway to retry. */
 		req->rp.result = SD_RES_OLD_NODE_VER;
 		req->rp.epoch = sys->epoch;
 		put_request(req);
 		return -1;
 	} else if (after(req->rq.epoch, sys->epoch)) {
-		sd_eprintf("new node version %u, %u (%s)\n",
-			sys->epoch, req->rq.epoch, op_name(req->op));
+		sd_eprintf("new node version %u, %u (%s)",
+			   sys->epoch, req->rq.epoch, op_name(req->op));
 
 		/* put on local wait queue, waiting for local epoch
 		   to be lifted */
@@ -173,14 +170,12 @@ static bool request_in_recovery(struct request *req)
 		 * Put request on wait queues of local node
 		 */
 		if (is_recovery_init()) {
-			sd_dprintf("%"PRIx64" on rw_queue\n", req->local_oid);
+			sd_dprintf("%"PRIx64" on rw_queue", req->local_oid);
 			req->rp.result = SD_RES_OBJ_RECOVERING;
-			list_add_tail(&req->request_list,
-				      &sys->wait_rw_queue);
+			list_add_tail(&req->request_list, &sys->wait_rw_queue);
 		} else {
-			sd_dprintf("%"PRIx64" on obj_queue\n", req->local_oid);
-			list_add_tail(&req->request_list,
-				      &sys->wait_obj_queue);
+			sd_dprintf("%"PRIx64" on obj_queue", req->local_oid);
+			list_add_tail(&req->request_list, &sys->wait_obj_queue);
 		}
 		return true;
 	}
@@ -231,7 +226,7 @@ void resume_wait_recovery_requests(void)
 		if (req->rp.result != SD_RES_OBJ_RECOVERING)
 			continue;
 
-		sd_dprintf("resume wait oid %" PRIx64 "\n", req->local_oid);
+		sd_dprintf("resume wait oid %" PRIx64, req->local_oid);
 		list_del(&req->request_list);
 		requeue_request(req);
 	}
@@ -252,7 +247,7 @@ void resume_wait_obj_requests(uint64_t oid)
 
 		/* the object requested by a pending request has been
 		 * recovered, notify the pending request. */
-		sd_dprintf("retry %" PRIx64 "\n", req->local_oid);
+		sd_dprintf("retry %" PRIx64, req->local_oid);
 		list_del(&req->request_list);
 		requeue_request(req);
 	}
@@ -346,12 +341,12 @@ static void queue_request(struct request *req)
 
 	req->op = get_sd_op(hdr->opcode);
 	if (!req->op) {
-		sd_eprintf("invalid opcode %d\n", hdr->opcode);
+		sd_eprintf("invalid opcode %d", hdr->opcode);
 		rsp->result = SD_RES_INVALID_PARMS;
 		goto done;
 	}
 
-	sd_dprintf("%s, %d\n", op_name(req->op), sys->status);
+	sd_dprintf("%s, %d", op_name(req->op), sys->status);
 
 	switch (sys->status) {
 	case SD_STATUS_KILLED:
@@ -402,7 +397,7 @@ static void queue_request(struct request *req)
 		hdr->epoch = sys->epoch;
 		queue_cluster_request(req);
 	} else {
-		sd_eprintf("unknown operation %d\n", hdr->opcode);
+		sd_eprintf("unknown operation %d", hdr->opcode);
 		rsp->result = SD_RES_SYSTEM_ERROR;
 		goto done;
 	}
@@ -472,7 +467,7 @@ again:
 	/* In error case (for e.g, EINTR) just retry read */
 	ret = eventfd_read(req->wait_efd, &value);
 	if (ret < 0) {
-		sd_eprintf("%m\n");
+		sd_eprintf("%m");
 		if (errno == EINTR)
 			goto again;
 		/* Fake the result to ask for retry */
@@ -592,7 +587,7 @@ static inline int begin_rx(struct client_info *ci)
 		ret = rx(conn, C_IO_END);
 		break;
 	default:
-		sd_eprintf("bug: unknown state %d\n", conn->c_rx_state);
+		sd_eprintf("bug: unknown state %d", conn->c_rx_state);
 	}
 
 	if (is_conn_dead(conn)) {
@@ -614,7 +609,7 @@ static inline void finish_rx(struct client_info *ci)
 	req = ci->rx_req;
 	init_rx_hdr(ci);
 
-	sd_dprintf("%d, %s:%d\n", ci->conn.fd, ci->conn.ipstr, ci->conn.port);
+	sd_dprintf("%d, %s:%d", ci->conn.fd, ci->conn.ipstr, ci->conn.port);
 	queue_request(req);
 }
 
@@ -700,8 +695,8 @@ static inline int finish_tx(struct client_info *ci)
 {
 	/* Finish sending one response */
 	if (ci->conn.c_tx_state == C_IO_END) {
-		sd_dprintf("connection from: %d, %s:%d\n", ci->conn.fd,
-			ci->conn.ipstr, ci->conn.port);
+		sd_dprintf("connection from: %d, %s:%d", ci->conn.fd,
+			   ci->conn.ipstr, ci->conn.port);
 		free_request(ci->tx_req);
 		ci->tx_req = NULL;
 	}
@@ -731,7 +726,7 @@ static void do_client_tx(struct client_info *ci)
 
 static void destroy_client(struct client_info *ci)
 {
-	sd_dprintf("connection from: %s:%d\n", ci->conn.ipstr, ci->conn.port);
+	sd_dprintf("connection from: %s:%d", ci->conn.ipstr, ci->conn.port);
 	close(ci->conn.fd);
 	free(ci);
 }
@@ -740,7 +735,7 @@ static void clear_client_info(struct client_info *ci)
 {
 	struct request *req, *t;
 
-	sd_dprintf("connection seems to be dead\n");
+	sd_dprintf("connection seems to be dead");
 
 	if (ci->rx_req) {
 		free_request(ci->rx_req);
@@ -759,9 +754,8 @@ static void clear_client_info(struct client_info *ci)
 
 	unregister_event(ci->conn.fd);
 
-	sd_dprintf("refcnt:%d, fd:%d, %s:%d\n",
-		ci->refcnt, ci->conn.fd,
-		ci->conn.ipstr, ci->conn.port);
+	sd_dprintf("refcnt:%d, fd:%d, %s:%d", ci->refcnt, ci->conn.fd,
+		   ci->conn.ipstr, ci->conn.port);
 
 	if (ci->refcnt)
 		return;
@@ -810,8 +804,8 @@ static void client_handler(int fd, int events, void *data)
 {
 	struct client_info *ci = (struct client_info *)data;
 
-	sd_dprintf("%x, rx %d, tx %d\n", events, ci->conn.c_rx_state,
-		ci->conn.c_tx_state);
+	sd_dprintf("%x, rx %d, tx %d", events, ci->conn.c_rx_state,
+		   ci->conn.c_tx_state);
 
 	if (events & (EPOLLERR | EPOLLHUP) || is_conn_dead(&ci->conn))
 		return clear_client_info(ci);
@@ -832,7 +826,7 @@ static void listen_handler(int listen_fd, int events, void *data)
 	bool is_inet_socket = *(bool *)data;
 
 	if (sys->status == SD_STATUS_SHUTDOWN) {
-		sd_dprintf("unregistering connection %d\n", listen_fd);
+		sd_dprintf("unregistering connection %d", listen_fd);
 		unregister_event(listen_fd);
 		return;
 	}
@@ -840,7 +834,7 @@ static void listen_handler(int listen_fd, int events, void *data)
 	namesize = sizeof(from);
 	fd = accept(listen_fd, (struct sockaddr *)&from, &namesize);
 	if (fd < 0) {
-		sd_eprintf("failed to accept a new connection: %m\n");
+		sd_eprintf("failed to accept a new connection: %m");
 		return;
 	}
 
@@ -870,7 +864,7 @@ static void listen_handler(int listen_fd, int events, void *data)
 		return;
 	}
 
-	sd_dprintf("accepted a new connection: %d\n", fd);
+	sd_dprintf("accepted a new connection: %d", fd);
 }
 
 static int create_listen_port_fn(int fd, void *data)
@@ -906,7 +900,7 @@ static void req_handler(int listen_fd, int events, void *data)
 	int ret;
 
 	if (events & EPOLLERR)
-		sd_eprintf("request handler error\n");
+		sd_eprintf("request handler error");
 
 	ret = eventfd_read(listen_fd, &value);
 	if (ret < 0)
diff --git a/sheep/sheep.c b/sheep/sheep.c
index 7a76f6f..1572149 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -134,13 +134,13 @@ static void signal_handler(int listen_fd, int events, void *data)
 
 	ret = read(sigfd, &siginfo, sizeof(siginfo));
 	assert(ret == sizeof(siginfo));
-	sd_dprintf("signal %d\n", siginfo.ssi_signo);
+	sd_dprintf("signal %d", siginfo.ssi_signo);
 	switch (siginfo.ssi_signo) {
 	case SIGTERM:
 		sys->status = SD_STATUS_KILLED;
 		break;
 	default:
-		sd_eprintf("signal %d unhandled\n", siginfo.ssi_signo);
+		sd_eprintf("signal %d unhandled", siginfo.ssi_signo);
 		break;
 	}
 }
@@ -160,24 +160,24 @@ static int init_signal(void)
 
 	sigfd = signalfd(-1, &mask, SFD_NONBLOCK);
 	if (sigfd < 0) {
-		sd_eprintf("failed to create a signal fd: %m\n");
+		sd_eprintf("failed to create a signal fd: %m");
 		return -1;
 	}
 
 	ret = register_event(sigfd, signal_handler, NULL);
 	if (ret) {
-		sd_eprintf("failed to register signal handler (%d)\n", ret);
+		sd_eprintf("failed to register signal handler (%d)", ret);
 		return -1;
 	}
 
-	sd_dprintf("register signal_handler for %d\n", sigfd);
+	sd_dprintf("register signal_handler for %d", sigfd);
 
 	return 0;
 }
 
 static void crash_handler(int signo)
 {
-	sd_printf(SDOG_EMERG, "sheep exits unexpectedly (%s).\n",
+	sd_printf(SDOG_EMERG, "sheep exits unexpectedly (%s).",
 		  strsignal(signo));
 
 	sd_backtrace();
@@ -411,22 +411,22 @@ static void check_host_env(void)
 	struct rlimit r;
 
 	if (getrlimit(RLIMIT_NOFILE, &r) < 0)
-		sd_eprintf("failed to get nofile %m\n");
+		sd_eprintf("failed to get nofile %m");
 	/*
 	 * 1024 is default for NOFILE on most distributions, which is very
 	 * dangerous to run Sheepdog cluster.
 	 */
 	else if (r.rlim_cur == 1024)
 		sd_eprintf("WARN: Allowed open files 1024 too small, "
-			   "suggested %u\n", SD_RLIM_NOFILE);
+			   "suggested %u", SD_RLIM_NOFILE);
 	else if (r.rlim_cur < SD_RLIM_NOFILE)
-		sd_iprintf("Allowed open files %lu, suggested %u\n",
-			   r.rlim_cur, SD_RLIM_NOFILE);
+		sd_iprintf("Allowed open files %lu, suggested %u", r.rlim_cur,
+			   SD_RLIM_NOFILE);
 
 	if (getrlimit(RLIMIT_CORE, &r) < 0)
-		sd_eprintf("failed to get core %m\n");
+		sd_eprintf("failed to get core %m");
 	else if (r.rlim_cur < RLIM_INFINITY)
-		sd_iprintf("Allowed core file size %lu, suggested unlimited\n",
+		sd_iprintf("Allowed core file size %lu, suggested unlimited",
 			   r.rlim_cur);
 }
 
@@ -659,7 +659,7 @@ int main(int argc, char **argv)
 
 	ret = create_cluster(port, zone, nr_vnodes, explicit_addr);
 	if (ret) {
-		sd_eprintf("failed to create sheepdog cluster\n");
+		sd_eprintf("failed to create sheepdog cluster");
 		exit(1);
 	}
 
@@ -668,7 +668,7 @@ int main(int argc, char **argv)
 		if (!strlen(jpath))
 			/* internal journal */
 			memcpy(jpath, dir, strlen(dir));
-		sd_dprintf("%s, %zu, %d\n", jpath, jsize, jskip);
+		sd_dprintf("%s, %zu, %d", jpath, jsize, jskip);
 		ret = journal_file_init(jpath, jsize, jskip);
 		if (ret)
 			exit(1);
@@ -705,8 +705,7 @@ int main(int argc, char **argv)
 		exit(1);
 
 	if (pid_file && (create_pidfile(pid_file) != 0)) {
-		fprintf(stderr, "failed to pid file '%s' - %s\n", pid_file,
-			strerror(errno));
+		fprintf(stderr, "failed to pid file '%s' - %m\n", pid_file);
 		exit(1);
 	}
 
@@ -717,15 +716,15 @@ int main(int argc, char **argv)
 
 	free(dir);
 	check_host_env();
-	sd_printf(SDOG_NOTICE, "sheepdog daemon (version %s) started\n",
-		PACKAGE_VERSION);
+	sd_printf(SDOG_NOTICE, "sheepdog daemon (version %s) started",
+		  PACKAGE_VERSION);
 
 	while (sys->nr_outstanding_reqs != 0 ||
 	       (sys->status != SD_STATUS_KILLED &&
 		sys->status != SD_STATUS_SHUTDOWN))
 		event_loop(-1);
 
-	sd_printf(SDOG_INFO, "shutdown\n");
+	sd_printf(SDOG_INFO, "shutdown");
 
 	leave_cluster();
 	log_close();
diff --git a/sheep/sockfd_cache.c b/sheep/sockfd_cache.c
index 168e9fb..ddefbf2 100644
--- a/sheep/sockfd_cache.c
+++ b/sheep/sockfd_cache.c
@@ -153,7 +153,7 @@ static struct sockfd_cache_entry *sockfd_cache_grab(const struct node_id *nid,
 		char name[INET6_ADDRSTRLEN];
 
 		addr_to_str(name, sizeof(name), nid->addr, 0);
-		sd_dprintf("failed node %s:%d\n", name, nid->port);
+		sd_dprintf("failed node %s:%d", name, nid->port);
 		goto out;
 	}
 
@@ -196,12 +196,12 @@ static bool sockfd_cache_destroy(const struct node_id *nid)
 	pthread_rwlock_wrlock(&sockfd_cache.lock);
 	entry = sockfd_cache_search(nid);
 	if (!entry) {
-		sd_dprintf("It is already destroyed\n");
+		sd_dprintf("It is already destroyed");
 		goto false_out;
 	}
 
 	if (!slots_all_free(entry)) {
-		sd_dprintf("Some victim still holds it\n");
+		sd_dprintf("Some victim still holds it");
 		goto false_out;
 	}
 
@@ -228,7 +228,7 @@ void sockfd_cache_del(const struct node_id *nid)
 
 	n = uatomic_sub_return(&sockfd_cache.count, 1);
 	addr_to_str(name, sizeof(name), nid->addr, 0);
-	sd_dprintf("%s:%d, count %d\n", name, nid->port, n);
+	sd_dprintf("%s:%d, count %d", name, nid->port, n);
 }
 
 static void sockfd_cache_add_nolock(const struct node_id *nid)
@@ -253,7 +253,7 @@ void sockfd_cache_add_group(const struct sd_node *nodes, int nr)
 {
 	const struct sd_node *p;
 
-	sd_dprintf("%d\n", nr);
+	sd_dprintf("%d", nr);
 	pthread_rwlock_wrlock(&sockfd_cache.lock);
 	while (nr--) {
 		p = nodes + nr;
@@ -285,7 +285,7 @@ void sockfd_cache_add(const struct node_id *nid)
 	pthread_rwlock_unlock(&sockfd_cache.lock);
 	n = uatomic_add_return(&sockfd_cache.count, 1);
 	addr_to_str(name, sizeof(name), nid->addr, 0);
-	sd_dprintf("%s:%d, count %d\n", name, nid->port, n);
+	sd_dprintf("%s:%d, count %d", name, nid->port, n);
 }
 
 static void do_grow_fds(struct work *work)
@@ -294,7 +294,7 @@ static void do_grow_fds(struct work *work)
 	struct rb_node *p;
 	int old_fds_count, new_fds_count, new_size, i;
 
-	sd_dprintf("%d\n", fds_count);
+	sd_dprintf("%d", fds_count);
 	pthread_rwlock_wrlock(&sockfd_cache.lock);
 	old_fds_count = fds_count;
 	new_fds_count = fds_count * 2;
@@ -317,7 +317,7 @@ static void grow_fds_done(struct work *work)
 {
 	fds_count *= 2;
 	fds_high_watermark = FDS_WATERMARK(fds_count);
-	sd_dprintf("fd count has been grown into %d\n", fds_count);
+	sd_dprintf("fd count has been grown into %d", fds_count);
 	uatomic_set_false(&fds_in_grow);
 	free(work);
 }
@@ -392,16 +392,16 @@ grab:
 	}
 	check_idx(idx);
 	if (entry->fds[idx].fd != -1) {
-		sd_dprintf("%s:%d, idx %d\n", name, port, idx);
+		sd_dprintf("%s:%d, idx %d", name, port, idx);
 		goto out;
 	}
 
 	/* Create a new cached connection for this vnode */
-	sd_dprintf("create cache connection %s:%d idx %d\n", name, port, idx);
+	sd_dprintf("create cache connection %s:%d idx %d", name, port, idx);
 	fd = connect_to(name, port);
 	if (fd < 0) {
 		if (use_io) {
-			sd_eprintf("fallback to non-io connection\n");
+			sd_eprintf("fallback to non-io connection");
 			fd = connect_to_addr(nid->addr, nid->port);
 			if (fd >= 0)
 				goto new;
@@ -427,7 +427,7 @@ static void sockfd_cache_put(const struct node_id *nid, int idx)
 	char name[INET6_ADDRSTRLEN];
 
 	addr_to_str(name, sizeof(name), addr, 0);
-	sd_dprintf("%s:%d idx %d\n", name, port, idx);
+	sd_dprintf("%s:%d idx %d", name, port, idx);
 
 	pthread_rwlock_rdlock(&sockfd_cache.lock);
 	entry = sockfd_cache_search(nid);
@@ -462,7 +462,7 @@ struct sockfd *sheep_get_sockfd(const struct node_id *nid)
 	sfd = xmalloc(sizeof(*sfd));
 	sfd->idx = -1;
 	sfd->fd = fd;
-	sd_dprintf("%d\n", fd);
+	sd_dprintf("%d", fd);
 	return sfd;
 }
 
@@ -480,7 +480,7 @@ struct sockfd *sheep_get_sockfd(const struct node_id *nid)
 void sheep_put_sockfd(const struct node_id *nid, struct sockfd *sfd)
 {
 	if (sfd->idx == -1) {
-		sd_dprintf("%d\n", sfd->fd);
+		sd_dprintf("%d", sfd->fd);
 		close(sfd->fd);
 		free(sfd);
 		return;
@@ -500,7 +500,7 @@ void sheep_put_sockfd(const struct node_id *nid, struct sockfd *sfd)
 void sheep_del_sockfd(const struct node_id *nid, struct sockfd *sfd)
 {
 	if (sfd->idx == -1) {
-		sd_dprintf("%d\n", sfd->fd);
+		sd_dprintf("%d", sfd->fd);
 		close(sfd->fd);
 		free(sfd);
 		return;
@@ -523,13 +523,13 @@ int sheep_exec_req(const struct node_id *nid, struct sd_req *hdr, void *buf)
 
 	ret = exec_req(sfd->fd, hdr, buf, sheep_need_retry, hdr->epoch);
 	if (ret) {
-		sd_dprintf("remote node might have gone away\n");
+		sd_dprintf("remote node might have gone away");
 		sheep_del_sockfd(nid, sfd);
 		return SD_RES_NETWORK_ERROR;
 	}
 	ret = rsp->result;
 	if (ret != SD_RES_SUCCESS)
-		sd_eprintf("failed %x\n", ret);
+		sd_eprintf("failed %x", ret);
 
 	sheep_put_sockfd(nid, sfd);
 	return ret;
diff --git a/sheep/store.c b/sheep/store.c
index 8b9f1a9..7f3b5cd 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -45,7 +45,7 @@ int update_epoch_log(uint32_t epoch, struct sd_node *nodes, size_t nr_nodes)
 	time_t t;
 	char path[PATH_MAX];
 
-	sd_dprintf("update epoch: %d, %zd\n", epoch, nr_nodes);
+	sd_dprintf("update epoch: %d, %zd", epoch, nr_nodes);
 
 	snprintf(path, sizeof(path), "%s%08u", epoch_path, epoch);
 	fd = open(path, O_RDWR | O_CREAT | O_DSYNC, def_fmode);
@@ -71,7 +71,7 @@ int update_epoch_log(uint32_t epoch, struct sd_node *nodes, size_t nr_nodes)
 err:
 	close(fd);
 err_open:
-	sd_dprintf("%s\n", strerror(errno));
+	sd_dprintf("%m");
 	return -1;
 }
 
@@ -122,7 +122,7 @@ int epoch_log_read(uint32_t epoch, struct sd_node *nodes, int len)
 	snprintf(path, sizeof(path), "%s%08u", epoch_path, epoch);
 	fd = open(path, O_RDONLY);
 	if (fd < 0) {
-		sd_eprintf("failed to open epoch %"PRIu32" log\n", epoch);
+		sd_eprintf("failed to open epoch %"PRIu32" log", epoch);
 		return -1;
 	}
 
@@ -131,7 +131,7 @@ int epoch_log_read(uint32_t epoch, struct sd_node *nodes, int len)
 	close(fd);
 
 	if (len < 0) {
-		sd_eprintf("failed to read epoch %"PRIu32" log\n", epoch);
+		sd_eprintf("failed to read epoch %"PRIu32" log", epoch);
 		return -1;
 	}
 	return len / sizeof(*nodes);
@@ -145,10 +145,8 @@ uint32_t get_latest_epoch(void)
 	char *p;
 
 	dir = opendir(epoch_path);
-	if (!dir) {
-		sd_printf(SDOG_EMERG, "failed to get the latest epoch: %m\n");
-		abort();
-	}
+	if (!dir)
+		panic("failed to get the latest epoch: %m");
 
 	while ((d = readdir(dir))) {
 		e = strtol(d->d_name, &p, 10);
@@ -177,13 +175,13 @@ again:
 	ret = stat(d, &s);
 	if (ret) {
 		if (retry || errno != ENOENT) {
-			sd_eprintf("cannot handle the directory %s: %m\n", d);
+			sd_eprintf("cannot handle the directory %s: %m", d);
 			return 1;
 		}
 
 		ret = mkdir(d, def_dmode);
 		if (ret) {
-			sd_eprintf("cannot create the directory %s: %m\n", d);
+			sd_eprintf("cannot create the directory %s: %m", d);
 			return 1;
 		} else {
 			if (new)
@@ -194,7 +192,7 @@ again:
 	}
 
 	if (!S_ISDIR(s.st_mode)) {
-		sd_eprintf("%s is not a directory\n", d);
+		sd_eprintf("%s is not a directory", d);
 		return 1;
 	}
 
@@ -214,18 +212,16 @@ static int lock_base_dir(const char *d)
 
 	fd = open(lock_path, O_WRONLY|O_CREAT, def_fmode);
 	if (fd < 0) {
-		sd_eprintf("failed to open lock file %s (%s)\n",
-			lock_path, strerror(errno));
+		sd_eprintf("failed to open lock file %s (%m)", lock_path);
 		ret = -1;
 		goto out;
 	}
 
 	if (lockf(fd, F_TLOCK, 1) < 0) {
 		if (errno == EACCES || errno == EAGAIN) {
-			sd_eprintf("another sheep daemon is using %s\n", d);
+			sd_eprintf("another sheep daemon is using %s", d);
 		} else {
-			sd_eprintf("unable to get base dir lock (%s)\n",
-				strerror(errno));
+			sd_eprintf("unable to get base dir lock (%m)");
 		}
 		ret = -1;
 		goto out;
@@ -320,7 +316,7 @@ int init_store_driver(void)
 		 * If the driver name is not NUL terminated we are in deep
 		 * trouble, let's get out here.
 		 */
-		sd_dprintf("store name not NUL terminated\n");
+		sd_dprintf("store name not NUL terminated");
 		return SD_RES_NO_STORE;
 	}
 
@@ -333,7 +329,7 @@ int init_store_driver(void)
 
 	sd_store = find_store_driver(driver_name);
 	if (!sd_store) {
-		sd_dprintf("store %s not found\n", driver_name);
+		sd_dprintf("store %s not found", driver_name);
 		return SD_RES_NO_STORE;
 	}
 
@@ -362,7 +358,7 @@ int init_disk_space(const char *base_path)
 
 	ret = statvfs(base_path, &fs);
 	if (ret < 0) {
-		sd_dprintf("get disk space failed %m\n");
+		sd_dprintf("get disk space failed %m");
 		ret = SD_RES_EIO;
 		goto out;
 	}
@@ -370,7 +366,7 @@ int init_disk_space(const char *base_path)
 	sys->disk_space = (uint64_t)fs.f_frsize * fs.f_bfree;
 	ret = set_cluster_space(sys->disk_space);
 out:
-	sd_dprintf("disk free space is %" PRIu64 "\n", sys->disk_space);
+	sd_dprintf("disk free space is %" PRIu64, sys->disk_space);
 	return ret;
 }
 
@@ -414,8 +410,8 @@ int write_object(uint64_t oid, char *data, unsigned int datalen,
 			goto forward_write;
 
 		if (ret != 0) {
-			sd_eprintf("write cache failed %"PRIx64" %"PRIx32"\n",
-				oid, ret);
+			sd_eprintf("write cache failed %"PRIx64" %"PRIx32, oid,
+				   ret);
 			return ret;
 		}
 	}
@@ -434,8 +430,7 @@ forward_write:
 
 	ret = exec_local_req(&hdr, data);
 	if (ret != SD_RES_SUCCESS)
-		sd_eprintf("failed to write object %" PRIx64 ", %x\n",
-			oid, ret);
+		sd_eprintf("failed to write object %" PRIx64 ", %x", oid, ret);
 
 	return ret;
 }
@@ -455,7 +450,7 @@ int read_backend_object(uint64_t oid, char *data, unsigned int datalen,
 
 	ret = exec_local_req(&hdr, data);
 	if (ret != SD_RES_SUCCESS)
-		sd_eprintf("failed to read object %" PRIx64 ", %x\n", oid, ret);
+		sd_eprintf("failed to read object %" PRIx64 ", %x", oid, ret);
 
 	untrim_zero_sectors(data, rsp->obj.offset, rsp->data_length, datalen);
 
@@ -474,8 +469,8 @@ int read_object(uint64_t oid, char *data, unsigned int datalen,
 	if (is_object_cache_enabled() && object_is_cached(oid)) {
 		ret = object_cache_read(oid, data, datalen, offset);
 		if (ret != SD_RES_SUCCESS) {
-			sd_eprintf("try forward read %"PRIx64" %"PRIx32"\n",
-				oid, ret);
+			sd_eprintf("try forward read %"PRIx64" %"PRIx32, oid,
+				   ret);
 			goto forward_read;
 		}
 		return ret;
@@ -498,8 +493,7 @@ int remove_object(uint64_t oid, int copies)
 
 	ret = exec_local_req(&hdr, NULL);
 	if (ret != SD_RES_SUCCESS)
-		sd_eprintf("failed to remove object %" PRIx64 ", %x\n",
-			oid, ret);
+		sd_eprintf("failed to remove object %" PRIx64 ", %x", oid, ret);
 
 	return ret;
 }
diff --git a/sheep/trace/trace.c b/sheep/trace/trace.c
index 75f7ff1..377c4f2 100644
--- a/sheep/trace/trace.c
+++ b/sheep/trace/trace.c
@@ -124,14 +124,14 @@ notrace struct caller *trace_lookup_ip(unsigned long ip, bool create)
 	}
 not_found:
 	if (get_ipinfo(ip, &info) < 0) {
-		sd_dprintf("ip: %lx not found\n", ip);
+		sd_dprintf("ip: %lx not found", ip);
 		new = NULL;
 		goto out;
 	}
 	if (create) {
 		new = malloc(sizeof(*new));
 		if (!new) {
-			sd_eprintf("out of memory\n");
+			sd_eprintf("out of memory");
 			goto out;
 		}
 		new->mcount = ip;
@@ -139,7 +139,7 @@ not_found:
 		new->name = info.fn_name;
 		hlist_add_head(&new->hash, head);
 		list_add(&new->list, &caller_list);
-		sd_dprintf("add %.*s\n", info.fn_namelen, info.fn_name);
+		sd_dprintf("add %.*s", info.fn_namelen, info.fn_name);
 	} else {
 		sd_dprintf("%.*s\n not found", info.fn_namelen, info.fn_name);
 		new = NULL;
@@ -187,7 +187,7 @@ static notrace void suspend_worker_threads(void)
 	list_for_each_entry(wi, &worker_info_list, worker_info_siblings) {
 		if (wi->ordered &&
 		    pthread_kill(wi->worker_thread, SIGUSR2) != 0)
-			sd_dprintf("%m\n");
+			sd_dprintf("%m");
 	}
 
 wait_for_worker_suspend:
@@ -247,7 +247,7 @@ static notrace void enable_tracer(int fd, int events, void *data)
 	 * expected to be waken up by epoll again.
 	 */
 	if (ret < 0) {
-		sd_eprintf("%m\n");
+		sd_eprintf("%m");
 		return;
 	}
 
@@ -259,7 +259,7 @@ static notrace void enable_tracer(int fd, int events, void *data)
 	resume_worker_threads();
 	unregister_event(trace_efd);
 	trace_in_patch = false;
-	sd_dprintf("tracer enabled\n");
+	sd_dprintf("tracer enabled");
 }
 
 static notrace void disable_tracer(int fd, int events, void *data)
@@ -269,7 +269,7 @@ static notrace void disable_tracer(int fd, int events, void *data)
 
 	ret = eventfd_read(fd, &value);
 	if (ret < 0) {
-		sd_eprintf("%m\n");
+		sd_eprintf("%m");
 		return;
 	}
 
@@ -281,13 +281,13 @@ static notrace void disable_tracer(int fd, int events, void *data)
 	resume_worker_threads();
 	unregister_event(trace_efd);
 	trace_in_patch = false;
-	sd_dprintf("tracer disabled\n");
+	sd_dprintf("tracer disabled");
 }
 
 notrace int trace_enable(void)
 {
 	if (trace_func == trace_call) {
-		sd_dprintf("no tracer available\n");
+		sd_dprintf("no tracer available");
 		return SD_RES_NO_TAG;
 	}
 
@@ -309,7 +309,7 @@ int trace_init_signal(void)
 {
 	/* trace uses this signal to suspend the worker threads */
 	if (install_sighandler(SIGUSR2, suspend, false) < 0) {
-		sd_dprintf("%m\n");
+		sd_dprintf("%m");
 		return -1;
 	}
 	return 0;
@@ -366,12 +366,12 @@ notrace int trace_init(void)
 	sigemptyset(&block);
 	sigaddset(&block, SIGUSR2);
 	if (pthread_sigmask(SIG_BLOCK, &block, NULL) != 0) {
-		sd_dprintf("%m\n");
+		sd_dprintf("%m");
 		return -1;
 	}
 
 	if (make_text_writable((unsigned long)mcount_call) < 0) {
-		sd_dprintf("%m\n");
+		sd_dprintf("%m");
 		return -1;
 	}
 
@@ -384,6 +384,6 @@ notrace int trace_init(void)
 
 	trace_efd = eventfd(0, EFD_NONBLOCK);
 
-	sd_dprintf("trace support enabled. cpu count %d.\n", nr_cpu);
+	sd_dprintf("trace support enabled. cpu count %d.", nr_cpu);
 	return 0;
 }
diff --git a/sheep/vdi.c b/sheep/vdi.c
index e7f55ff..1f23415 100644
--- a/sheep/vdi.c
+++ b/sheep/vdi.c
@@ -79,7 +79,7 @@ int get_vdi_copy_number(uint32_t vid)
 	pthread_rwlock_unlock(&vdi_copy_lock);
 
 	if (!entry) {
-		sd_eprintf("No VDI copy entry for %" PRIx32 " found\n", vid);
+		sd_eprintf("No VDI copy entry for %" PRIx32 " found", vid);
 		return 0;
 	}
 
@@ -122,7 +122,7 @@ int add_vdi_copy_number(uint32_t vid, int nr_copies)
 	entry->vid = vid;
 	entry->nr_copies = nr_copies;
 
-	sd_dprintf("%" PRIx32 ", %d\n", vid, nr_copies);
+	sd_dprintf("%" PRIx32 ", %d", vid, nr_copies);
 
 	pthread_rwlock_wrlock(&vdi_copy_lock);
 	old = vdi_copy_insert(&vdi_copy_root, entry);
@@ -172,7 +172,7 @@ int vdi_exist(uint32_t vid)
 	ret = read_object(vid_to_vdi_oid(vid), (char *)inode,
 			  sizeof(*inode), 0, nr_copies);
 	if (ret != SD_RES_SUCCESS) {
-		sd_eprintf("fail to read vdi inode (%" PRIx32 ")\n", vid);
+		sd_eprintf("fail to read vdi inode (%" PRIx32 ")", vid);
 		ret = 0;
 		goto out;
 	}
@@ -219,12 +219,12 @@ static int create_vdi_obj(struct vdi_iocb *iocb, uint32_t new_vid,
 	if (iocb->create_snapshot) {
 		if (cur_vid != iocb->base_vid) {
 			sd_printf(SDOG_INFO, "tree snapshot %s %" PRIx32 " %"
-				PRIx32 "\n", name, cur_vid, iocb->base_vid);
+				  PRIx32, name, cur_vid, iocb->base_vid);
 
 			ret = read_object(vid_to_vdi_oid(cur_vid), (char *)cur,
 					  SD_INODE_HEADER_SIZE, 0, 0);
 			if (ret != SD_RES_SUCCESS) {
-				sd_printf(SDOG_ERR, "failed\n");
+				sd_printf(SDOG_ERR, "failed");
 				ret = SD_RES_BASE_VDI_READ;
 				goto out;
 			}
@@ -266,7 +266,7 @@ static int create_vdi_obj(struct vdi_iocb *iocb, uint32_t new_vid,
 		ret = write_object(vid_to_vdi_oid(cur_vid), (char *)cur,
 				   SD_INODE_HEADER_SIZE, 0, 0, false, 0);
 		if (ret != 0) {
-			sd_printf(SDOG_ERR, "failed\n");
+			sd_printf(SDOG_ERR, "failed");
 			ret = SD_RES_BASE_VDI_READ;
 			goto out;
 		}
@@ -276,7 +276,7 @@ static int create_vdi_obj(struct vdi_iocb *iocb, uint32_t new_vid,
 		ret = write_object(vid_to_vdi_oid(iocb->base_vid), (char *)base,
 				   SD_INODE_HEADER_SIZE, 0, 0, false, 0);
 		if (ret != 0) {
-			sd_printf(SDOG_ERR, "failed\n");
+			sd_printf(SDOG_ERR, "failed");
 			ret = SD_RES_BASE_VDI_WRITE;
 			goto out;
 		}
@@ -308,7 +308,7 @@ static int find_first_vdi(unsigned long start, unsigned long end,
 
 	inode = malloc(SD_INODE_HEADER_SIZE);
 	if (!inode) {
-		sd_eprintf("failed to allocate memory\n");
+		sd_eprintf("failed to allocate memory");
 		goto out;
 	}
 
@@ -370,7 +370,7 @@ static int do_lookup_vdi(const char *name, int namelen, uint32_t *vid,
 
 	start_nr = fnv_64a_buf(name, namelen, FNV1A_64_INIT) & (SD_NR_VDIS - 1);
 
-	sd_dprintf("looking for %s (%lx)\n", name, start_nr);
+	sd_dprintf("looking for %s (%lx)", name, start_nr);
 
 	/* bitmap search from the hash point */
 	nr = find_next_zero_bit(sys->vdi_inuse, SD_NR_VDIS, start_nr);
@@ -434,8 +434,8 @@ static int notify_vdi_add(uint32_t vdi_id, uint32_t nr_copies)
 
 	ret = exec_local_req(&hdr, buf);
 	if (ret != SD_RES_SUCCESS)
-		sd_eprintf("fail to notify vdi add event(%" PRIx32 ", %d)\n",
-			vdi_id, nr_copies);
+		sd_eprintf("fail to notify vdi add event(%" PRIx32 ", %d)",
+			   vdi_id, nr_copies);
 
 	free(buf);
 
@@ -463,8 +463,8 @@ int add_vdi(struct vdi_iocb *iocb, uint32_t *new_vid)
 	if (iocb->create_snapshot) {
 		if (ret != SD_RES_SUCCESS) {
 			if (ret == SD_RES_NO_VDI)
-				sd_printf(SDOG_CRIT, "VDI %s does not exist\n",
-					name);
+				sd_printf(SDOG_CRIT, "VDI %s does not exist",
+					  name);
 			return ret;
 		}
 		nr = right_nr;
@@ -487,7 +487,7 @@ int add_vdi(struct vdi_iocb *iocb, uint32_t *new_vid)
 	notify_vdi_add(nr, iocb->nr_copies);
 
 	sd_iprintf("creating new %s %s: size %" PRIu64 ", vid %"
-		   PRIx32 ", base %" PRIx32 ", cur %" PRIx32 ", copies %d\n",
+		   PRIx32 ", base %" PRIx32 ", cur %" PRIx32 ", copies %d",
 		   iocb->create_snapshot ? "snapshot" : "vdi", name, iocb->size,
 		   *new_vid, iocb->base_vid, cur_vid, iocb->nr_copies);
 
@@ -589,8 +589,8 @@ static int notify_vdi_deletion(uint32_t vdi_id)
 
 	ret = exec_local_req(&hdr, &vdi_id);
 	if (ret != SD_RES_SUCCESS)
-		sd_eprintf("fail to notify vdi deletion(%" PRIx32 "), %d\n",
-			vdi_id, ret);
+		sd_eprintf("fail to notify vdi deletion(%" PRIx32 "), %d",
+			   vdi_id, ret);
 
 	return ret;
 }
@@ -603,11 +603,11 @@ static void delete_one(struct work *work)
 	struct sheepdog_inode *inode = NULL;
 	int nr_copies;
 
-	sd_dprintf("%d %d, %16x\n", dw->done, dw->count, vdi_id);
+	sd_dprintf("%d %d, %16x", dw->done, dw->count, vdi_id);
 
 	inode = malloc(sizeof(*inode));
 	if (!inode) {
-		sd_eprintf("failed to allocate memory\n");
+		sd_eprintf("failed to allocate memory");
 		goto out;
 	}
 
@@ -616,7 +616,7 @@ static void delete_one(struct work *work)
 			  (void *)inode, sizeof(*inode), 0, nr_copies);
 
 	if (ret != SD_RES_SUCCESS) {
-		sd_eprintf("cannot find VDI object\n");
+		sd_eprintf("cannot find VDI object");
 		goto out;
 	}
 
@@ -633,14 +633,14 @@ static void delete_one(struct work *work)
 
 		if (inode->data_vdi_id[i] != inode->vdi_id) {
 			sd_dprintf("object %" PRIx64 " is base's data, would"
-				" not be deleted.\n", oid);
+				   " not be deleted.", oid);
 			continue;
 		}
 
 		ret = remove_object(oid, nr_copies);
 		if (ret != SD_RES_SUCCESS)
-			sd_eprintf("remove object %" PRIx64 " fail, %d\n",
-				oid, ret);
+			sd_eprintf("remove object %" PRIx64 " fail, %d", oid,
+				   ret);
 
 		nr_deleted++;
 	}
@@ -696,7 +696,7 @@ static int fill_vdi_list(struct deletion_work *dw, uint32_t root_vid)
 
 	inode = malloc(SD_INODE_HEADER_SIZE);
 	if (!inode) {
-		sd_eprintf("failed to allocate memory\n");
+		sd_eprintf("failed to allocate memory");
 		goto err;
 	}
 
@@ -708,7 +708,7 @@ again:
 			  SD_INODE_HEADER_SIZE, 0, nr_copies);
 
 	if (ret != SD_RES_SUCCESS) {
-		sd_eprintf("cannot find VDI object\n");
+		sd_eprintf("cannot find VDI object");
 		goto err;
 	}
 
@@ -741,7 +741,7 @@ static uint64_t get_vdi_root(uint32_t vid, bool *cloned)
 
 	inode = malloc(SD_INODE_HEADER_SIZE);
 	if (!inode) {
-		sd_eprintf("failed to allocate memory\n");
+		sd_eprintf("failed to allocate memory");
 		vid = 0;
 		goto out;
 	}
@@ -753,13 +753,13 @@ next:
 	if (vid == inode->vdi_id && inode->snap_id == 1
 			&& inode->parent_vdi_id != 0
 			&& !inode->snap_ctime) {
-		sd_dprintf("vdi %" PRIx32 " is a cloned vdi.\n", vid);
+		sd_dprintf("vdi %" PRIx32 " is a cloned vdi.", vid);
 		/* current vdi is a cloned vdi */
 		*cloned = true;
 	}
 
 	if (ret != SD_RES_SUCCESS) {
-		sd_eprintf("cannot find VDI object\n");
+		sd_eprintf("cannot find VDI object");
 		vid = 0;
 		goto out;
 	}
@@ -809,14 +809,14 @@ static int start_deletion(struct request *req, uint32_t vid)
 			dw->count = 1;
 		} else {
 			sd_dprintf("snapshot chain has valid vdi, "
-				"just mark vdi %" PRIx32 " as deleted.\n",
-				dw->vid);
+				   "just mark vdi %" PRIx32 " as deleted.",
+				   dw->vid);
 			delete_inode(dw);
 			return SD_RES_SUCCESS;
 		}
 	}
 
-	sd_dprintf("%d\n", dw->count);
+	sd_dprintf("%d", dw->count);
 
 	if (dw->count == 0)
 		goto out;
@@ -908,7 +908,7 @@ int get_vdi_attr(struct sheepdog_vdi_attr *vattr, int data_len,
 		(*attrid)++;
 	}
 
-	sd_dprintf("there is no space for new VDIs\n");
+	sd_dprintf("there is no space for new VDIs");
 	ret = SD_RES_FULL_VDI;
 out:
 	return ret;
diff --git a/sheep/work.c b/sheep/work.c
index ba88859..7b4b4c7 100644
--- a/sheep/work.c
+++ b/sheep/work.c
@@ -68,7 +68,7 @@ static void *run_short_thread(void *arg)
 	/* Tell runtime to release resources after termination */
 	err = pthread_detach(pthread_self());
 	if (err)
-		panic("%s\n", strerror(err));
+		panic("%s", strerror(err));
 
 	set_thread_name(sw->wi->name, uatomic_add_return(&idx, 1));
 
@@ -95,7 +95,7 @@ static inline void create_short_thread(struct worker_info *wi,
 
 	err = pthread_create(&thread, NULL, run_short_thread, sw);
 	if (err)
-		panic("%s\n", strerror(err));
+		panic("%s", strerror(err));
 	short_thread_begin();
 }
 
@@ -190,13 +190,13 @@ int init_wqueue_eventfd(void)
 
 	efd = eventfd(0, EFD_NONBLOCK);
 	if (efd < 0) {
-		sd_eprintf("failed to create an event fd: %m\n");
+		sd_eprintf("failed to create an event fd: %m");
 		return 1;
 	}
 
 	ret = register_event(efd, bs_thread_request_done, NULL);
 	if (ret) {
-		sd_eprintf("failed to register event fd %m\n");
+		sd_eprintf("failed to register event fd %m");
 		close(efd);
 		return 1;
 	}
@@ -229,8 +229,7 @@ struct work_queue *init_work_queue(const char *name, bool ordered)
 		ret = pthread_create(&wi->worker_thread, NULL, worker_routine,
 				     wi);
 		if (ret) {
-			sd_eprintf("failed to create worker thread: %s\n",
-				strerror(ret));
+			sd_eprintf("failed to create worker thread: %m");
 			goto destroy_threads;
 		}
 
@@ -246,7 +245,7 @@ destroy_threads:
 	wi->q.wq_state |= WQ_DEAD;
 	pthread_mutex_unlock(&wi->startup_lock);
 	pthread_join(wi->worker_thread, NULL);
-	sd_eprintf("stopped worker thread\n");
+	sd_eprintf("stopped worker thread");
 
 /* destroy_cond_mutex: */
 	pthread_cond_destroy(&wi->pending_cond);
-- 
1.8.1.3.566.gaa39828




More information about the sheepdog mailing list