Skip to content

Commit f3fe395

Browse files
YuezhangMonamjaejeon
authored andcommitted
exfat: replace magic numbers with Macros
Code refinement, no functional changes. Signed-off-by: Yuezhang Mo <[email protected]> Reviewed-by: Andy Wu <[email protected]> Reviewed-by: Aoyama Wataru <[email protected]> Reviewed-by: Sungjong Seo <[email protected]> Signed-off-by: Namjae Jeon <[email protected]>
1 parent 3b9681a commit f3fe395

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

fs/exfat/dir.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static void exfat_get_uniname_from_ext_entry(struct super_block *sb,
4444
* Third entry : first file-name entry
4545
* So, the index of first file-name dentry should start from 2.
4646
*/
47-
for (i = 2; i < es.num_entries; i++) {
47+
for (i = ES_IDX_FIRST_FILENAME; i < es.num_entries; i++) {
4848
struct exfat_dentry *ep = exfat_get_dentry_cached(&es, i);
4949

5050
/* end of name entry */
@@ -336,7 +336,7 @@ int exfat_calc_num_entries(struct exfat_uni_name *p_uniname)
336336
return -EINVAL;
337337

338338
/* 1 file entry + 1 stream entry + name entries */
339-
return ((len - 1) / EXFAT_FILE_NAME_LEN + 3);
339+
return ES_ENTRY_NUM(len);
340340
}
341341

342342
unsigned int exfat_get_entry_type(struct exfat_dentry *ep)
@@ -591,13 +591,13 @@ void exfat_update_dir_chksum_with_entry_set(struct exfat_entry_set_cache *es)
591591
unsigned short chksum = 0;
592592
struct exfat_dentry *ep;
593593

594-
for (i = 0; i < es->num_entries; i++) {
594+
for (i = ES_IDX_FILE; i < es->num_entries; i++) {
595595
ep = exfat_get_dentry_cached(es, i);
596596
chksum = exfat_calc_chksum16(ep, DENTRY_SIZE, chksum,
597597
chksum_type);
598598
chksum_type = CS_DEFAULT;
599599
}
600-
ep = exfat_get_dentry_cached(es, 0);
600+
ep = exfat_get_dentry_cached(es, ES_IDX_FILE);
601601
ep->dentry.file.checksum = cpu_to_le16(chksum);
602602
es->modified = true;
603603
}
@@ -858,7 +858,7 @@ int exfat_get_dentry_set(struct exfat_entry_set_cache *es,
858858
return -EIO;
859859
es->bh[es->num_bh++] = bh;
860860

861-
ep = exfat_get_dentry_cached(es, 0);
861+
ep = exfat_get_dentry_cached(es, ES_IDX_FILE);
862862
if (!exfat_validate_entry(exfat_get_entry_type(ep), &mode))
863863
goto put_es;
864864

@@ -895,7 +895,7 @@ int exfat_get_dentry_set(struct exfat_entry_set_cache *es,
895895
}
896896

897897
/* validate cached dentries */
898-
for (i = 1; i < num_entries; i++) {
898+
for (i = ES_IDX_STREAM; i < num_entries; i++) {
899899
ep = exfat_get_dentry_cached(es, i);
900900
if (!exfat_validate_entry(exfat_get_entry_type(ep), &mode))
901901
goto put_es;

fs/exfat/inode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ int __exfat_write_inode(struct inode *inode, int sync)
4444
/* get the directory entry of given file or directory */
4545
if (exfat_get_dentry_set(&es, sb, &(ei->dir), ei->entry, ES_ALL_ENTRIES))
4646
return -EIO;
47-
ep = exfat_get_dentry_cached(&es, 0);
48-
ep2 = exfat_get_dentry_cached(&es, 1);
47+
ep = exfat_get_dentry_cached(&es, ES_IDX_FILE);
48+
ep2 = exfat_get_dentry_cached(&es, ES_IDX_STREAM);
4949

5050
ep->dentry.file.attr = cpu_to_le16(exfat_make_attr(inode));
5151

fs/exfat/namei.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,8 @@ static int exfat_find(struct inode *dir, struct qstr *qname,
646646
dentry = hint_opt.eidx;
647647
if (exfat_get_dentry_set(&es, sb, &cdir, dentry, ES_2_ENTRIES))
648648
return -EIO;
649-
ep = exfat_get_dentry_cached(&es, 0);
650-
ep2 = exfat_get_dentry_cached(&es, 1);
649+
ep = exfat_get_dentry_cached(&es, ES_IDX_FILE);
650+
ep2 = exfat_get_dentry_cached(&es, ES_IDX_STREAM);
651651

652652
info->type = exfat_get_entry_type(ep);
653653
info->attr = le16_to_cpu(ep->dentry.file.attr);

0 commit comments

Comments
 (0)