Project

General

Profile

Actions

Bug #6317

closed

NULL pointer constant is not an int nor unsigned int in libzfs

Added by Richard PALO about 6 years ago. Updated about 1 year ago.

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

Related to illumos gate - Bug #11156: libzfs: NULL pointer errorsClosedToomas Soome

Actions
Related to illumos gate - Feature #12661: null.h: enable NULL pointer for SPARCClosedToomas Soome

Actions
Actions #1

Updated by Yuri Pankov about 6 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
Actions #2

Updated by Gary Mills about 6 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.

Actions #3

Updated by Richard PALO about 6 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 *) */

Actions #4

Updated by Gary Mills about 6 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.

Actions #5

Updated by Toomas Soome about 1 year ago

  • Related to Bug #11156: libzfs: NULL pointer errors added
Actions #6

Updated by Toomas Soome about 1 year ago

  • Related to Feature #12661: null.h: enable NULL pointer for SPARC added
Actions #7

Updated by Toomas Soome about 1 year ago

  • Status changed from New to Closed
Actions

Also available in: Atom PDF