From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.4 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id C6DFA1F4B4 for ; Mon, 5 Apr 2021 13:26:16 +0000 (UTC) Received: from localhost ([::1]:37118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lTPF9-0002ZD-IG for normalperson@yhbt.net; Mon, 05 Apr 2021 09:26:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47844) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lTPEu-0002Yd-V4 for bug-gnulib@gnu.org; Mon, 05 Apr 2021 09:26:02 -0400 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]:38845) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lTPEm-0003wf-N7 for bug-gnulib@gnu.org; Mon, 05 Apr 2021 09:25:59 -0400 Received: by mail-ej1-x635.google.com with SMTP id r12so16814100ejr.5 for ; Mon, 05 Apr 2021 06:25:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=eav3bh6PqxRu8Vs1rfP4QWfOdDR12caVBb7nJt2raT8=; b=EsqMFBa0dgJAX8+7ms4oMp830q7xjbseofDuKDK0zx7pQ+Hnd8iyw2yPzlbw5S2Qnr RZxlPKX2xCqNnJDxdpP1HppvvJgAZvsXMMeWNn0pkoDForKHCzQsgwNthyZv8B7T+lQ4 Ey1zXiKQ/+/dCnGlp80/hSHSHptz8IMxG0e5Kf871bNWbvjZFhPnwMba6krhGMinYhCk YEUetIwK7g5edCnss830GL3BrKoAkJN82b+KGy+kCAzMzuMjgAEVBsBEFghoc2tkOF0P r4jbkXOcWZQpaAMghSlHJ5t8sHRAKnqobB4b3Uh/5ca9kDqqJzEwU0nPTQYgLgXOytij CA4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=eav3bh6PqxRu8Vs1rfP4QWfOdDR12caVBb7nJt2raT8=; b=O1/+FSeBVWwwTENAoqoy5g2DkNadppyBpvCwOfpttY/rUFZc8q+9xnS+6J2bExwOAq KqOfoqtA8h+wTTM2fLh/5YmqoX0fzLONIh0y6c6Akk/Kgr+jpZlNH1bWwDDLg3n6EXSh /rLWOBsZK5bdHN0VbYQQxnYWROARW+Qe8sSGqdTo0k6iTLKQGvx+hW1AvoX50iEJowxO AwQ3uYA5x2r1sLtnJjdQXN3OyhCk2VjbUie0WoW2+Cpf77Qppzh3+1a4bTUBZi25A5pM k/km/h8j6NMxXhB9UPHxygp8Mh9rjaSlmGfZBykBBnR+Ax+PqJyCnoWyHBr6juezOsKs GUfQ== X-Gm-Message-State: AOAM530DRD7Qhn6gv2H80m3sVBXf731PuujD5m7/npu4he1OcT5XDjPV e/gInvqg19OQ9TBvbNLFiU6tk4KSAa0LAw== X-Google-Smtp-Source: ABdhPJxAtHqGFtcTWLZdtPyaCzHCeX5td16DzmwfoVHw8M64xgnMFM2T+lDcCT8xETj/cJYXNjH17A== X-Received: by 2002:a17:906:2710:: with SMTP id z16mr28665272ejc.176.1617629150328; Mon, 05 Apr 2021 06:25:50 -0700 (PDT) Received: from caesar.mshome.net (ipbcc1ad82.dynamic.kabel-deutschland.de. [188.193.173.130]) by smtp.gmail.com with ESMTPSA id j7sm11092362edv.40.2021.04.05.06.25.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Apr 2021 06:25:49 -0700 (PDT) From: =?UTF-8?q?Marc=20Nieper-Wi=C3=9Fkirchen?= To: bug-gnulib@gnu.org Subject: [PATCH 1/1] hamt: Fix coding errors. Date: Mon, 5 Apr 2021 15:25:46 +0200 Message-Id: <20210405132546.1625039-1-marc.nieper+gnu@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::635; envelope-from=marc.nieper+gnu@gmail.com; helo=mail-ej1-x635.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc=20Nieper-Wi=C3=9Fkirchen?= Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" From: Marc Nieper-Wißkirchen Reported by Bruno Haible in after a Coverity run. * lib/hamt.c (bucket_do_while, hamt_iterator): Add missing derefencing operator and silence a bogus warning on uninitialized variables. * tests/test-hamt.c (test_general): Replace two errorneous assignment operators with comparison operators. --- ChangeLog | 12 ++++++++++++ lib/hamt.c | 6 +++--- tests/test-hamt.c | 4 ++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index e8a27df73..81d3aab73 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2021-04-05 Marc Nieper-Wißkirchen + + hamt: Fix coding errors. + Reported by Bruno Haible in + + after a Coverity run. + * lib/hamt.c (bucket_do_while, hamt_iterator): Add missing + derefencing operator and silence a bogus warning on uninitialized + variables. + * tests/test-hamt.c (test_general): Replace two errorneous + assignment operators with comparison operators. + 2021-04-05 Fabrice Fontaine pthread-cond: Fix compilation error. diff --git a/lib/hamt.c b/lib/hamt.c index 204c2f069..34880eff4 100644 --- a/lib/hamt.c +++ b/lib/hamt.c @@ -873,7 +873,7 @@ bucket_do_while (const struct bucket *bucket, Hamt_processor *proc, void *data, for (size_t i = 0; i < elt_count; ++i) { *success = proc (elts[i], data); - if (!success) + if (*success == false) return cnt; ++cnt; } @@ -946,14 +946,14 @@ hamt_iterator (Hamt *hamt) Hamt_iterator iter; iter.hamt = hamt_copy (hamt); Hamt_entry *entry = hamt->root; + iter.path = 0; + iter.position = 0; if (entry == NULL) { iter.depth = -1; return iter; } iter.depth = 0; - iter.path = 0; - iter.position = 0; while (iter.entry[iter.depth] = entry, entry_type (entry) == subtrie_entry) { const struct subtrie *subtrie = (const struct subtrie *) entry; diff --git a/tests/test-hamt.c b/tests/test-hamt.c index 0cf6eb5a9..882bf0fc7 100644 --- a/tests/test-hamt.c +++ b/tests/test-hamt.c @@ -152,10 +152,10 @@ test_general (void) hamt1 = hamt_remove (hamt2, &x4); sum = 0; ASSERT (hamt_do_while (hamt2, proc, &flag) == 4); - ASSERT (sum = 52); + ASSERT (sum == 52); sum = 0; ASSERT (hamt_do_while (hamt1, proc, &flag) == 3); - ASSERT (sum = 48); + ASSERT (sum == 48); hamt_free (hamt1); hamt_free (hamt2); -- 2.25.1