[CRIU] [crtools-bot for Kir Kolyshkin ] sockets00: use snprintf()

Cyrill Gorcunov gorcunov at openvz.org
Tue Feb 7 14:59:28 EST 2012


The commit is pushed to "master" and will appear on git://github.com/cyrillos/crtools.git
------>
commit a3fe624c55a5c3428dfe659bbda0a464fb39213e
Author: Kir Kolyshkin <kir at openvz.org>
Date:   Tue Feb 7 23:53:50 2012 +0400

    sockets00: use snprintf()
    
    Way easier this way.
    
    Signed-off-by: Kir Kolyshkin <kir at openvz.org>
    Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 test/zdtm/live/static/sockets00.c |   16 ++++------------
 1 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/test/zdtm/live/static/sockets00.c b/test/zdtm/live/static/sockets00.c
index 929e867..297df03 100644
--- a/test/zdtm/live/static/sockets00.c
+++ b/test/zdtm/live/static/sockets00.c
@@ -56,9 +56,7 @@ int main(int argc, char *argv[])
 		exit(1);
 	}
 
-	memset(path, 0, sizeof(path));
-	strncat(path, cwd, sizeof(path));
-	strncat(path, "/test-socket", sizeof(path));
+	snprintf(path, sizeof(path), "%s/test-socket", cwd);
 	unlink(path);
 
 	addr.sun_family = AF_UNIX;
@@ -110,25 +108,19 @@ int main(int argc, char *argv[])
 		exit(1);
 	}
 
-	memset(path, 0, sizeof(path));
-	strncat(path, cwd, sizeof(path));
-	strncat(path, "/test-socket-bound", sizeof(path));
+	snprintf(path, sizeof(path), "%s/test-socket-bound", cwd);
 	unlink(path);
 
 	name_bound.sun_family = AF_UNIX;
 	strncpy(name_bound.sun_path, path, sizeof(name_bound.sun_path));
 
-	memset(path, 0, sizeof(path));
-	strncat(path, cwd, sizeof(path));
-	strncat(path, "/test-socket-conn", sizeof(path));
+	snprintf(path, sizeof(path), "%s/test-socket-conn", cwd);
 	unlink(path);
 
 	name_conn.sun_family = AF_UNIX;
 	strncpy(name_conn.sun_path, path, sizeof(name_conn.sun_path));
 
-	memset(path, 0, sizeof(path));
-	strncat(path, cwd, sizeof(path));
-	strncat(path, "/test-socket-bound-conn", sizeof(path));
+	snprintf(path, sizeof(path), "%s/test-socket-bound-conn", cwd);
 	unlink(path);
 
 	name_bound_conn.sun_family = AF_UNIX;


More information about the CRIU mailing list