[PATCH] befs: replace goto with while

From: Daeseok Youn
Date: Mon Apr 14 2014 - 02:05:55 EST



The goto in befs_readdir() can be replaced with while.

And also fix smatch warnings:
fs/befs/linuxvfs.c:283 befs_readdir() info:
ignoring unreachable code.
fs/befs/linuxvfs.c:283 befs_readdir() info:
ignoring unreachable code.

Signed-off-by: Daeseok Youn <daeseok.youn@xxxxxxxxx>
---
fs/befs/linuxvfs.c | 86 +++++++++++++++++++++++++++-------------------------
1 files changed, 45 insertions(+), 41 deletions(-)

diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index d626756..640f8775 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -227,6 +227,7 @@ befs_readdir(struct file *file, struct dir_context *ctx)
befs_data_stream *ds = &BEFS_I(inode)->i_data.ds;
befs_off_t value;
int result;
+ int ret = 0;
size_t keysize;
unsigned char d_type;
char keybuf[BEFS_NAME_LEN + 1];
@@ -235,54 +236,57 @@ befs_readdir(struct file *file, struct dir_context *ctx)
befs_debug(sb, "---> %s name %s, inode %ld, ctx->pos %lld",
__func__, dirname, inode->i_ino, ctx->pos);

-more:
- result = befs_btree_read(sb, ds, ctx->pos, BEFS_NAME_LEN + 1,
- keybuf, &keysize, &value);
+ while (1) {
+ 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 %s (inode %lu)",
- dirname, inode->i_ino);
- return -EIO;
+ if (result == BEFS_ERR) {
+ befs_debug(sb, "<--- %s ERROR", __func__);
+ befs_error(sb, "IO error reading %s (inode %lu)",
+ dirname, inode->i_ino);
+ ret = -EIO;
+ break;

- } else if (result == BEFS_BT_END) {
- befs_debug(sb, "<--- %s END", __func__);
- return 0;
+ } else if (result == BEFS_BT_END) {
+ befs_debug(sb, "<--- %s END", __func__);
+ break;

- } else if (result == BEFS_BT_EMPTY) {
- befs_debug(sb, "<--- %s Empty directory", __func__);
- return 0;
- }
+ } else if (result == BEFS_BT_EMPTY) {
+ befs_debug(sb, "<--- %s Empty directory", __func__);
+ break;
+ }

- d_type = DT_UNKNOWN;
+ d_type = 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, d_type)) {
+ /* 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__);
+ ret = result;
+ break;
+ }
+ if (!dir_emit(ctx, nlsname, nlsnamelen,
+ (ino_t) value, d_type)) {
+ kfree(nlsname);
+ break;
+ }
kfree(nlsname);
- return 0;
+ } else {
+ if (!dir_emit(ctx, keybuf, keysize,
+ (ino_t) value, d_type))
+ break;
}
- kfree(nlsname);
- } else {
- if (!dir_emit(ctx, keybuf, keysize,
- (ino_t) value, d_type))
- return 0;
+ ctx->pos++;
+ befs_debug(sb, "<--- %s pos %lld", __func__, ctx->pos);
}
- ctx->pos++;
- goto more;

- befs_debug(sb, "<--- %s pos %lld", __func__, ctx->pos);
-
- return 0;
+ return ret;
}

static struct inode *
--
1.7.4.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/