Skip to content

Commit 744e6c8

Browse files
author
Darrick J. Wong
committed
xfs: constify xfs_name_dotdot
The symbol xfs_name_dotdot is a global variable that the xfs codebase uses here and there to look up directory dotdot entries. Currently it's a non-const variable, which means that it's a mutable global variable. So far nobody's abused this to cause problems, but let's use the compiler to enforce that. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com>
1 parent 996b232 commit 744e6c8

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

fs/xfs/libxfs/xfs_dir2.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
#include "xfs_error.h"
2020
#include "xfs_trace.h"
2121

22-
struct xfs_name xfs_name_dotdot = { (unsigned char *)"..", 2, XFS_DIR3_FT_DIR };
22+
const struct xfs_name xfs_name_dotdot = {
23+
.name = (const unsigned char *)"..",
24+
.len = 2,
25+
.type = XFS_DIR3_FT_DIR,
26+
};
2327

2428
/*
2529
* Convert inode mode to directory entry filetype

fs/xfs/libxfs/xfs_dir2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct xfs_dir2_data_unused;
2121
struct xfs_dir3_icfree_hdr;
2222
struct xfs_dir3_icleaf_hdr;
2323

24-
extern struct xfs_name xfs_name_dotdot;
24+
extern const struct xfs_name xfs_name_dotdot;
2525

2626
/*
2727
* Convert inode mode to directory entry filetype

0 commit comments

Comments
 (0)