[sheepdog] [PATCH] use boolean where it is appropriate

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Wed Jan 16 15:10:58 CET 2013


Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 include/util.h |    2 +-
 lib/util.c     |   16 ++++++++--------
 sheep/group.c  |    2 +-
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/util.h b/include/util.h
index 44c2a2a..bebef6a 100644
--- a/include/util.h
+++ b/include/util.h
@@ -82,7 +82,7 @@ extern ssize_t xpread(int fd, void *buf, size_t count, off_t offset);
 extern ssize_t xpwrite(int fd, const void *buf, size_t count, off_t offset);
 extern void pstrcpy(char *buf, int buf_size, const char *str);
 extern int rmdir_r(char *dir_path);
-extern int is_numeric(const char *p);
+extern bool is_numeric(const char *p);
 
 void trim_zero_sectors(void *buf, uint64_t *offset, uint32_t *len);
 void set_trimmed_sectors(void *buf, uint64_t offset, uint32_t len,
diff --git a/lib/util.c b/lib/util.c
index 84aad0a..0fc888f 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -94,7 +94,7 @@ void *xcalloc(size_t nmemb, size_t size)
 static ssize_t _read(int fd, void *buf, size_t len)
 {
 	ssize_t nr;
-	while (1) {
+	while (true) {
 		nr = read(fd, buf, len);
 		if ((nr < 0) && (errno == EAGAIN || errno == EINTR))
 			continue;
@@ -105,7 +105,7 @@ static ssize_t _read(int fd, void *buf, size_t len)
 static ssize_t _write(int fd, const void *buf, size_t len)
 {
 	ssize_t nr;
-	while (1) {
+	while (true) {
 		nr = write(fd, buf, len);
 		if ((nr < 0) && (errno == EAGAIN || errno == EINTR))
 			continue;
@@ -156,7 +156,7 @@ ssize_t xwrite(int fd, const void *buf, size_t count)
 static ssize_t _pread(int fd, void *buf, size_t len, off_t offset)
 {
 	ssize_t nr;
-	while (1) {
+	while (true) {
 		nr = pread(fd, buf, len, offset);
 		if ((nr < 0) && (errno == EAGAIN || errno == EINTR))
 			continue;
@@ -167,7 +167,7 @@ static ssize_t _pread(int fd, void *buf, size_t len, off_t offset)
 static ssize_t _pwrite(int fd, const void *buf, size_t len, off_t offset)
 {
 	ssize_t nr;
-	while (1) {
+	while (true) {
 		nr = pwrite(fd, buf, len, offset);
 		if ((nr < 0) && (errno == EAGAIN || errno == EINTR))
 			continue;
@@ -331,7 +331,7 @@ void set_trimmed_sectors(void *buf, uint64_t offset, uint32_t len,
 		memset(p + offset + len, 0, requested_len - offset - len);
 }
 
-int is_numeric(const char *s)
+bool is_numeric(const char *s)
 {
 	const char *p = s;
 
@@ -340,8 +340,8 @@ int is_numeric(const char *s)
 
 		while ((c=*p++))
 			if (!isdigit(c))
-				return 0;
-		return 1;
+				return false;
+		return true;
 	}
-	return 0;
+	return false;
 }
diff --git a/sheep/group.c b/sheep/group.c
index 05e4f0a..9462180 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -42,7 +42,7 @@ struct get_vdis_work {
 
 static pthread_mutex_t wait_vdis_lock = PTHREAD_MUTEX_INITIALIZER;
 static pthread_cond_t wait_vdis_cond = PTHREAD_COND_INITIALIZER;
-static int is_vdi_list_ready = true;
+static bool is_vdi_list_ready = true;
 
 static struct vnode_info *current_vnode_info;
 
-- 
1.7.2.5




More information about the sheepdog mailing list