From patchwork Mon Feb 4 23:15:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 1036327 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-99768-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="UjBBLcox"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43tk8Z04RRz9sN9 for ; Tue, 5 Feb 2019 10:15:41 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id :mime-version:content-type; q=dns; s=default; b=NiQppuX1RWRD3QBu h7uC+ceuuo8Y805+8WQz0A+f9jpiQn7rvNJOLMJQ46LVMeiCifi9YMCavWBws9ky 1x900+pfJhuNEtsdJ0s4SbetsjRsku/P0qR7k/fS4r8ZFRv9gacs8MqAApb5faMS q2Qp1jJ6fB7v1+NJr1uWIFPdnHo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id :mime-version:content-type; s=default; bh=dupf5x9Thm2rDPRYbIhwPA Xt+6c=; b=UjBBLcoxgwbNOtUQQUMW9hg3SBSnptqgR4CYf0DT2k+RUYIutTCOdR i6QyoWfbH39JrtmoOcDozcC2r9YRbRU3fJhOL6H4VdmGn1EJeSuiaSUH9Kw7ACU2 Qrj0PO3abfYcn5A3JVwXY+8ejXuCDHJu8T88Qxj+gnr851TRq56lc= Received: (qmail 91591 invoked by alias); 4 Feb 2019 23:15:36 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 91583 invoked by uid 89); 4 Feb 2019 23:15:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Date: Mon, 4 Feb 2019 23:15:28 +0000 From: Joseph Myers To: CC: Subject: Fix assertion in malloc.c:tcache_get Message-ID: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 One of the warnings that appears with -Wextra is "ordered comparison of pointer with integer zero" in malloc.c:tcache_get, for the assertion: assert (tcache->entries[tc_idx] > 0); Indeed, a "> 0" comparison does not make sense for tcache->entries[tc_idx], which is a pointer. My guess is that tcache->counts[tc_idx] is what's intended here, and this patch changes the assertion accordingly. Tested for x86_64. 2019-02-04 Joseph Myers * malloc/malloc.c (tcache_get): Compare tcache->counts[tc_idx] with 0, not tcache->entries[tc_idx]. diff --git a/malloc/malloc.c b/malloc/malloc.c index feaf7ee0bf..13fc1f2049 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -2946,7 +2946,7 @@ tcache_get (size_t tc_idx) { tcache_entry *e = tcache->entries[tc_idx]; assert (tc_idx < TCACHE_MAX_BINS); - assert (tcache->entries[tc_idx] > 0); + assert (tcache->counts[tc_idx] > 0); tcache->entries[tc_idx] = e->next; --(tcache->counts[tc_idx]); e->key = NULL;