* [PATCH 2/3] befs: remove constant variable
2016-07-01 0:07 [PATCH 1/3] befs: avoid dereferencing dentry twice Luis de Bethencourt
@ 2016-07-01 0:07 ` Luis de Bethencourt
2016-07-28 0:11 ` Salah Triki
2016-07-01 0:07 ` [PATCH 3/3] befs: use simpler while loop Luis de Bethencourt
1 sibling, 1 reply; 4+ messages in thread
From: Luis de Bethencourt @ 2016-07-01 0:07 UTC (permalink / raw)
To: linux-kernel
Cc: akpm, salah.triki, viro, hannes, vdavydov, Luis de Bethencourt
Use macro directly instead of via assigning it to an unchanging variable.
Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
---
fs/befs/linuxvfs.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index 6740b0d..a16421a 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -211,7 +211,6 @@ befs_readdir(struct file *file, struct dir_context *ctx)
befs_off_t value;
int result;
size_t keysize;
- unsigned char d_type;
char keybuf[BEFS_NAME_LEN + 1];
befs_debug(sb, "---> %s name %pD, inode %ld, ctx->pos %lld",
@@ -236,8 +235,6 @@ more:
return 0;
}
- d_type = DT_UNKNOWN;
-
/* Convert to NLS */
if (BEFS_SB(sb)->nls) {
char *nlsname;
@@ -249,14 +246,14 @@ more:
return result;
}
if (!dir_emit(ctx, nlsname, nlsnamelen,
- (ino_t) value, d_type)) {
+ (ino_t) value, DT_UNKNOWN)) {
kfree(nlsname);
return 0;
}
kfree(nlsname);
} else {
if (!dir_emit(ctx, keybuf, keysize,
- (ino_t) value, d_type))
+ (ino_t) value, DT_UNKNOWN))
return 0;
}
ctx->pos++;
--
2.5.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] befs: use simpler while loop
2016-07-01 0:07 [PATCH 1/3] befs: avoid dereferencing dentry twice Luis de Bethencourt
2016-07-01 0:07 ` [PATCH 2/3] befs: remove constant variable Luis de Bethencourt
@ 2016-07-01 0:07 ` Luis de Bethencourt
1 sibling, 0 replies; 4+ messages in thread
From: Luis de Bethencourt @ 2016-07-01 0:07 UTC (permalink / raw)
To: linux-kernel
Cc: akpm, salah.triki, viro, hannes, vdavydov, Luis de Bethencourt
Replace goto with simpler while loop to make befs_readdir() more readable.
Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
---
fs/befs/linuxvfs.c | 74 ++++++++++++++++++++++++++++--------------------------
1 file changed, 38 insertions(+), 36 deletions(-)
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index a16421a..3879048 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 *
--
2.5.1
^ permalink raw reply related [flat|nested] 4+ messages in thread