Skip to content

Commit cafc667

Browse files
cla7aye15I4ndkleikamp
authored andcommitted
jfs: replace hardcoded magic number with DTPAGEMAXSLOT constant
Replace hardcoded value 127 with DTPAGEMAXSLOT constant in boundary checks within jfs_readdir() and dtReadFirst(). This improves code maintainability and ensures consistency with the defined maximum slot value. Signed-off-by: Zheng Yu <zheng.yu@northwestern.edu> Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
1 parent e551cc2 commit cafc667

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

fs/jfs/jfs_dtree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2903,7 +2903,7 @@ int jfs_readdir(struct file *file, struct dir_context *ctx)
29032903
stbl = DT_GETSTBL(p);
29042904

29052905
for (i = index; i < p->header.nextindex; i++) {
2906-
if (stbl[i] < 0 || stbl[i] > 127) {
2906+
if (stbl[i] < 0 || stbl[i] >= DTPAGEMAXSLOT) {
29072907
jfs_err("JFS: Invalid stbl[%d] = %d for inode %ld, block = %lld",
29082908
i, stbl[i], (long)ip->i_ino, (long long)bn);
29092909
free_page(dirent_buf);
@@ -3108,7 +3108,7 @@ static int dtReadFirst(struct inode *ip, struct btstack * btstack)
31083108
/* get the leftmost entry */
31093109
stbl = DT_GETSTBL(p);
31103110

3111-
if (stbl[0] < 0 || stbl[0] > 127) {
3111+
if (stbl[0] < 0 || stbl[0] >= DTPAGEMAXSLOT) {
31123112
DT_PUTPAGE(mp);
31133113
jfs_error(ip->i_sb, "stbl[0] out of bound\n");
31143114
return -EIO;

0 commit comments

Comments
 (0)