Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xfs: constify the name argument to various directory functions

Various directory functions do not modify their @name parameter,
so mark it const to make that clear. This will enable us to mark
the global xfs_name_dotdot variable as const to prevent mischief.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>

+27 -26
+15 -15
fs/xfs/libxfs/xfs_dir2.c
··· 54 54 */ 55 55 xfs_dahash_t 56 56 xfs_ascii_ci_hashname( 57 - struct xfs_name *name) 57 + const struct xfs_name *name) 58 58 { 59 - xfs_dahash_t hash; 60 - int i; 59 + xfs_dahash_t hash; 60 + int i; 61 61 62 62 for (i = 0, hash = 0; i < name->len; i++) 63 63 hash = tolower(name->name[i]) ^ rol32(hash, 7); ··· 243 243 xfs_dir_createname( 244 244 struct xfs_trans *tp, 245 245 struct xfs_inode *dp, 246 - struct xfs_name *name, 246 + const struct xfs_name *name, 247 247 xfs_ino_t inum, /* new entry inode number */ 248 248 xfs_extlen_t total) /* bmap's total block count */ 249 249 { ··· 337 337 338 338 int 339 339 xfs_dir_lookup( 340 - xfs_trans_t *tp, 341 - xfs_inode_t *dp, 342 - struct xfs_name *name, 343 - xfs_ino_t *inum, /* out: inode number */ 344 - struct xfs_name *ci_name) /* out: actual name if CI match */ 340 + struct xfs_trans *tp, 341 + struct xfs_inode *dp, 342 + const struct xfs_name *name, 343 + xfs_ino_t *inum, /* out: inode number */ 344 + struct xfs_name *ci_name) /* out: actual name if CI match */ 345 345 { 346 - struct xfs_da_args *args; 347 - int rval; 348 - int v; /* type-checking value */ 349 - int lock_mode; 346 + struct xfs_da_args *args; 347 + int rval; 348 + int v; /* type-checking value */ 349 + int lock_mode; 350 350 351 351 ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); 352 352 XFS_STATS_INC(dp->i_mount, xs_dir_lookup); ··· 475 475 xfs_dir_replace( 476 476 struct xfs_trans *tp, 477 477 struct xfs_inode *dp, 478 - struct xfs_name *name, /* name of entry to replace */ 478 + const struct xfs_name *name, /* name of entry to replace */ 479 479 xfs_ino_t inum, /* new inode number */ 480 480 xfs_extlen_t total) /* bmap's total block count */ 481 481 { ··· 728 728 xfs_dahash_t 729 729 xfs_dir2_hashname( 730 730 struct xfs_mount *mp, 731 - struct xfs_name *name) 731 + const struct xfs_name *name) 732 732 { 733 733 if (unlikely(xfs_has_asciici(mp))) 734 734 return xfs_ascii_ci_hashname(name);
+3 -3
fs/xfs/libxfs/xfs_dir2.h
··· 39 39 extern int xfs_dir_init(struct xfs_trans *tp, struct xfs_inode *dp, 40 40 struct xfs_inode *pdp); 41 41 extern int xfs_dir_createname(struct xfs_trans *tp, struct xfs_inode *dp, 42 - struct xfs_name *name, xfs_ino_t inum, 42 + const struct xfs_name *name, xfs_ino_t inum, 43 43 xfs_extlen_t tot); 44 44 extern int xfs_dir_lookup(struct xfs_trans *tp, struct xfs_inode *dp, 45 - struct xfs_name *name, xfs_ino_t *inum, 45 + const struct xfs_name *name, xfs_ino_t *inum, 46 46 struct xfs_name *ci_name); 47 47 extern int xfs_dir_removename(struct xfs_trans *tp, struct xfs_inode *dp, 48 48 struct xfs_name *name, xfs_ino_t ino, 49 49 xfs_extlen_t tot); 50 50 extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp, 51 - struct xfs_name *name, xfs_ino_t inum, 51 + const struct xfs_name *name, xfs_ino_t inum, 52 52 xfs_extlen_t tot); 53 53 extern int xfs_dir_canenter(struct xfs_trans *tp, struct xfs_inode *dp, 54 54 struct xfs_name *name);
+3 -2
fs/xfs/libxfs/xfs_dir2_priv.h
··· 40 40 }; 41 41 42 42 /* xfs_dir2.c */ 43 - xfs_dahash_t xfs_ascii_ci_hashname(struct xfs_name *name); 43 + xfs_dahash_t xfs_ascii_ci_hashname(const struct xfs_name *name); 44 44 enum xfs_dacmp xfs_ascii_ci_compname(struct xfs_da_args *args, 45 45 const unsigned char *name, int len); 46 46 extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space, ··· 201 201 return round_up(len, XFS_DIR2_DATA_ALIGN); 202 202 } 203 203 204 - xfs_dahash_t xfs_dir2_hashname(struct xfs_mount *mp, struct xfs_name *name); 204 + xfs_dahash_t xfs_dir2_hashname(struct xfs_mount *mp, 205 + const struct xfs_name *name); 205 206 enum xfs_dacmp xfs_dir2_compname(struct xfs_da_args *args, 206 207 const unsigned char *name, int len); 207 208
+3 -3
fs/xfs/xfs_inode.c
··· 658 658 */ 659 659 int 660 660 xfs_lookup( 661 - xfs_inode_t *dp, 662 - struct xfs_name *name, 663 - xfs_inode_t **ipp, 661 + struct xfs_inode *dp, 662 + const struct xfs_name *name, 663 + struct xfs_inode **ipp, 664 664 struct xfs_name *ci_name) 665 665 { 666 666 xfs_ino_t inum;
+1 -1
fs/xfs/xfs_inode.h
··· 402 402 403 403 int xfs_release(struct xfs_inode *ip); 404 404 void xfs_inactive(struct xfs_inode *ip); 405 - int xfs_lookup(struct xfs_inode *dp, struct xfs_name *name, 405 + int xfs_lookup(struct xfs_inode *dp, const struct xfs_name *name, 406 406 struct xfs_inode **ipp, struct xfs_name *ci_name); 407 407 int xfs_create(struct user_namespace *mnt_userns, 408 408 struct xfs_inode *dp, struct xfs_name *name,
+2 -2
fs/xfs/xfs_trace.h
··· 933 933 DEFINE_IREF_EVENT(xfs_inode_unpin_nowait); 934 934 935 935 DECLARE_EVENT_CLASS(xfs_namespace_class, 936 - TP_PROTO(struct xfs_inode *dp, struct xfs_name *name), 936 + TP_PROTO(struct xfs_inode *dp, const struct xfs_name *name), 937 937 TP_ARGS(dp, name), 938 938 TP_STRUCT__entry( 939 939 __field(dev_t, dev) ··· 956 956 957 957 #define DEFINE_NAMESPACE_EVENT(name) \ 958 958 DEFINE_EVENT(xfs_namespace_class, name, \ 959 - TP_PROTO(struct xfs_inode *dp, struct xfs_name *name), \ 959 + TP_PROTO(struct xfs_inode *dp, const struct xfs_name *name), \ 960 960 TP_ARGS(dp, name)) 961 961 DEFINE_NAMESPACE_EVENT(xfs_remove); 962 962 DEFINE_NAMESPACE_EVENT(xfs_link);