Actions
Bug #6317
closedNULL pointer constant is not an int nor unsigned int in libzfs
Status:
Closed
Priority:
Normal
Assignee:
-
Category:
zfs - Zettabyte File System
Start date:
2015-10-10
Due date:
% Done:
0%
Estimated time:
Difficulty:
Medium
Tags:
needs-triage
Gerrit CR:
Description
After a recent libzfs commit, here are the current mods to fix the NULL pointer constant issue:
diff --git a/usr/src/lib/libzfs/common/libzfs_sendrecv.c b/usr/src/lib/libzfs/common/libzfs_sendrecv.c index b9b0f68..6622403 100644 --- a/usr/src/lib/libzfs/common/libzfs_sendrecv.c +++ b/usr/src/lib/libzfs/common/libzfs_sendrecv.c @@ -3053,7 +3053,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap, boolean_t resuming = DMU_GET_FEATUREFLAGS(drrb->drr_versioninfo) & DMU_BACKUP_FEATURE_RESUMING; - stream_wantsnewfs = (drrb->drr_fromguid == NULL || + stream_wantsnewfs = (drrb->drr_fromguid == 0 || (drrb->drr_flags & DRR_FLAG_CLONE) || originsnap) && !resuming; if (stream_wantsnewfs) { diff --git a/usr/src/lib/libzfs/common/libzfs_util.c b/usr/src/lib/libzfs/common/libzfs_util.c index 507a72c..f08e15f 100644 --- a/usr/src/lib/libzfs/common/libzfs_util.c +++ b/usr/src/lib/libzfs/common/libzfs_util.c @@ -773,9 +773,9 @@ zcmd_free_nvlists(zfs_cmd_t *zc) free((void *)(uintptr_t)zc->zc_nvlist_conf); free((void *)(uintptr_t)zc->zc_nvlist_src); free((void *)(uintptr_t)zc->zc_nvlist_dst); - zc->zc_nvlist_conf = NULL; - zc->zc_nvlist_src = NULL; - zc->zc_nvlist_dst = NULL; + zc->zc_nvlist_conf = (uintptr_t)NULL; + zc->zc_nvlist_src = (uintptr_t)NULL; + zc->zc_nvlist_dst = (uintptr_t)NULL; } static int
Related issues
Updated by Yuri Pankov almost 7 years ago
- Subject changed from NULL pointer constant is not an int nor unsigned int in libzfz to NULL pointer constant is not an int nor unsigned int in libzfs
Updated by Gary Mills almost 7 years ago
I'd recommend setting those three values to:
(uint64_t)0
The three structure members all have type uint64_t, an integer type. NULL, the pointer, is not involved here.
Updated by Richard PALO almost 7 years ago
except reading from zfs_ioctl.h
322typedef struct zfs_cmd { 323 char zc_name[MAXPATHLEN]; /* name of pool or dataset */ 324 uint64_t zc_nvlist_src; /* really (char *) */ 325 uint64_t zc_nvlist_src_size; 326 uint64_t zc_nvlist_dst; /* really (char *) */ 327 uint64_t zc_nvlist_dst_size; ... 339 uint64_t zc_nvlist_conf; /* really (char *) */
Updated by Gary Mills almost 7 years ago
Ignore the comments. uint64_t is still an integer type. The comments only mean that zfs is storing pointers into integer members. It would have to cast them to use them as pointers. The members should still be initialized to zero, just like it was before.
Updated by Toomas Soome almost 2 years ago
- Related to Bug #11156: libzfs: NULL pointer errors added
Updated by Toomas Soome almost 2 years ago
- Related to Feature #12661: null.h: enable NULL pointer for SPARC added
Actions