From 7d34cf342e5d11c068f51162bfe50dcdaa0aac59 Mon Sep 17 00:00:00 2001 From: Jacob Malevich Date: Thu, 13 Nov 2014 12:30:26 -0800 Subject: [PATCH] bcacheadm: register bcache ioctl already takes an argv, no need to parse it Change-Id: I0295ebde998c038feb40332ea303935035b8e2bd Signed-off-by: Jacob Malevich --- bcache.c | 24 ++---------------------- bcacheadm.c | 8 +------- 2 files changed, 3 insertions(+), 29 deletions(-) diff --git a/bcache.c b/bcache.c index 444643dc..5d1162f1 100644 --- a/bcache.c +++ b/bcache.c @@ -934,39 +934,19 @@ int list_cachesets(char *cset_dir) return 0; } -char *parse_array_to_list(char *const *args) -{ - int i, len = 0; - char *space = " "; - for(i=0; args[i] != NULL; i++) { - len+=strlen(args[i]) + 1; - } - - char *arg_list = (char*)malloc(sizeof(char)*len); - strcpy(arg_list, args[0]); - strcat(arg_list, space); - - for(i=1; args[i] != NULL; i++) { - strcat(arg_list, args[i]); - strcat(arg_list, space); - } - - return arg_list; -} - int register_bcache(char *devs) { int ret, bcachefd; bcachefd = open("/dev/bcache", O_RDWR); if (bcachefd < 0) { - perror("Can't open bcache device"); + perror("Can't open bcache device\n"); exit(EXIT_FAILURE); } ret = ioctl(bcachefd, BCH_IOCTL_REGISTER, devs); if (ret < 0) { - fprintf(stderr, "ioctl register error: %s", strerror(ret)); + fprintf(stderr, "ioctl register error: %s\n", strerror(ret)); exit(EXIT_FAILURE); } return 0; diff --git a/bcacheadm.c b/bcacheadm.c index e0cccb89..64ebb6b2 100644 --- a/bcacheadm.c +++ b/bcacheadm.c @@ -345,13 +345,7 @@ int probe_bcache (NihCommand *command, char *const *args) int bcache_register (NihCommand *command, char *const *args) { - int ret; - char *arg_list = parse_array_to_list(args); - - if(arg_list) { - ret = register_bcache(arg_list); - free(arg_list); - } + int ret = register_bcache(args); return ret; }