diff options
author | David Sterba <dsterba@suse.com> | 2015-11-06 16:53:55 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2015-11-06 16:53:55 +0100 |
commit | 4e01c34b8bf06268a515b7ffe83e905b0a02ef38 (patch) | |
tree | 391f12e7fcab1172ef3326579d27c39e4b77b3de | |
parent | 49e0f3e6466db78fb6c12f71e0c46be4b1492d90 (diff) |
btrfs-progs: simplify empty stirngs check
We can do a strlen(str) == 0 in a simpler way.
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | btrfs-convert.c | 2 | ||||
-rw-r--r-- | btrfs-corrupt-block.c | 8 | ||||
-rw-r--r-- | cmds-filesystem.c | 6 | ||||
-rw-r--r-- | cmds-receive.c | 8 | ||||
-rw-r--r-- | string-table.c | 2 | ||||
-rw-r--r-- | utils.c | 2 |
6 files changed, 14 insertions, 14 deletions
diff --git a/btrfs-convert.c b/btrfs-convert.c index 5b9171ee..02e5cdba 100644 --- a/btrfs-convert.c +++ b/btrfs-convert.c @@ -1449,7 +1449,7 @@ static struct btrfs_root * link_subvol(struct btrfs_root *root, int ret; len = strlen(base); - if (len < 1 || len > BTRFS_NAME_LEN) + if (len == 0 || len > BTRFS_NAME_LEN) return NULL; path = btrfs_alloc_path(); diff --git a/btrfs-corrupt-block.c b/btrfs-corrupt-block.c index ee2093fa..0287f0bc 100644 --- a/btrfs-corrupt-block.c +++ b/btrfs-corrupt-block.c @@ -1217,7 +1217,7 @@ int main(int ac, char **av) if (inode) { struct btrfs_trans_handle *trans; - if (!strlen(field)) + if (*field == 0) print_usage(1); trans = btrfs_start_transaction(root, 1); @@ -1233,13 +1233,13 @@ int main(int ac, char **av) goto out_close; } if (metadata_block) { - if (!strlen(field)) + if (*field == 0) print_usage(1); ret = corrupt_metadata_block(root, metadata_block, field); goto out_close; } if (corrupt_di) { - if (!key.objectid || !strlen(field)) + if (!key.objectid || *field == 0) print_usage(1); ret = corrupt_dir_item(root, &key, field); goto out_close; @@ -1276,7 +1276,7 @@ int main(int ac, char **av) goto out_close; } if (key.objectid || key.offset || key.type) { - if (!strlen(field)) + if (*field == 0) print_usage(1); ret = corrupt_key(root, &key, field); goto out_close; diff --git a/cmds-filesystem.c b/cmds-filesystem.c index 98c13f56..3bd6304d 100644 --- a/cmds-filesystem.c +++ b/cmds-filesystem.c @@ -233,7 +233,7 @@ static int match_search_item_kernel(__u8 *fsid, char *mnt, char *label, if (!strncmp(uuidbuf, search, search_len)) return 1; - if (strlen(label) && strcmp(label, search) == 0) + if (*label && strcmp(label, search) == 0) return 1; if (strcmp(mnt, search) == 0) @@ -403,7 +403,7 @@ static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info, return ret; uuid_unparse(fs_info->fsid, uuidbuf); - if (label && strlen(label)) + if (label && *label) printf("Label: '%s' ", label); else printf("Label: none "); @@ -823,7 +823,7 @@ static int cmd_filesystem_show(int argc, char **argv) if (argc > optind) { search = argv[optind]; - if (strlen(search) == 0) + if (*search == 0) usage(cmd_filesystem_show_usage); type = check_arg_type(search); diff --git a/cmds-receive.c b/cmds-receive.c index 1d7d897f..3a84a3bf 100644 --- a/cmds-receive.c +++ b/cmds-receive.c @@ -169,7 +169,7 @@ static int process_subvol(const char *path, const u8 *uuid, u64 ctransid, BUG_ON(r->cur_subvol.path); BUG_ON(r->cur_subvol_path[0]); - if (strlen(r->dest_dir_path) == 0) { + if (*r->dest_dir_path == 0) { strncpy_null(r->cur_subvol_path, path); } else { ret = path_cat_out(r->cur_subvol_path, r->dest_dir_path, path); @@ -229,7 +229,7 @@ static int process_snapshot(const char *path, const u8 *uuid, u64 ctransid, BUG_ON(r->cur_subvol.path); BUG_ON(r->cur_subvol_path[0]); - if (strlen(r->dest_dir_path) == 0) { + if (*r->dest_dir_path == 0) { strncpy_null(r->cur_subvol_path, path); } else { ret = path_cat_out(r->cur_subvol_path, r->dest_dir_path, path); @@ -326,7 +326,7 @@ static int process_snapshot(const char *path, const u8 *uuid, u64 ctransid, } }*/ - if (strlen(parent_subvol->path) == 0) + if (*parent_subvol->path == 0) args_v2.fd = dup(r->mnt_fd); else args_v2.fd = openat(r->mnt_fd, parent_subvol->path, @@ -1135,7 +1135,7 @@ static int do_receive(struct btrfs_receive *r, const char *tomnt, * Ok we're inside of a subvol off of the root subvol, we need to * actually set full_root_path. */ - if (strlen(root_subvol_path)) + if (*root_subvol_path) r->full_root_path = root_subvol_path; if (r->dest_dir_chroot) { diff --git a/string-table.c b/string-table.c index 7e01412d..fc9d51ee 100644 --- a/string-table.c +++ b/string-table.c @@ -101,7 +101,7 @@ void table_dump(struct string_table *tab) continue; len = strlen(tab->cells[idx]) - 1; - if (len < 1 || tab->cells[idx][0] == '*') + if (len == 0 || tab->cells[idx][0] == '*') continue; if (len > sizes[i]) @@ -1516,7 +1516,7 @@ int btrfs_register_all_devices(void) list_for_each_entry(fs_devices, all_uuids, list) { list_for_each_entry(device, &fs_devices->devices, dev_list) { - if (strlen(device->name) != 0) { + if (*device->name) { err = btrfs_register_one_device(device->name); if (err < 0) return err; |