Commit 77e5da8e by 2xsec

tools: lxc-create: remove the trailing . & fix coding style of strncmp

Signed-off-by: 's avatar2xsec <dh48.jeong@samsung.com>
parent 5dec9c3e
...@@ -62,7 +62,8 @@ static uint64_t get_fssize(char *s) ...@@ -62,7 +62,8 @@ static uint64_t get_fssize(char *s)
ret *= 1024ULL * 1024ULL * 1024ULL; ret *= 1024ULL * 1024ULL * 1024ULL;
else if (*end == 't' || *end == 'T') else if (*end == 't' || *end == 'T')
ret *= 1024ULL * 1024ULL * 1024ULL * 1024ULL; ret *= 1024ULL * 1024ULL * 1024ULL * 1024ULL;
else { else
{
ERROR("Invalid blockdev unit size '%c' in '%s', using default size", *end, s); ERROR("Invalid blockdev unit size '%c' in '%s', using default size", *end, s);
return 0; return 0;
} }
...@@ -176,31 +177,31 @@ Options :\n\ ...@@ -176,31 +177,31 @@ Options :\n\
static bool validate_bdev_args(struct lxc_arguments *a) static bool validate_bdev_args(struct lxc_arguments *a)
{ {
if (strncmp(a->bdevtype, "best", strlen(a->bdevtype))) { if (strncmp(a->bdevtype, "best", strlen(a->bdevtype)) != 0) {
if (a->fstype || a->fssize) { if (a->fstype || a->fssize) {
if (strncmp(a->bdevtype, "lvm", strlen(a->bdevtype)) && if (strncmp(a->bdevtype, "lvm", strlen(a->bdevtype)) != 0 &&
strncmp(a->bdevtype, "loop", strlen(a->bdevtype)) && strncmp(a->bdevtype, "loop", strlen(a->bdevtype)) != 0 &&
strncmp(a->bdevtype, "rbd", strlen(a->bdevtype))) { strncmp(a->bdevtype, "rbd", strlen(a->bdevtype)) != 0) {
ERROR("Filesystem type and size are only valid with block devices"); ERROR("Filesystem type and size are only valid with block devices");
return false; return false;
} }
} }
if (strncmp(a->bdevtype, "lvm", strlen(a->bdevtype))) { if (strncmp(a->bdevtype, "lvm", strlen(a->bdevtype)) != 0) {
if (a->lvname || a->vgname || a->thinpool) { if (a->lvname || a->vgname || a->thinpool) {
ERROR("--lvname, --vgname and --thinpool are only valid with -B lvm"); ERROR("--lvname, --vgname and --thinpool are only valid with -B lvm");
return false; return false;
} }
} }
if (strncmp(a->bdevtype, "rbd", strlen(a->bdevtype))) { if (strncmp(a->bdevtype, "rbd", strlen(a->bdevtype)) != 0) {
if (a->rbdname || a->rbdpool) { if (a->rbdname || a->rbdpool) {
ERROR("--rbdname and --rbdpool are only valid with -B rbd"); ERROR("--rbdname and --rbdpool are only valid with -B rbd");
return false; return false;
} }
} }
if (strncmp(a->bdevtype, "zfs", strlen(a->bdevtype))) { if (strncmp(a->bdevtype, "zfs", strlen(a->bdevtype)) != 0) {
if (a->zfsroot) { if (a->zfsroot) {
ERROR("zfsroot is only valid with -B zfs"); ERROR("zfsroot is only valid with -B zfs");
return false; return false;
...@@ -254,12 +255,12 @@ int main(int argc, char *argv[]) ...@@ -254,12 +255,12 @@ int main(int argc, char *argv[])
} }
if (!my_args.template) { if (!my_args.template) {
ERROR("A template must be specified."); ERROR("A template must be specified");
ERROR("Use \"none\" if you really want a container without a rootfs."); ERROR("Use \"none\" if you really want a container without a rootfs");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (!strncmp(my_args.template, "none", strlen(my_args.template))) if (strncmp(my_args.template, "none", strlen(my_args.template)) == 0)
my_args.template = NULL; my_args.template = NULL;
if (!my_args.bdevtype) if (!my_args.bdevtype)
...@@ -268,14 +269,14 @@ int main(int argc, char *argv[]) ...@@ -268,14 +269,14 @@ int main(int argc, char *argv[])
if (!validate_bdev_args(&my_args)) if (!validate_bdev_args(&my_args))
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
if (!strncmp(my_args.bdevtype, "none", strlen(my_args.bdevtype))) if (strncmp(my_args.bdevtype, "none", strlen(my_args.bdevtype)) == 0)
my_args.bdevtype = "dir"; my_args.bdevtype = "dir";
/* Final check whether the user gave use a valid bdev type. */ /* Final check whether the user gave use a valid bdev type. */
if (strncmp(my_args.bdevtype, "best", strlen(my_args.bdevtype)) && if (strncmp(my_args.bdevtype, "best", strlen(my_args.bdevtype)) != 0 &&
strncmp(my_args.bdevtype, "_unset", strlen(my_args.bdevtype)) && strncmp(my_args.bdevtype, "_unset", strlen(my_args.bdevtype)) != 0 &&
!is_valid_storage_type(my_args.bdevtype)) { !is_valid_storage_type(my_args.bdevtype)) {
ERROR("%s is not a valid backing storage type.", my_args.bdevtype); ERROR("%s is not a valid backing storage type", my_args.bdevtype);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
...@@ -293,7 +294,7 @@ int main(int argc, char *argv[]) ...@@ -293,7 +294,7 @@ int main(int argc, char *argv[])
c = lxc_container_new(my_args.name, my_args.lxcpath[0]); c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
if (!c) { if (!c) {
ERROR("Failed to create lxc container."); ERROR("Failed to create lxc container");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
...@@ -316,14 +317,14 @@ int main(int argc, char *argv[]) ...@@ -316,14 +317,14 @@ int main(int argc, char *argv[])
if (my_args.fssize) if (my_args.fssize)
spec.fssize = my_args.fssize; spec.fssize = my_args.fssize;
if ((!strncmp(my_args.bdevtype, "zfs", strlen(my_args.bdevtype))) || if ((strncmp(my_args.bdevtype, "zfs", strlen(my_args.bdevtype)) == 0) ||
(!strncmp(my_args.bdevtype, "best", strlen(my_args.bdevtype)))) { (strncmp(my_args.bdevtype, "best", strlen(my_args.bdevtype)) == 0)) {
if (my_args.zfsroot) if (my_args.zfsroot)
spec.zfs.zfsroot = my_args.zfsroot; spec.zfs.zfsroot = my_args.zfsroot;
} }
if ((!strncmp(my_args.bdevtype, "lvm", strlen(my_args.bdevtype))) || if ((strncmp(my_args.bdevtype, "lvm", strlen(my_args.bdevtype)) == 0) ||
(!strncmp(my_args.bdevtype, "best", strlen(my_args.bdevtype)))) { (strncmp(my_args.bdevtype, "best", strlen(my_args.bdevtype)) == 0)) {
if (my_args.lvname) if (my_args.lvname)
spec.lvm.lv = my_args.lvname; spec.lvm.lv = my_args.lvname;
...@@ -334,8 +335,8 @@ int main(int argc, char *argv[]) ...@@ -334,8 +335,8 @@ int main(int argc, char *argv[])
spec.lvm.thinpool = my_args.thinpool; spec.lvm.thinpool = my_args.thinpool;
} }
if ((!strncmp(my_args.bdevtype, "rbd", strlen(my_args.bdevtype))) || if ((strncmp(my_args.bdevtype, "rbd", strlen(my_args.bdevtype)) == 0) ||
(!strncmp(my_args.bdevtype, "best", strlen(my_args.bdevtype)))) { (strncmp(my_args.bdevtype, "best", strlen(my_args.bdevtype)) == 0)) {
if (my_args.rbdname) if (my_args.rbdname)
spec.rbd.rbdname = my_args.rbdname; spec.rbd.rbdname = my_args.rbdname;
...@@ -346,7 +347,7 @@ int main(int argc, char *argv[]) ...@@ -346,7 +347,7 @@ int main(int argc, char *argv[])
if (my_args.dir) if (my_args.dir)
spec.dir = my_args.dir; spec.dir = my_args.dir;
if (!strncmp(my_args.bdevtype, "_unset", strlen(my_args.bdevtype))) if (strncmp(my_args.bdevtype, "_unset", strlen(my_args.bdevtype)) == 0)
my_args.bdevtype = NULL; my_args.bdevtype = NULL;
if (my_args.quiet) if (my_args.quiet)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment