]> sourceware.org Git - systemtap.git/commitdiff
util.cxx: Use abs() instead of labs()
authorTimm Bäder <tbaeder@redhat.com>
Wed, 19 May 2021 20:23:06 +0000 (16:23 -0400)
committerAaron Merey <amerey@redhat.com>
Wed, 19 May 2021 20:23:06 +0000 (16:23 -0400)
Taking the absolute value of unsigned values is pointless, as reported
by clang:

util.cxx:1545:28: error: taking the absolute value of unsigned type 'unsigned long' has no effect [-Werror,-Wabsolute-value]
      unsigned min_score = labs(target.size() - it->size());
                           ^
util.cxx:1545:28: note: remove the call to 'labs' since unsigned values cannot be negative
      unsigned min_score = labs(target.size() - it->size());

util.cxx

index 518c9c2904e3a5c20a7451cdf264d90cc6c32a8a..cfdbe11f60b9af2e87ee4cecd4d70833888fd86f 100644 (file)
--- a/util.cxx
+++ b/util.cxx
@@ -1542,7 +1542,7 @@ levenshtein_suggest(const string& target,        // string to match against
 
       // Approximate levenshtein by size-difference only; real score
       // is at least this high
-      unsigned min_score = labs(target.size() - it->size());
+      unsigned min_score = abs(static_cast<signed>(target.size()) - static_cast<signed>(it->size()));
 
       if (min_score > threshold) // min-score too high for threshold
         continue;
This page took 0.02459 seconds and 5 git commands to generate.