Skip to content

Commit

Permalink
libzfs: const'ify path argument to zfs_path_to_zhandle
Browse files Browse the repository at this point in the history
zfs_path_to_zhandle has no need to mutate the path argument,
most notably:

- zfs_open takes path as const
- getextmntent takes path as const
- fprintf most clearly doesn't need to mutate it

It's hard to foresee any reason that libzfs could conceivably
want to mutate it in the future, either, so const'ify it.

Reviewed-by: Ryan Moeller <[email protected]>
Reviewed-by: Matt Ahrens <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Kyle Evans <[email protected]>
Closes #10605
  • Loading branch information
kevans91 authored Jul 22, 2020
1 parent db5b392 commit b197457
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion include/libzfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,8 @@ extern int zfs_show_diffs(zfs_handle_t *, int, const char *, const char *,
extern const char *zfs_type_to_name(zfs_type_t);
extern void zfs_refresh_properties(zfs_handle_t *);
extern int zfs_name_valid(const char *, zfs_type_t);
extern zfs_handle_t *zfs_path_to_zhandle(libzfs_handle_t *, char *, zfs_type_t);
extern zfs_handle_t *zfs_path_to_zhandle(libzfs_handle_t *, const char *,
zfs_type_t);
extern int zfs_parent_name(zfs_handle_t *, char *, size_t);
extern boolean_t zfs_dataset_exists(libzfs_handle_t *, const char *,
zfs_type_t);
Expand Down
2 changes: 1 addition & 1 deletion lib/libzfs/libzfs_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ zfs_get_pool_handle(const zfs_handle_t *zhp)
* fs/vol/snap/bkmark name.
*/
zfs_handle_t *
zfs_path_to_zhandle(libzfs_handle_t *hdl, char *path, zfs_type_t argtype)
zfs_path_to_zhandle(libzfs_handle_t *hdl, const char *path, zfs_type_t argtype)
{
struct stat64 statbuf;
struct extmnttab entry;
Expand Down

0 comments on commit b197457

Please sign in to comment.