trinity-devel@lists.pearsoncomputing.net

Message: previous - next
Month: November 2012

katapult: warning: comparison with string literal

From: Darrell Anderson <humanreadable@...>
Date: Thu, 1 Nov 2012 09:30:48 -0700 (PDT)
I noticed the following warning when building katapult:

documentcatalog.cpp:176:57: warning: comparison with string literal results in unspecified behaviour [-Waddress]

From what I gather the problem is trying to compare incompatible data types, usually strings to pointers.

Somebody please review the proposed patch:

======================================
diff -urN katapult/katapult/plugins/catalogs/documentcatalog/documentcatalog.cpp katapult.new/katapult/plugins/catalogs/documentcatalog/documentcatalog.cpp
--- katapult/katapult/plugins/catalogs/documentcatalog/documentcatalog.cpp  2012-09-14 17:40:04.000000000 -0500
+++ katapult.new/katapult/plugins/catalogs/documentcatalog/documentcatalog.cpp  2012-11-01 11:27:44.000000000 -0500
@@ -173,7 +173,7 @@
      if(files.count() > 0)
      {
        newStatus |= S_HasResults;
-       if(files.count() > 1 || files.at(0)->className() == "Directory")
+       if(files.count() > 1 || strcmp(files.at(0)->className(), "Directory"))
          newStatus |= S_Multiple;
      } else
        newStatus |= S_NoResults;
======================================

Thanks!

Darrell