libzfs: constify zfs_strip_partition(), zfs_strip_path()

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13413
This commit is contained in:
наб 2022-05-03 19:56:12 +02:00 committed by Brian Behlendorf
parent ca3b105cd9
commit 5ac80603bd
5 changed files with 17 additions and 14 deletions

View File

@ -97,8 +97,8 @@ _LIBZUTIL_H int zfs_append_partition(char *path, size_t max_len);
_LIBZUTIL_H int zfs_resolve_shortname(const char *name, char *path,
size_t pathlen);
_LIBZUTIL_H char *zfs_strip_partition(char *);
_LIBZUTIL_H char *zfs_strip_path(char *);
_LIBZUTIL_H char *zfs_strip_partition(const char *);
_LIBZUTIL_H const char *zfs_strip_path(const char *);
_LIBZUTIL_H int zfs_strcmp_pathname(const char *, const char *, int);

View File

@ -5588,12 +5588,12 @@
<return type-id='95e97e5e'/>
</function-decl>
<function-decl name='zfs_strip_partition' mangled-name='zfs_strip_partition' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_strip_partition'>
<parameter type-id='26a90f95' name='path'/>
<parameter type-id='80f4b756' name='path'/>
<return type-id='26a90f95'/>
</function-decl>
<function-decl name='zfs_strip_path' mangled-name='zfs_strip_path' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_strip_path'>
<parameter type-id='26a90f95' name='path'/>
<return type-id='26a90f95'/>
<parameter type-id='80f4b756' name='path'/>
<return type-id='80f4b756'/>
</function-decl>
<function-decl name='zfs_get_enclosure_sysfs_path' mangled-name='zfs_get_enclosure_sysfs_path' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_get_enclosure_sysfs_path'>
<parameter type-id='80f4b756' name='dev_name'/>

View File

@ -4123,7 +4123,8 @@ char *
zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv,
int name_flags)
{
char *path, *type;
char *type, *tpath;
const char *path;
uint64_t value;
char buf[PATH_BUF_LEN];
char tmpbuf[PATH_BUF_LEN * 2];
@ -4148,7 +4149,9 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv,
(void) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_GUID, &value);
(void) snprintf(buf, sizeof (buf), "%llu", (u_longlong_t)value);
path = buf;
} else if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path) == 0) {
} else if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &tpath) == 0) {
path = tpath;
if (name_flags & VDEV_NAME_FOLLOW_LINKS) {
char *rp = realpath(path, NULL);
if (rp) {

View File

@ -40,7 +40,7 @@
* Note: The caller must free the returned string.
*/
char *
zfs_strip_partition(char *dev)
zfs_strip_partition(const char *dev)
{
return (strdup(dev));
}
@ -56,8 +56,8 @@ zfs_append_partition(char *path, size_t max_len)
* On FreeBSD we only want to remove "/dev/" from the beginning of
* paths if present.
*/
char *
zfs_strip_path(char *path)
const char *
zfs_strip_path(const char *path)
{
if (strncmp(path, _PATH_DEV, sizeof (_PATH_DEV) - 1) == 0)
return (path + sizeof (_PATH_DEV) - 1);

View File

@ -81,7 +81,7 @@ zfs_append_partition(char *path, size_t max_len)
* caller must free the returned string
*/
char *
zfs_strip_partition(char *path)
zfs_strip_partition(const char *path)
{
char *tmp = strdup(path);
char *part = NULL, *d = NULL;
@ -117,7 +117,7 @@ zfs_strip_partition(char *path)
* Returned string must be freed.
*/
static char *
zfs_strip_partition_path(char *path)
zfs_strip_partition_path(const char *path)
{
char *newpath = strdup(path);
char *sd_offset;
@ -148,8 +148,8 @@ zfs_strip_partition_path(char *path)
/*
* Strip the unwanted portion of a device path.
*/
char *
zfs_strip_path(char *path)
const char *
zfs_strip_path(const char *path)
{
return (strrchr(path, '/') + 1);
}