11453 zpool: NULL pointer errors

Review Request #2171 — Created July 11, 2019 and submitted

tsoome
illumos-gate
11453
561cce6...
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


  • 2
  • 0
  • 0
  • 0
  • 2
Description From Last Updated
Would be better to remove this. dm_descriptor_t is more-or-less opaque, and if it is possible avoid dereferencing that. If the ... domag02 domag02
Same, this should be in the error handling after the next call of dm_get_associated_descriptors(). domag02 domag02
glasspelican
  1. Ship It!
  2. 
      
alp
  1. Ship It!
  2. 
      
tsoome
Review request changed

Status: Closed (submitted)

domag02
  1. I think it's possible to avoid some of these == 0 checks.

  2. 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 of dm_get_associated_descriptors() will return with NULL and err set to ENODEV.

    This line should be:

            &err)) == NULL) {
    
  3. 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().

  4. 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);
        }
    
  5. 
      
Loading...