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:
Ryan Moeller
2020-10-02 20:44:10 -04:00
committed by GitHub
parent 5b525165e9
commit 4d55ea811d
20 changed files with 99 additions and 108 deletions
+1 -1
View File
@@ -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;
+19 -26
View File
@@ -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;