mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-23 02:44:41 +03:00
nvpair: Constify string functions
After addressing coverity complaints involving `nvpair_name()`, the compiler started complaining about dropping const. This lead to a rabbit hole where not only `nvpair_name()` needed to be constified, but also `nvpair_value_string()`, `fnvpair_value_string()` and a few other static functions, plus variable pointers throughout the code. The result became a fairly big change, so it has been split out into its own patch. Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu> Closes #14612
This commit is contained in:
committed by
Brian Behlendorf
parent
50f6934b9c
commit
d1807f168e
@@ -181,6 +181,7 @@
|
||||
<qualified-type-def type-id='a84c031d' const='yes' id='9b45d938'/>
|
||||
<pointer-type-def type-id='9b45d938' size-in-bits='64' id='80f4b756'/>
|
||||
<qualified-type-def type-id='80f4b756' restrict='yes' id='9d26089a'/>
|
||||
<pointer-type-def type-id='80f4b756' size-in-bits='64' id='7d3cd834'/>
|
||||
<qualified-type-def type-id='8e8d4be3' const='yes' id='693c3853'/>
|
||||
<pointer-type-def type-id='693c3853' size-in-bits='64' id='22cce67b'/>
|
||||
<pointer-type-def type-id='95942d0c' size-in-bits='64' id='b0382bb3'/>
|
||||
@@ -235,9 +236,9 @@
|
||||
<return type-id='95e97e5e'/>
|
||||
</function-decl>
|
||||
<function-decl name='nvlist_lookup_string' visibility='default' binding='global' size-in-bits='64'>
|
||||
<parameter type-id='5ce45b60'/>
|
||||
<parameter type-id='22cce67b'/>
|
||||
<parameter type-id='80f4b756'/>
|
||||
<parameter type-id='9b23c9ad'/>
|
||||
<parameter type-id='7d3cd834'/>
|
||||
<return type-id='95e97e5e'/>
|
||||
</function-decl>
|
||||
<function-decl name='nvlist_exists' visibility='default' binding='global' size-in-bits='64'>
|
||||
|
||||
@@ -116,7 +116,7 @@ lzbe_get_boot_device(const char *pool, char **device)
|
||||
libzfs_handle_t *hdl;
|
||||
zpool_handle_t *zphdl;
|
||||
nvlist_t *nv;
|
||||
char *val;
|
||||
const char *val;
|
||||
int rv = -1;
|
||||
|
||||
if (pool == NULL || *pool == '\0' || device == NULL)
|
||||
@@ -140,14 +140,13 @@ lzbe_get_boot_device(const char *pool, char **device)
|
||||
* we only do need dataset name.
|
||||
*/
|
||||
if (strncmp(val, "zfs:", 4) == 0) {
|
||||
val += 4;
|
||||
val = strdup(val);
|
||||
if (val != NULL) {
|
||||
size_t len = strlen(val);
|
||||
char *tmp = strdup(val + 4);
|
||||
if (tmp != NULL) {
|
||||
size_t len = strlen(tmp);
|
||||
|
||||
if (val[len - 1] == ':')
|
||||
val[len - 1] = '\0';
|
||||
*device = val;
|
||||
if (tmp[len - 1] == ':')
|
||||
tmp[len - 1] = '\0';
|
||||
*device = tmp;
|
||||
} else {
|
||||
rv = ENOMEM;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user