Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw const on some strings #10997

Merged
merged 1 commit into from
Oct 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/os/freebsd/zfs/sys/zfs_ctldir.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int zfsctl_root(zfsvfs_t *, int, vnode_t **);
void zfsctl_init(void);
void zfsctl_fini(void);
boolean_t zfsctl_is_node(vnode_t *);
int zfsctl_snapshot_unmount(char *snapname, int flags);
int zfsctl_snapshot_unmount(const char *snapname, int flags);
int zfsctl_rename_snapshot(const char *from, const char *to);
int zfsctl_destroy_snapshot(const char *snapname, int force);
int zfsctl_umount_snapshots(vfs_t *, int, cred_t *);
Expand Down
4 changes: 0 additions & 4 deletions include/os/freebsd/zfs/sys/zfs_dir.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ extern int zfs_dirent_lookup(znode_t *, const char *, znode_t **, int);
extern int zfs_link_create(znode_t *, const char *, znode_t *, dmu_tx_t *, int);
extern int zfs_link_destroy(znode_t *, const char *, znode_t *, dmu_tx_t *, int,
boolean_t *);
#if 0
extern int zfs_dirlook(vnode_t *, const char *, vnode_t **, int);
#else
extern int zfs_dirlook(znode_t *, const char *name, znode_t **);
#endif
extern void zfs_mknode(znode_t *, vattr_t *, dmu_tx_t *, cred_t *,
uint_t, znode_t **, zfs_acl_ids_t *);
extern void zfs_rmnode(znode_t *);
Expand Down
14 changes: 7 additions & 7 deletions include/os/freebsd/zfs/sys/zfs_vnops.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ int dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset,
uint64_t size, struct vm_page **ppa, dmu_tx_t *tx);
int dmu_read_pages(objset_t *os, uint64_t object, vm_page_t *ma, int count,
int *rbehind, int *rahead, int last_size);
extern int zfs_remove(znode_t *dzp, char *name, cred_t *cr, int flags);
extern int zfs_mkdir(znode_t *dzp, char *dirname, vattr_t *vap,
extern int zfs_remove(znode_t *dzp, const char *name, cred_t *cr, int flags);
extern int zfs_mkdir(znode_t *dzp, const char *dirname, vattr_t *vap,
znode_t **zpp, cred_t *cr, int flags, vsecattr_t *vsecp);
extern int zfs_rmdir(znode_t *dzp, char *name, znode_t *cwd,
extern int zfs_rmdir(znode_t *dzp, const char *name, znode_t *cwd,
cred_t *cr, int flags);
extern int zfs_setattr(znode_t *zp, vattr_t *vap, int flag, cred_t *cr);
extern int zfs_rename(znode_t *sdzp, char *snm, znode_t *tdzp,
char *tnm, cred_t *cr, int flags);
extern int zfs_rename(znode_t *sdzp, const char *snm, znode_t *tdzp,
const char *tnm, cred_t *cr, int flags);
extern int zfs_symlink(znode_t *dzp, const char *name, vattr_t *vap,
const char *link, znode_t **zpp, cred_t *cr, int flags);
extern int zfs_link(znode_t *tdzp, znode_t *sp,
char *name, cred_t *cr, int flags);
const char *name, cred_t *cr, int flags);
extern int zfs_space(znode_t *zp, int cmd, struct flock *bfp, int flag,
offset_t offset, cred_t *cr);
extern int zfs_create(znode_t *dzp, char *name, vattr_t *vap, int excl,
extern int 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);
extern int zfs_setsecattr(znode_t *zp, vsecattr_t *vsecp, int flag,
cred_t *cr);
Expand Down
18 changes: 9 additions & 9 deletions include/os/linux/zfs/sys/zfs_ctldir.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,22 @@ extern boolean_t zfsctl_is_snapdir(struct inode *ip);
extern int zfsctl_fid(struct inode *ip, fid_t *fidp);

/* zfsctl '.zfs' functions */
extern int zfsctl_root_lookup(struct inode *dip, char *name,
extern int zfsctl_root_lookup(struct inode *dip, const char *name,
struct inode **ipp, int flags, cred_t *cr, int *direntflags,
pathname_t *realpnp);

/* zfsctl '.zfs/snapshot' functions */
extern int zfsctl_snapdir_lookup(struct inode *dip, char *name,
extern int zfsctl_snapdir_lookup(struct inode *dip, const char *name,
struct inode **ipp, int flags, cred_t *cr, int *direntflags,
pathname_t *realpnp);
extern int zfsctl_snapdir_rename(struct inode *sdip, char *sname,
struct inode *tdip, char *tname, cred_t *cr, int flags);
extern int zfsctl_snapdir_remove(struct inode *dip, char *name, cred_t *cr,
int flags);
extern int zfsctl_snapdir_mkdir(struct inode *dip, char *dirname, vattr_t *vap,
struct inode **ipp, cred_t *cr, int flags);
extern int zfsctl_snapdir_rename(struct inode *sdip, const char *sname,
struct inode *tdip, const char *tname, cred_t *cr, int flags);
extern int zfsctl_snapdir_remove(struct inode *dip, const char *name,
cred_t *cr, int flags);
extern int zfsctl_snapdir_mkdir(struct inode *dip, const char *dirname,
vattr_t *vap, struct inode **ipp, cred_t *cr, int flags);
extern int zfsctl_snapshot_mount(struct path *path, int flags);
extern int zfsctl_snapshot_unmount(char *snapname, int flags);
extern int zfsctl_snapshot_unmount(const char *snapname, int flags);
extern int zfsctl_snapshot_unmount_delay(spa_t *spa, uint64_t objsetid,
int delay);
extern int zfsctl_snapdir_vget(struct super_block *sb, uint64_t objsetid,
Expand Down
4 changes: 2 additions & 2 deletions include/os/linux/zfs/sys/zfs_vnops.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ extern int zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr);
extern int zfs_write_simple(znode_t *zp, const void *data, size_t len,
loff_t pos, size_t *resid);
extern int zfs_access(struct inode *ip, int mode, int flag, cred_t *cr);
extern int zfs_lookup(znode_t *dzp, char *nm, znode_t **zpp,
int flags, cred_t *cr, int *direntflags, pathname_t *realpnp);
extern int zfs_lookup(znode_t *dzp, char *nm, znode_t **zpp, int flags,
cred_t *cr, int *direntflags, pathname_t *realpnp);
extern int zfs_create(znode_t *dzp, char *name, vattr_t *vap, int excl,
int mode, znode_t **zpp, cred_t *cr, int flag, vsecattr_t *vsecp);
extern int zfs_tmpfile(struct inode *dip, vattr_t *vapzfs, int excl,
Expand Down
2 changes: 1 addition & 1 deletion include/sys/dmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ extern int dmu_objset_blksize(objset_t *os);
extern int dmu_snapshot_list_next(objset_t *os, int namelen, char *name,
uint64_t *id, uint64_t *offp, boolean_t *case_conflict);
extern int dmu_snapshot_lookup(objset_t *os, const char *name, uint64_t *val);
extern int dmu_snapshot_realname(objset_t *os, char *name, char *real,
extern int dmu_snapshot_realname(objset_t *os, const char *name, char *real,
int maxlen, boolean_t *conflict);
extern int dmu_dir_list_next(objset_t *os, int namelen, char *name,
uint64_t *idp, uint64_t *offp);
Expand Down
6 changes: 3 additions & 3 deletions include/sys/spa.h
Original file line number Diff line number Diff line change
Expand Up @@ -768,12 +768,12 @@ extern int spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props,
extern int spa_import(char *pool, nvlist_t *config, nvlist_t *props,
uint64_t flags);
extern nvlist_t *spa_tryimport(nvlist_t *tryconfig);
extern int spa_destroy(char *pool);
extern int spa_destroy(const char *pool);
extern int spa_checkpoint(const char *pool);
extern int spa_checkpoint_discard(const char *pool);
extern int spa_export(char *pool, nvlist_t **oldconfig, boolean_t force,
extern int spa_export(const char *pool, nvlist_t **oldconfig, boolean_t force,
boolean_t hardforce);
extern int spa_reset(char *pool);
extern int spa_reset(const char *pool);
extern void spa_async_request(spa_t *spa, int flag);
extern void spa_async_unrequest(spa_t *spa, int flag);
extern void spa_async_suspend(spa_t *spa);
Expand Down
2 changes: 1 addition & 1 deletion include/sys/u8_textprep.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ extern int uconv_u8tou32(const uchar_t *, size_t *, uint32_t *, size_t *, int);
#define U8_ILLEGAL_CHAR (-1)
#define U8_OUT_OF_RANGE_CHAR (-2)

extern int u8_validate(char *, size_t, char **, int, int *);
extern int u8_validate(const char *, size_t, char **, int, int *);
extern int u8_strcmp(const char *, const char *, size_t, int, size_t, int *);
extern size_t u8_textprep_str(char *, size_t *, char *, size_t *, int, size_t,
int *);
Expand Down
13 changes: 7 additions & 6 deletions include/sys/zfs_znode.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,19 +262,20 @@ extern boolean_t zfs_get_vfs_flag_unmounted(objset_t *os);
extern void zfs_znode_dmu_fini(znode_t *);

extern void zfs_log_create(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
znode_t *dzp, znode_t *zp, char *name, vsecattr_t *, zfs_fuid_info_t *,
vattr_t *vap);
znode_t *dzp, znode_t *zp, const char *name, vsecattr_t *,
zfs_fuid_info_t *, vattr_t *vap);
extern int zfs_log_create_txtype(zil_create_t, vsecattr_t *vsecp,
vattr_t *vap);
extern void zfs_log_remove(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
znode_t *dzp, char *name, uint64_t foid, boolean_t unlinked);
znode_t *dzp, const char *name, uint64_t foid, boolean_t unlinked);
#define ZFS_NO_OBJECT 0 /* no object id */
extern void zfs_log_link(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
znode_t *dzp, znode_t *zp, char *name);
znode_t *dzp, znode_t *zp, const char *name);
extern void zfs_log_symlink(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
znode_t *dzp, znode_t *zp, char *name, char *link);
znode_t *dzp, znode_t *zp, const char *name, const char *link);
extern void zfs_log_rename(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
znode_t *sdzp, char *sname, znode_t *tdzp, char *dname, znode_t *szp);
znode_t *sdzp, const char *sname, znode_t *tdzp, const char *dname,
znode_t *szp);
extern void zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype,
znode_t *zp, offset_t off, ssize_t len, int ioflag,
zil_callback_t callback, void *callback_data);
Expand Down
2 changes: 1 addition & 1 deletion module/os/freebsd/zfs/zfs_ctldir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
45 changes: 19 additions & 26 deletions module/os/freebsd/zfs/zfs_vnops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1945,7 +1939,7 @@ zfs_create(znode_t *dzp, char *name, vattr_t *vap, int excl, int mode,

/*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;
Expand Down Expand Up @@ -2059,13 +2053,13 @@ zfs_remove_(vnode_t *dvp, vnode_t *vp, char *name, cred_t *cr)


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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -2360,7 +2354,7 @@ zfs_rmdir_(vnode_t *dvp, vnode_t *vp, char *name, cred_t *cr)
}

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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -4201,7 +4195,7 @@ zfs_rename_(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp,
}

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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
Loading