Fix coverity defects:
coverity scan CID:147623, Type: Resource leak.
coverity scan CID:147622, Type: Resource leak.
reason: zpool_open zhp, but not zpool_close zhp. so resource leak.
coverity scan CID:147621, Type: Resource fd leak.
coverity scan CID:147620, Type: Resource fd leak.
reason: do_write do_read open file fd,but exception not close fd.
delete unuse definition DMU_OS_IS_L2COMPRESSIBLE.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: cao.xuewen <cao.xuewen@zte.com.cn>
Closes #5137
if (tgt == NULL) {
(void) fprintf(stderr, "cannot find device '%s' in "
"pool '%s'\n", device, pool);
+ zpool_close(zhp);
return (-1);
}
record->zi_end = record->zi_start + VDEV_PAD_SIZE - 1;
break;
}
+ zpool_close(zhp);
return (0);
}
{
char *poolname;
int i, ret = 0;
- zpool_handle_t *zhp;
+ zpool_handle_t *zhp = NULL;
argc--;
argv++;
if (zpool_vdev_remove(zhp, argv[i]) != 0)
ret = 1;
}
+ zpool_close(zhp);
return (ret);
}
((os)->os_secondary_cache == ZFS_CACHE_ALL || \
(os)->os_secondary_cache == ZFS_CACHE_METADATA)
-#define DMU_OS_IS_L2COMPRESSIBLE(os) (zfs_mdcomp_disable == B_FALSE)
-
/* called from zpl */
int dmu_objset_hold(const char *name, void *tag, objset_t **osp);
int dmu_objset_own(const char *name, dmu_objset_type_t type,
if (read(fd, buf, sizeof (buf)) == -1) {
(void) fprintf(stderr, "read(%d, buf, %zd) failed with errno "
"%d\n", fd, sizeof (buf), errno);
+ (void) close(fd);
return (1);
}
(void) close(fd);
if (write(fd, buf, strlen(buf)) == -1) {
(void) fprintf(stderr, "write(%d, buf, %d) failed with errno "
"%d\n", fd, (int)strlen(buf), errno);
+ (void) close(fd);
return (1);
}
(void) close(fd);