[CRIU] [crtools-bot] A few cleanups to uts_ns

Cyrill Gorcunov gorcunov at openvz.org
Tue Jan 31 14:35:07 EST 2012


The commit is pushed to "master" and will appear on git://github.com/cyrillos/crtools.git
------>
commit ca099959343463088387df332107c2a6c5d47186
Author: Cyrill Gorcunov <gorcunov at openvz.org>
Date:   Tue Jan 31 23:29:24 2012 +0400

    A few cleanups to uts_ns
    
     - drop hardcoded numbers, use sizeof
     - drop unneeded local argument
    
    Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 uts_ns.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/uts_ns.c b/uts_ns.c
index af16805..04bfced 100644
--- a/uts_ns.c
+++ b/uts_ns.c
@@ -14,7 +14,7 @@ static int dump_uts_string(int fd, char *str)
 
 	len = strlen(str);
 	ret = write_img(fd, &len);
-	if (ret == 0)
+	if (!ret)
 		ret = write_img_buf(fd, str, len);
 
 	return ret;
@@ -52,7 +52,7 @@ static int prepare_uts_str(int fd, char *n)
 
 	ret = read_img(fd, &len);
 	if (ret > 0) {
-		if (len >= 65) {
+		if (len >= sizeof(str)) {
 			pr_err("Corrupted %s\n", n);
 			return -1;
 		}
@@ -91,7 +91,6 @@ int prepare_utsns(int pid)
 {
 	int fd, ret;
 	u32 len;
-	char str[65];
 
 	fd = open_image_ro(CR_FD_UTSNS, pid);
 	if (fd < 0)
@@ -113,7 +112,7 @@ static void show_uts_string(int fd, char *n)
 
 	ret = read_img(fd, &len);
 	if (ret > 0) {
-		if (len >= 65) {
+		if (len >= sizeof(str)) {
 			pr_err("Corrupted hostname\n");
 			return;
 		}


More information about the CRIU mailing list