Skip to content

Commit

Permalink
xfs: constify xfs_name_dotdot
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Darrick J. Wong committed Mar 14, 2022
1 parent 996b232 commit 744e6c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion fs/xfs/libxfs/xfs_dir2.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
#include "xfs_error.h"
#include "xfs_trace.h"

struct xfs_name xfs_name_dotdot = { (unsigned char *)"..", 2, XFS_DIR3_FT_DIR };
const struct xfs_name xfs_name_dotdot = {
.name = (const unsigned char *)"..",
.len = 2,
.type = XFS_DIR3_FT_DIR,
};

/*
* Convert inode mode to directory entry filetype
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/libxfs/xfs_dir2.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct xfs_dir2_data_unused;
struct xfs_dir3_icfree_hdr;
struct xfs_dir3_icleaf_hdr;

extern struct xfs_name xfs_name_dotdot;
extern const struct xfs_name xfs_name_dotdot;

/*
* Convert inode mode to directory entry filetype
Expand Down

0 comments on commit 744e6c8

Please sign in to comment.