mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-17 10:01:01 +03:00
Fix coverity defects: CID 147548
CID 147548: Type:Dereference null return value Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: cao.xuewen <cao.xuewen@zte.com.cn> Closes #5321
This commit is contained in:
parent
b182ac00aa
commit
2bac68145f
@ -917,6 +917,7 @@ typedef struct ddt_histogram {
|
||||
#define ZVOL_DRIVER "zvol"
|
||||
#define ZFS_DRIVER "zfs"
|
||||
#define ZFS_DEV "/dev/zfs"
|
||||
#define ZFS_SHARETAB "/etc/dfs/sharetab"
|
||||
|
||||
/* general zvol path */
|
||||
#define ZVOL_DIR "/dev"
|
||||
|
@ -113,7 +113,7 @@ parse_sharetab(sa_handle_impl_t impl_handle) {
|
||||
char line[512];
|
||||
char *eol, *pathname, *resource, *fstype, *options, *description;
|
||||
|
||||
fp = fopen("/etc/dfs/sharetab", "r");
|
||||
fp = fopen(ZFS_SHARETAB, "r");
|
||||
|
||||
if (fp == NULL)
|
||||
return;
|
||||
@ -170,7 +170,7 @@ update_sharetab(sa_handle_impl_t impl_handle)
|
||||
sa_share_impl_t impl_share;
|
||||
int temp_fd;
|
||||
FILE *temp_fp;
|
||||
char tempfile[] = "/etc/dfs/sharetab.XXXXXX";
|
||||
char tempfile[] = ZFS_SHARETAB".XXXXXX";
|
||||
sa_fstype_t *fstype;
|
||||
const char *resource;
|
||||
|
||||
@ -215,7 +215,7 @@ update_sharetab(sa_handle_impl_t impl_handle)
|
||||
fsync(temp_fd);
|
||||
fclose(temp_fp);
|
||||
|
||||
(void) rename(tempfile, "/etc/dfs/sharetab");
|
||||
(void) rename(tempfile, ZFS_SHARETAB);
|
||||
}
|
||||
|
||||
typedef struct update_cookie_s {
|
||||
|
@ -863,12 +863,13 @@ libzfs_init(void)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
hdl->libzfs_sharetab = fopen("/etc/dfs/sharetab", "r");
|
||||
hdl->libzfs_sharetab = fopen(ZFS_SHARETAB, "r");
|
||||
|
||||
if (libzfs_core_init() != 0) {
|
||||
(void) close(hdl->libzfs_fd);
|
||||
(void) fclose(hdl->libzfs_mnttab);
|
||||
(void) fclose(hdl->libzfs_sharetab);
|
||||
if (hdl->libzfs_sharetab)
|
||||
(void) fclose(hdl->libzfs_sharetab);
|
||||
free(hdl);
|
||||
return (NULL);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user