diff options
author | Tony Hutter <[email protected]> | 2017-06-28 10:05:16 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2017-06-28 10:05:16 -0700 |
commit | 682ce104cdd80db4b67eea09eb0a90324c5f98ee (patch) | |
tree | 3fa2067633f5c089685600f25601af0f791bfcaf /module/zfs/zvol.c | |
parent | cda0317e4d2a1277b328e4fc42ee3699bbe46c12 (diff) |
GCC 7.1 fixes
GCC 7.1 with will warn when we're not checking the snprintf()
return code in cases where the buffer could be truncated. This
patch either checks the snprintf return code (where applicable),
or simply disables the warnings (ztest.c).
Reviewed-by: Chunwei Chen <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Tony Hutter <[email protected]>
Closes #6253
Diffstat (limited to 'module/zfs/zvol.c')
-rw-r--r-- | module/zfs/zvol.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c index 75ed06e03..528acbc22 100644 --- a/module/zfs/zvol.c +++ b/module/zfs/zvol.c @@ -2154,14 +2154,12 @@ zvol_rename_minors_impl(const char *oldname, const char *newname) { zvol_state_t *zv, *zv_next; int oldnamelen, newnamelen; - char *name; if (zvol_inhibit_dev) return; oldnamelen = strlen(oldname); newnamelen = strlen(newname); - name = kmem_alloc(MAXNAMELEN, KM_SLEEP); mutex_enter(&zvol_state_lock); @@ -2181,18 +2179,17 @@ zvol_rename_minors_impl(const char *oldname, const char *newname) } else if (strncmp(zv->zv_name, oldname, oldnamelen) == 0 && (zv->zv_name[oldnamelen] == '/' || zv->zv_name[oldnamelen] == '@')) { - snprintf(name, MAXNAMELEN, "%s%c%s", newname, + char *name = kmem_asprintf("%s%c%s", newname, zv->zv_name[oldnamelen], zv->zv_name + oldnamelen + 1); zvol_rename_minor(zv, name); + kmem_free(name, strlen(name + 1)); } mutex_exit(&zv->zv_state_lock); } mutex_exit(&zvol_state_lock); - - kmem_free(name, MAXNAMELEN); } typedef struct zvol_snapdev_cb_arg { |