9400 avs: comparison between pointer and zero character constant

Review Request #1043 - Created March 28, 2018 and submitted

Information
Toomas Soome
illumos-gate
9400
9b18cf6...
Reviewers
general
sndrsyncd.c: In function 'cleanup_hostlist':
sndrsyncd.c:1023:29: error: comparison between pointer and zero character constant [-Werror=pointer-compare]
        (host_list->hosts[i] == '\0')) {
                             ^~
sndrsyncd.c:1023:9: note: did you mean to dereference the pointer?
        (host_list->hosts[i] == '\0')) {
         ^
cc1: all warnings being treated as errors

  

Issues

  • 1
  • 0
  • 0
  • 1
Description From Last Updated
I'm not convinced that this is correct. I'd assume that hosts[i] is always != NULL if configured[i] is true. While ... Hans Rosenfeld Hans Rosenfeld
Andy Fiddaman
C Fraire
Toomas Soome
Review request changed

Status: Closed (submitted)

Hans Rosenfeld

   
usr/src/cmd/avs/rdc/sndrsyncd.c (Diff revision 1)
 
 
 

I'm not convinced that this is correct. I'd assume that hosts[i] is always != NULL if configured[i] is true. While I'm not against checking that separately, I do believe the original intent was to check that hosts[i] doesn't point to an empty string.

So this particular check should very likely be for *hosts[i] == '\0'.

  1. It is actually more complicated, because we should not get host entry inserted if it did not pass self_check() test - which is about verifying the hostname, see http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/librdc/common/netaddrs.c#146

    However, we possibly can have NULL pointers in that list if something went wrong with keeping host_list->configured array in sync (we calloc the host_list, and we assign hosts[] entry from strdup(), result of strdup is not checked... there are more bugs in this code).

Loading...