diff options
author | Luis de Bethencourt | 2016-07-01 01:07:32 +0100 |
---|---|---|
committer | Luis de Bethencourt | 2016-10-08 10:01:16 +0100 |
commit | 9ae51a32b1a060d2db4340d853d989ae622d273f (patch) | |
tree | f8e6ad4f541f9b3278426959411c163409b39e43 /fs/befs | |
parent | 50858ef96deeeeeb36b2113d49007f41d0410763 (diff) |
befs: use simpler while loop
Replace goto with simpler while loop to make befs_readdir() more readable.
Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
Diffstat (limited to 'fs/befs')
-rw-r--r-- | fs/befs/linuxvfs.c | 74 |
1 files changed, 38 insertions, 36 deletions
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index 516a958ba50e..e0979a471e84 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c @@ -216,48 +216,50 @@ befs_readdir(struct file *file, struct dir_context *ctx) befs_debug(sb, "---> %s name %pD, inode %ld, ctx->pos %lld", __func__, file, inode->i_ino, ctx->pos); -more: - result = befs_btree_read(sb, ds, ctx->pos, BEFS_NAME_LEN + 1, - keybuf, &keysize, &value); - - if (result == BEFS_ERR) { - befs_debug(sb, "<--- %s ERROR", __func__); - befs_error(sb, "IO error reading %pD (inode %lu)", - file, inode->i_ino); - return -EIO; - - } else if (result == BEFS_BT_END) { - befs_debug(sb, "<--- %s END", __func__); - return 0; - - } else if (result == BEFS_BT_EMPTY) { - befs_debug(sb, "<--- %s Empty directory", __func__); - return 0; - } + while (1) { + result = befs_btree_read(sb, ds, ctx->pos, BEFS_NAME_LEN + 1, + keybuf, &keysize, &value); - /* Convert to NLS */ - if (BEFS_SB(sb)->nls) { - char *nlsname; - int nlsnamelen; - result = - befs_utf2nls(sb, keybuf, keysize, &nlsname, &nlsnamelen); - if (result < 0) { + if (result == BEFS_ERR) { befs_debug(sb, "<--- %s ERROR", __func__); - return result; + befs_error(sb, "IO error reading %pD (inode %lu)", + file, inode->i_ino); + return -EIO; + + } else if (result == BEFS_BT_END) { + befs_debug(sb, "<--- %s END", __func__); + return 0; + + } else if (result == BEFS_BT_EMPTY) { + befs_debug(sb, "<--- %s Empty directory", __func__); + return 0; } - if (!dir_emit(ctx, nlsname, nlsnamelen, - (ino_t) value, DT_UNKNOWN)) { + + /* Convert to NLS */ + if (BEFS_SB(sb)->nls) { + char *nlsname; + int nlsnamelen; + + result = + befs_utf2nls(sb, keybuf, keysize, &nlsname, + &nlsnamelen); + if (result < 0) { + befs_debug(sb, "<--- %s ERROR", __func__); + return result; + } + if (!dir_emit(ctx, nlsname, nlsnamelen, + (ino_t) value, DT_UNKNOWN)) { + kfree(nlsname); + return 0; + } kfree(nlsname); - return 0; + } else { + if (!dir_emit(ctx, keybuf, keysize, + (ino_t) value, DT_UNKNOWN)) + return 0; } - kfree(nlsname); - } else { - if (!dir_emit(ctx, keybuf, keysize, - (ino_t) value, DT_UNKNOWN)) - return 0; + ctx->pos++; } - ctx->pos++; - goto more; } static struct inode * |