btrfs-progs: check: fix missing newlines
[platform/upstream/btrfs-progs.git] / cmds-device.c
index 7616c43..fa0830f 100644 (file)
@@ -107,8 +107,9 @@ static int cmd_device_add(int argc, char **argv)
                        continue;
                }
 
-               res = btrfs_prepare_device(devfd, argv[i], 1, &dev_block_count,
-                                          0, discard);
+               res = btrfs_prepare_device(devfd, argv[i], &dev_block_count, 0,
+                               PREP_DEVICE_ZERO_END | PREP_DEVICE_VERBOSE |
+                               (discard ? PREP_DEVICE_DISCARD : 0));
                close(devfd);
                if (res) {
                        ret++;
@@ -257,7 +258,6 @@ static int cmd_device_scan(int argc, char **argv)
        int all = 0;
        int ret = 0;
 
-       optind = 1;
        while (1) {
                int c;
                static const struct option long_options[] = {
@@ -283,7 +283,7 @@ static int cmd_device_scan(int argc, char **argv)
 
        if (all || argc - optind == 0) {
                printf("Scanning for Btrfs filesystems\n");
-               ret = btrfs_scan_lblkid();
+               ret = btrfs_scan_devices();
                error_on(ret, "error %d while scanning", ret);
                ret = btrfs_register_all_devices();
                error_on(ret, "there are %d errors while registering devices", ret);
@@ -333,7 +333,7 @@ static int cmd_device_ready(int argc, char **argv)
 
        clean_args_no_options(argc, argv, cmd_device_ready_usage);
 
-       if (check_argc_min(argc - optind, 1))
+       if (check_argc_exact(argc - optind, 1))
                usage(cmd_device_ready_usage);
 
        fd = open("/dev/btrfs-control", O_RDWR);
@@ -392,7 +392,6 @@ static int cmd_device_stats(int argc, char **argv)
        __u64 flags = 0;
        DIR *dirstream = NULL;
 
-       optind = 1;
        while ((c = getopt(argc, argv, "z")) != -1) {
                switch (c) {
                case 'z':
@@ -450,6 +449,10 @@ static int cmd_device_stats(int argc, char **argv)
                        /* No path when device is missing. */
                        if (!canonical_path) {
                                canonical_path = malloc(32);
+                               if (!canonical_path) {
+                                       error("not enough memory for path buffer");
+                                       goto out;
+                               }
                                snprintf(canonical_path, 32,
                                         "devid:%llu", args.devid);
                        }