]> granicus.if.org Git - graphviz/commit
remove undefined behavior in VPSC Constraint output
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 13 Sep 2020 03:51:17 +0000 (20:51 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 19 Sep 2020 16:42:59 +0000 (09:42 -0700)
commit3178647a95d4095a03d679e0c2a8bdb8c6ed62f9
tree54331638c4049b462e39f422b986bdc595733647
parent197460f985bf06970a939a4fdbffb9b8e8a1261c
remove undefined behavior in VPSC Constraint output

The address of a reference parameter can never be NULL. A reference parameter
is, definitionally, non-NULL. So taking the address of a reference parameter and
comparing it against NULL is always false. None of the call sites of this
operator passed in NULL, so this change is a no-op from a user perspective, but
it guards against future misuse.

This addresses the following Coverity warning:

  Error: COMPILER_WARNING: [#def230]
  graphviz-2.40.1/lib/vpsc/constraint.cpp: scope_hint: In function 'std::ostream& operator<<(std::ostream&, const Constraint&)'
  graphviz-2.40.1/lib/vpsc/constraint.cpp:46:7: warning: the compiler can assume that the address of 'c' will never be NULL [-Waddress]
  #  if(&c==NULL) {
  #       ^
  #   44|   std::ostream& operator <<(std::ostream &os, const Constraint &c)
  #   45|   {
  #   46|->   if(&c==NULL) {
  #   47|       os<<"NULL";
  #   48|     } else {

Related to #1464.
lib/vpsc/constraint.cpp