libzfs_sendrecv: Style pass on zfs_send_space

* Reduce indentation.
* Move locals closer to use.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #12967
This commit is contained in:
Ryan Moeller 2021-08-05 15:28:32 +00:00 committed by Brian Behlendorf
parent 0c1c746a74
commit a8747c0403

View File

@ -726,53 +726,50 @@ static int
zfs_send_space(zfs_handle_t *zhp, const char *snapname, const char *from, zfs_send_space(zfs_handle_t *zhp, const char *snapname, const char *from,
enum lzc_send_flags flags, uint64_t *spacep) enum lzc_send_flags flags, uint64_t *spacep)
{ {
libzfs_handle_t *hdl = zhp->zfs_hdl;
int error;
assert(snapname != NULL); assert(snapname != NULL);
error = lzc_send_space(snapname, from, flags, spacep);
if (error != 0) { int error = lzc_send_space(snapname, from, flags, spacep);
char errbuf[1024]; if (error == 0)
(void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, return (0);
"warning: cannot estimate space for '%s'"), snapname);
switch (error) { char errbuf[1024];
case EXDEV: (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
"warning: cannot estimate space for '%s'"), snapname);
libzfs_handle_t *hdl = zhp->zfs_hdl;
switch (error) {
case EXDEV:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"not an earlier snapshot from the same fs"));
return (zfs_error(hdl, EZFS_CROSSTARGET, errbuf));
case ENOENT:
if (zfs_dataset_exists(hdl, snapname,
ZFS_TYPE_SNAPSHOT)) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"not an earlier snapshot from the same fs")); "incremental source (%s) does not exist"),
return (zfs_error(hdl, EZFS_CROSSTARGET, errbuf)); snapname);
case ENOENT:
if (zfs_dataset_exists(hdl, snapname,
ZFS_TYPE_SNAPSHOT)) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"incremental source (%s) does not exist"),
snapname);
}
return (zfs_error(hdl, EZFS_NOENT, errbuf));
case EDQUOT:
case EFBIG:
case EIO:
case ENOLINK:
case ENOSPC:
case ENOSTR:
case ENXIO:
case EPIPE:
case ERANGE:
case EFAULT:
case EROFS:
case EINVAL:
zfs_error_aux(hdl, "%s", strerror(error));
return (zfs_error(hdl, EZFS_BADBACKUP, errbuf));
default:
return (zfs_standard_error(hdl, error, errbuf));
} }
} return (zfs_error(hdl, EZFS_NOENT, errbuf));
return (0); case EDQUOT:
case EFBIG:
case EIO:
case ENOLINK:
case ENOSPC:
case ENOSTR:
case ENXIO:
case EPIPE:
case ERANGE:
case EFAULT:
case EROFS:
case EINVAL:
zfs_error_aux(hdl, "%s", strerror(error));
return (zfs_error(hdl, EZFS_BADBACKUP, errbuf));
default:
return (zfs_standard_error(hdl, error, errbuf));
}
} }
/* /*