[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v1 03/10] abg-reader: clarify boolean use of assignment



When compiling with clang, the following warning is emitted:

abg-reader.cc:1981:15: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
  while (corp = read_corpus_from_input(ctxt))
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

That is certainly a common pitfall and can be mitigated by placing
parentheses around the assignment.

 * src/abg-reader.cc: clarify boolean use of assignment

Signed-off-by: Matthias Maennich <maennich@google.com>
---
 src/abg-reader.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/abg-reader.cc b/src/abg-reader.cc
index 2204e153e7c1..69329d1f1cb5 100644
--- a/src/abg-reader.cc
+++ b/src/abg-reader.cc
@@ -1978,7 +1978,7 @@ read_corpus_group_from_input(read_context& ctxt)
   ctxt.set_corpus_node(node);
 
   corpus_sptr corp;
-  while (corp = read_corpus_from_input(ctxt))
+  while ((corp = read_corpus_from_input(ctxt)))
     ctxt.get_corpus_group()->add_corpus(corp);
 
   xmlTextReaderNext(reader.get());
-- 
2.21.0.392.gf8f6787159e-goog