Project

General

Profile

Actions

Bug #9263

closed

rdc: comparison between pointer and zero character constant

Added by Toomas Soome over 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
driver - device drivers
Start date:
2018-03-11
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

Issue found by gcc 7 build:

    ../../common/avs/ns/rdc/rdc_diskq.c:195:27: error: comparison between pointer and zero character constant [-Werror=pointer-compare]
      if (&urdc->disk_queue[0] == '\0') {
                               ^~
    ../../common/avs/ns/rdc/rdc_diskq.c:195:6: note: did you mean to dereference the pointer?
      if (&urdc->disk_queue[0] == '\0') {
          ^
    ../../common/avs/ns/rdc/rdc_diskq.c: In function 'rdc_read_diskq_header':
    ../../common/avs/ns/rdc/rdc_diskq.c:609:28: error: comparison between pointer and zero character constant [-Werror=pointer-compare]
           &urdc->group_name[0] == '\0' ? buf:
                                ^~
    ../../common/avs/ns/rdc/rdc_diskq.c:609:7: note: did you mean to dereference the pointer?
           &urdc->group_name[0] == '\0' ? buf:
           ^
    ../../common/avs/ns/rdc/rdc_diskq.c:629:32: error: comparison between pointer and zero character constant [-Werror=pointer-compare]
           rc, &urdc->group_name[0] == '\0' ? buf :
                                    ^~
    ../../common/avs/ns/rdc/rdc_diskq.c:629:11: note: did you mean to dereference the pointer?
           rc, &urdc->group_name[0] == '\0' ? buf :
               ^
    cc1: all warnings being treated as errors

The disk_queue and group_name above are fixed size char arrays, so taking address there will never evaluate to NULL and the only conclusion is that we indeed want to test for zero length string there.

Actions #1

Updated by Electric Monk about 4 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 90 to 100

git commit 6f9a31a96454e5a48ab600f85d7e8b556b897e1a

commit  6f9a31a96454e5a48ab600f85d7e8b556b897e1a
Author: Toomas Soome <tsoome@me.com>
Date:   2018-04-01T21:48:01.000Z

    9263 rdc: comparison between pointer and zero character constant
    Reviewed by: Jason King <jason.brian.king@gmail.com>
    Reviewed by: Andy Fiddaman <omnios@citrus-it.co.uk>
    Approved by: Gordon Ross <gwr@nexenta.com>

Actions

Also available in: Atom PDF