mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
Throw const on some strings
In C, const indicates to the reader that mutation will not occur. It can also serve as a hint about ownership. Add const in a few places where it makes sense. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org> Closes #10997
This commit is contained in:
committed by
Brian Behlendorf
parent
a09e3a8594
commit
47e3dba972
@@ -1327,7 +1327,7 @@ zfsctl_umount_snapshots(vfs_t *vfsp, int fflags, cred_t *cr)
|
||||
}
|
||||
|
||||
int
|
||||
zfsctl_snapshot_unmount(char *snapname, int flags __unused)
|
||||
zfsctl_snapshot_unmount(const char *snapname, int flags __unused)
|
||||
{
|
||||
vfs_t *vfsp = NULL;
|
||||
zfsvfs_t *zfsvfs = NULL;
|
||||
|
||||
@@ -104,14 +104,6 @@ VFS_SMR_DECLARE;
|
||||
#define vm_page_wire_unlock(pp) vm_page_unlock(pp)
|
||||
#endif
|
||||
|
||||
static int
|
||||
zfs_u8_validate(const char *u8str, size_t n, char **list, int flag, int *errnum)
|
||||
{
|
||||
|
||||
return (u8_validate(__DECONST(char *, u8str), n, list, flag, errnum));
|
||||
}
|
||||
#define u8_validate zfs_u8_validate
|
||||
|
||||
#ifdef DEBUG_VFS_LOCKS
|
||||
#define VNCHECKREF(vp) \
|
||||
VNASSERT((vp)->v_holdcnt > 0 && (vp)->v_usecount > 0, vp, \
|
||||
@@ -1536,8 +1528,9 @@ zfs_lookup_lock(vnode_t *dvp, vnode_t *vp, const char *name, int lkflags)
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
zfs_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, struct componentname *cnp,
|
||||
int nameiop, cred_t *cr, kthread_t *td, int flags, boolean_t cached)
|
||||
zfs_lookup(vnode_t *dvp, const char *nm, vnode_t **vpp,
|
||||
struct componentname *cnp, int nameiop, cred_t *cr, kthread_t *td,
|
||||
int flags, boolean_t cached)
|
||||
{
|
||||
znode_t *zdp = VTOZ(dvp);
|
||||
znode_t *zp;
|
||||
@@ -1561,7 +1554,8 @@ zfs_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, struct componentname *cnp,
|
||||
}
|
||||
}
|
||||
|
||||
DTRACE_PROBE2(zfs__fastpath__lookup__miss, vnode_t *, dvp, char *, nm);
|
||||
DTRACE_PROBE2(zfs__fastpath__lookup__miss, vnode_t *, dvp,
|
||||
const char *, nm);
|
||||
|
||||
ZFS_ENTER(zfsvfs);
|
||||
ZFS_VERIFY_ZP(zdp);
|
||||
@@ -1778,7 +1772,7 @@ zfs_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, struct componentname *cnp,
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
zfs_create(znode_t *dzp, char *name, vattr_t *vap, int excl, int mode,
|
||||
zfs_create(znode_t *dzp, const char *name, vattr_t *vap, int excl, int mode,
|
||||
znode_t **zpp, cred_t *cr, int flag, vsecattr_t *vsecp)
|
||||
{
|
||||
znode_t *zp;
|
||||
@@ -1945,7 +1939,7 @@ out:
|
||||
|
||||
/*ARGSUSED*/
|
||||
static int
|
||||
zfs_remove_(vnode_t *dvp, vnode_t *vp, char *name, cred_t *cr)
|
||||
zfs_remove_(vnode_t *dvp, vnode_t *vp, const char *name, cred_t *cr)
|
||||
{
|
||||
znode_t *dzp = VTOZ(dvp);
|
||||
znode_t *zp;
|
||||
@@ -2059,13 +2053,13 @@ out:
|
||||
|
||||
|
||||
static int
|
||||
zfs_lookup_internal(znode_t *dzp, char *name, vnode_t **vpp,
|
||||
zfs_lookup_internal(znode_t *dzp, const char *name, vnode_t **vpp,
|
||||
struct componentname *cnp, int nameiop)
|
||||
{
|
||||
zfsvfs_t *zfsvfs = dzp->z_zfsvfs;
|
||||
int error;
|
||||
|
||||
cnp->cn_nameptr = name;
|
||||
cnp->cn_nameptr = __DECONST(char *, name);
|
||||
cnp->cn_namelen = strlen(name);
|
||||
cnp->cn_nameiop = nameiop;
|
||||
cnp->cn_flags = ISLASTCN | SAVENAME;
|
||||
@@ -2096,7 +2090,7 @@ zfs_lookup_internal(znode_t *dzp, char *name, vnode_t **vpp,
|
||||
}
|
||||
|
||||
int
|
||||
zfs_remove(znode_t *dzp, char *name, cred_t *cr, int flags)
|
||||
zfs_remove(znode_t *dzp, const char *name, cred_t *cr, int flags)
|
||||
{
|
||||
vnode_t *vp;
|
||||
int error;
|
||||
@@ -2131,8 +2125,8 @@ zfs_remove(znode_t *dzp, char *name, cred_t *cr, int flags)
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
zfs_mkdir(znode_t *dzp, char *dirname, vattr_t *vap, znode_t **zpp, cred_t *cr,
|
||||
int flags, vsecattr_t *vsecp)
|
||||
zfs_mkdir(znode_t *dzp, const char *dirname, vattr_t *vap, znode_t **zpp,
|
||||
cred_t *cr, int flags, vsecattr_t *vsecp)
|
||||
{
|
||||
znode_t *zp;
|
||||
zfsvfs_t *zfsvfs = dzp->z_zfsvfs;
|
||||
@@ -2298,7 +2292,7 @@ zfs_mkdir(znode_t *dzp, char *dirname, vattr_t *vap, znode_t **zpp, cred_t *cr,
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
static int
|
||||
zfs_rmdir_(vnode_t *dvp, vnode_t *vp, char *name, cred_t *cr)
|
||||
zfs_rmdir_(vnode_t *dvp, vnode_t *vp, const char *name, cred_t *cr)
|
||||
{
|
||||
znode_t *dzp = VTOZ(dvp);
|
||||
znode_t *zp = VTOZ(vp);
|
||||
@@ -2360,7 +2354,7 @@ out:
|
||||
}
|
||||
|
||||
int
|
||||
zfs_rmdir(znode_t *dzp, char *name, znode_t *cwd, cred_t *cr, int flags)
|
||||
zfs_rmdir(znode_t *dzp, const char *name, znode_t *cwd, cred_t *cr, int flags)
|
||||
{
|
||||
struct componentname cn;
|
||||
vnode_t *vp;
|
||||
@@ -3934,8 +3928,8 @@ zfs_rename_(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp,
|
||||
znode_t *sdzp, *tdzp, *szp, *tzp;
|
||||
zilog_t *zilog = NULL;
|
||||
dmu_tx_t *tx;
|
||||
char *snm = scnp->cn_nameptr;
|
||||
char *tnm = tcnp->cn_nameptr;
|
||||
const char *snm = scnp->cn_nameptr;
|
||||
const char *tnm = tcnp->cn_nameptr;
|
||||
int error = 0;
|
||||
bool want_seqc_end __maybe_unused = false;
|
||||
|
||||
@@ -4201,7 +4195,7 @@ out: /* original two vnodes are locked */
|
||||
}
|
||||
|
||||
int
|
||||
zfs_rename(znode_t *sdzp, char *sname, znode_t *tdzp, char *tname,
|
||||
zfs_rename(znode_t *sdzp, const char *sname, znode_t *tdzp, const char *tname,
|
||||
cred_t *cr, int flags)
|
||||
{
|
||||
struct componentname scn, tcn;
|
||||
@@ -4360,8 +4354,7 @@ zfs_symlink(znode_t *dzp, const char *name, vattr_t *vap,
|
||||
*/
|
||||
(void) zfs_link_create(dzp, name, zp, tx, ZNEW);
|
||||
|
||||
zfs_log_symlink(zilog, tx, txtype, dzp, zp,
|
||||
__DECONST(char *, name), __DECONST(char *, link));
|
||||
zfs_log_symlink(zilog, tx, txtype, dzp, zp, name, link);
|
||||
*zpp = zp;
|
||||
|
||||
zfs_acl_ids_free(&acl_ids);
|
||||
@@ -4432,7 +4425,7 @@ zfs_readlink(vnode_t *vp, uio_t *uio, cred_t *cr, caller_context_t *ct)
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
int
|
||||
zfs_link(znode_t *tdzp, znode_t *szp, char *name, cred_t *cr,
|
||||
zfs_link(znode_t *tdzp, znode_t *szp, const char *name, cred_t *cr,
|
||||
int flags)
|
||||
{
|
||||
znode_t *tzp;
|
||||
|
||||
@@ -131,7 +131,7 @@ static void zfsctl_snapshot_unmount_delay_impl(zfs_snapentry_t *se, int delay);
|
||||
* the snapshot name and provided mount point. No reference is taken.
|
||||
*/
|
||||
static zfs_snapentry_t *
|
||||
zfsctl_snapshot_alloc(char *full_name, char *full_path, spa_t *spa,
|
||||
zfsctl_snapshot_alloc(const char *full_name, const char *full_path, spa_t *spa,
|
||||
uint64_t objsetid, struct dentry *root_dentry)
|
||||
{
|
||||
zfs_snapentry_t *se;
|
||||
@@ -261,13 +261,13 @@ snapentry_compare_by_objsetid(const void *a, const void *b)
|
||||
* NULL will be returned.
|
||||
*/
|
||||
static zfs_snapentry_t *
|
||||
zfsctl_snapshot_find_by_name(char *snapname)
|
||||
zfsctl_snapshot_find_by_name(const char *snapname)
|
||||
{
|
||||
zfs_snapentry_t *se, search;
|
||||
|
||||
ASSERT(RW_LOCK_HELD(&zfs_snapshot_lock));
|
||||
|
||||
search.se_name = snapname;
|
||||
search.se_name = (char *)snapname;
|
||||
se = avl_find(&zfs_snapshots_by_name, &search, NULL);
|
||||
if (se)
|
||||
zfsctl_snapshot_hold(se);
|
||||
@@ -301,7 +301,7 @@ zfsctl_snapshot_find_by_objsetid(spa_t *spa, uint64_t objsetid)
|
||||
* removed, renamed, and added back to the new correct location in the tree.
|
||||
*/
|
||||
static int
|
||||
zfsctl_snapshot_rename(char *old_snapname, char *new_snapname)
|
||||
zfsctl_snapshot_rename(const char *old_snapname, const char *new_snapname)
|
||||
{
|
||||
zfs_snapentry_t *se;
|
||||
|
||||
@@ -410,7 +410,7 @@ zfsctl_snapshot_unmount_delay(spa_t *spa, uint64_t objsetid, int delay)
|
||||
* and zero when unmounted.
|
||||
*/
|
||||
static boolean_t
|
||||
zfsctl_snapshot_ismounted(char *snapname)
|
||||
zfsctl_snapshot_ismounted(const char *snapname)
|
||||
{
|
||||
zfs_snapentry_t *se;
|
||||
boolean_t ismounted = B_FALSE;
|
||||
@@ -751,7 +751,7 @@ out:
|
||||
* Special case the handling of "..".
|
||||
*/
|
||||
int
|
||||
zfsctl_root_lookup(struct inode *dip, char *name, struct inode **ipp,
|
||||
zfsctl_root_lookup(struct inode *dip, const char *name, struct inode **ipp,
|
||||
int flags, cred_t *cr, int *direntflags, pathname_t *realpnp)
|
||||
{
|
||||
zfsvfs_t *zfsvfs = ITOZSB(dip);
|
||||
@@ -784,7 +784,7 @@ zfsctl_root_lookup(struct inode *dip, char *name, struct inode **ipp,
|
||||
* snapshot if it exist, creating the pseudo filesystem inode as necessary.
|
||||
*/
|
||||
int
|
||||
zfsctl_snapdir_lookup(struct inode *dip, char *name, struct inode **ipp,
|
||||
zfsctl_snapdir_lookup(struct inode *dip, const char *name, struct inode **ipp,
|
||||
int flags, cred_t *cr, int *direntflags, pathname_t *realpnp)
|
||||
{
|
||||
zfsvfs_t *zfsvfs = ITOZSB(dip);
|
||||
@@ -815,8 +815,8 @@ zfsctl_snapdir_lookup(struct inode *dip, char *name, struct inode **ipp,
|
||||
* to the '.zfs/snapshot' directory snapshots cannot be moved elsewhere.
|
||||
*/
|
||||
int
|
||||
zfsctl_snapdir_rename(struct inode *sdip, char *snm,
|
||||
struct inode *tdip, char *tnm, cred_t *cr, int flags)
|
||||
zfsctl_snapdir_rename(struct inode *sdip, const char *snm,
|
||||
struct inode *tdip, const char *tnm, cred_t *cr, int flags)
|
||||
{
|
||||
zfsvfs_t *zfsvfs = ITOZSB(sdip);
|
||||
char *to, *from, *real, *fsname;
|
||||
@@ -893,7 +893,8 @@ out:
|
||||
* the removal of the snapshot with the given name.
|
||||
*/
|
||||
int
|
||||
zfsctl_snapdir_remove(struct inode *dip, char *name, cred_t *cr, int flags)
|
||||
zfsctl_snapdir_remove(struct inode *dip, const char *name, cred_t *cr,
|
||||
int flags)
|
||||
{
|
||||
zfsvfs_t *zfsvfs = ITOZSB(dip);
|
||||
char *snapname, *real;
|
||||
@@ -941,7 +942,7 @@ out:
|
||||
* the creation of a new snapshot with the given name.
|
||||
*/
|
||||
int
|
||||
zfsctl_snapdir_mkdir(struct inode *dip, char *dirname, vattr_t *vap,
|
||||
zfsctl_snapdir_mkdir(struct inode *dip, const char *dirname, vattr_t *vap,
|
||||
struct inode **ipp, cred_t *cr, int flags)
|
||||
{
|
||||
zfsvfs_t *zfsvfs = ITOZSB(dip);
|
||||
@@ -1001,7 +1002,7 @@ exportfs_flush(void)
|
||||
* it's in use, the unmount will fail harmlessly.
|
||||
*/
|
||||
int
|
||||
zfsctl_snapshot_unmount(char *snapname, int flags)
|
||||
zfsctl_snapshot_unmount(const char *snapname, int flags)
|
||||
{
|
||||
char *argv[] = { "/usr/bin/env", "umount", "-t", "zfs", "-n", NULL,
|
||||
NULL };
|
||||
|
||||
@@ -60,8 +60,9 @@
|
||||
* of names after deciding which is the appropriate lookup interface.
|
||||
*/
|
||||
static int
|
||||
zfs_match_find(zfsvfs_t *zfsvfs, znode_t *dzp, char *name, matchtype_t mt,
|
||||
boolean_t update, int *deflags, pathname_t *rpnp, uint64_t *zoid)
|
||||
zfs_match_find(zfsvfs_t *zfsvfs, znode_t *dzp, const char *name,
|
||||
matchtype_t mt, boolean_t update, int *deflags, pathname_t *rpnp,
|
||||
uint64_t *zoid)
|
||||
{
|
||||
boolean_t conflict = B_FALSE;
|
||||
int error;
|
||||
@@ -139,8 +140,8 @@ zfs_match_find(zfsvfs_t *zfsvfs, znode_t *dzp, char *name, matchtype_t mt,
|
||||
* but return znode pointers to a single match.
|
||||
*/
|
||||
int
|
||||
zfs_dirent_lock(zfs_dirlock_t **dlpp, znode_t *dzp, char *name, znode_t **zpp,
|
||||
int flag, int *direntflags, pathname_t *realpnp)
|
||||
zfs_dirent_lock(zfs_dirlock_t **dlpp, znode_t *dzp, char *name,
|
||||
znode_t **zpp, int flag, int *direntflags, pathname_t *realpnp)
|
||||
{
|
||||
zfsvfs_t *zfsvfs = ZTOZSB(dzp);
|
||||
zfs_dirlock_t *dl;
|
||||
|
||||
@@ -1234,8 +1234,8 @@ zfs_access(struct inode *ip, int mode, int flag, cred_t *cr)
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
int
|
||||
zfs_lookup(znode_t *zdp, char *nm, znode_t **zpp, int flags,
|
||||
cred_t *cr, int *direntflags, pathname_t *realpnp)
|
||||
zfs_lookup(znode_t *zdp, char *nm, znode_t **zpp, int flags, cred_t *cr,
|
||||
int *direntflags, pathname_t *realpnp)
|
||||
{
|
||||
zfsvfs_t *zfsvfs = ZTOZSB(zdp);
|
||||
int error = 0;
|
||||
|
||||
Reference in New Issue
Block a user