11453 zpool: NULL pointer errors
Review Request #2171 — Created July 11, 2019 and submitted
Information | |
---|---|
tsoome | |
illumos-gate | |
11453 | |
561cce6... | |
Reviewers | |
general | |
zpool_vdev.c: In function 'check_disk': zpool_vdev.c:196:31: error: comparison between pointer and integer [-Werror] &err)) == NULL || *drive == NULL) { ^~ zpool_vdev.c:216:13: error: comparison between pointer and integer [-Werror] if (*media == NULL) { ^~ zpool_vdev.c:238:23: error: comparison between pointer and integer [-Werror] for (i = 0; slice[i] != NULL; i++) { ^~ zpool_vdev.c: In function 'check_device': zpool_vdev.c:267:62: error: comparison between pointer and integer [-Werror] if ((desc = dm_get_descriptor_by_name(DM_ALIAS, dev, &err)) != NULL) { ^~ cc1: all warnings being treated as errors
-
I think it's possible to avoid some of these
== 0
checks. -
usr/src/cmd/zpool/zpool_vdev.c (Diff revision 1) Would be better to remove this.
dm_descriptor_t
is more-or-less opaque, and if it is possible avoid dereferencing that.If the internal
p.general == NULL
, then the next call ofdm_get_associated_descriptors()
will return withNULL
anderr
set toENODEV
.This line should be:
&err)) == NULL) {
-
usr/src/cmd/zpool/zpool_vdev.c (Diff revision 1) Same, this should be in the error handling after the next call of
dm_get_associated_descriptors()
. -
usr/src/cmd/zpool/zpool_vdev.c (Diff revision 1) Should be:
if ((slice = dm_get_associated_descriptors(*media, DM_SLICE, &err)) == NULL) { dm_free_descriptors(media); if (err == ENODEV) { /* * It is possible that the user has specified a * removable media drive, and the media is not present. */ vdev_error(gettext("'%s' has no media in drive\n"), name); return (-1); } else if (err != 0) { libdiskmgt_error(err); } return (0); }