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-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id E5A661F4B4 for ; Mon, 4 Jan 2021 16:18:18 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B153C388A436; Mon, 4 Jan 2021 16:18:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B153C388A436 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1609777097; bh=EXQ241Rp9SHwqUvd7na/z+TQSYa227AGND52VCxREcU=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=uLG1I0blnzSCEPESONH3d09BCbOL7qEqC4ChoWCjPAagI+dp91FZiZowp7RdNJ5as FT9vZp99dNhjDLPEbsAPk8kXzABEeuiPkRyTZNeDPi+gdKpwaEMQDqAusPYtBh65Df /sgA5Oy3e/7fBh0h/+RemjbWlL4qUbQZOPYrF7O8= Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) by sourceware.org (Postfix) with ESMTPS id DC13C388703E for ; Mon, 4 Jan 2021 16:18:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DC13C388703E Received: by mail-oi1-x22b.google.com with SMTP id q25so32663180oij.10 for ; Mon, 04 Jan 2021 08:18:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=EXQ241Rp9SHwqUvd7na/z+TQSYa227AGND52VCxREcU=; b=SpACpp7zajo42Geqas0oVaZ6UNrGf1+gxalR2dy6LjLWoRGQ9P7GdWqYhFfN9Iiyp2 RX3ZBVCXgmRWAwPsr+TtcDoDUT7bYsfac4UCItuIueUpENncUFypvayCUPWhrDuZRcCl rgPFK5RPJvll398HcsazoI9wtIk62YkWgbHsf2yCB24EyhVKBikXEnAR7/1cSIE7HfFx opeMf3Zkn2S0X8j8X0bsCFoE3KVcohwTsD5mvi1G7DEThMSMfORqSnzFjQUm9V+1S9QA QDRFXpR1rkr/Kf7c7NH8KvIZYfAHFA5s47ARp/n2qNie2uv23it1dP8bwI3J0KOk6J8Z a+aA== X-Gm-Message-State: AOAM5324jnOSZLrYOofiGcMdeZGdyRM3YD4b7bdgNC5WzK1mGOY6tXf0 E/ByAVrb35Gv5820aF1IrVQ= X-Google-Smtp-Source: ABdhPJznvr6aqodk2vNv1SLWvDT6FV/W/O7M2RKnQSx4lnW1V/+Qygs/EP+ecYJhbEHUM79mCYRykw== X-Received: by 2002:a05:6808:3ac:: with SMTP id n12mr18608885oie.142.1609777094338; Mon, 04 Jan 2021 08:18:14 -0800 (PST) Received: from [192.168.0.41] (75-166-96-128.hlrn.qwest.net. [75.166.96.128]) by smtp.gmail.com with ESMTPSA id t18sm13579908otc.64.2021.01.04.08.18.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 Jan 2021 08:18:13 -0800 (PST) Subject: Re: [PATCH] add support for -Wmismatched-dealloc To: Florian Weimer , Martin Sebor via Libc-alpha References: <74efece7-9a4b-83ee-7fdd-475c0d514378@gmail.com> <758e723b-67cf-a211-7bc2-2ccd3fc744e5@gmail.com> <2555516b-4583-21fc-e844-fd44619488cd@gmail.com> <655918b2-16c6-74b1-6a49-505a7607007f@gmail.com> <87mtxok7ob.fsf@oldenburg2.str.redhat.com> Message-ID: <0aae9006-6001-8fc8-ad6d-c8e3ee60f82c@gmail.com> Date: Mon, 4 Jan 2021 09:18:12 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <87mtxok7ob.fsf@oldenburg2.str.redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Martin Sebor via Libc-alpha Reply-To: Martin Sebor Cc: Joseph Myers Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" On 1/4/21 9:07 AM, Florian Weimer wrote: > * Martin Sebor via Libc-alpha: > >> diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h >> index 9cf8b05a87..4c1c7f1119 100644 >> --- a/wcsmbs/wchar.h >> +++ b/wcsmbs/wchar.h >> @@ -151,7 +151,8 @@ extern size_t wcsxfrm_l (wchar_t *__s1, const wchar_t *__s2, >> size_t __n, locale_t __loc) __THROW; >> >> /* Duplicate S, returning an identical malloc'd string. */ >> -extern wchar_t *wcsdup (const wchar_t *__s) __THROW __attribute_malloc__; >> +extern wchar_t *wcsdup (const wchar_t *__s) __THROW >> + __attribute_malloc__ __attr_dealloc_free; >> #endif >> >> /* Find the first occurrence of WC in WCS. */ >> @@ -562,9 +563,18 @@ extern wchar_t *wcpncpy (wchar_t *__restrict __dest, >> /* Wide character I/O functions. */ >> >> #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2) >> +# ifdef __REDIRECT >> +/* Declare the __fclose alias and associate it as a deallocator >> + with open_wmemstream below. */ >> +extern int __REDIRECT (__fclose, (FILE *), fclose); >> +# define __attr_dealloc_fclose __attr_dealloc (__fclose, 1) >> +# else >> +# define __attr_dealloc_fclose /* empty */ >> +# endif >> /* Like OPEN_MEMSTREAM, but the stream is wide oriented and produces >> a wide character string. */ >> -extern __FILE *open_wmemstream (wchar_t **__bufloc, size_t *__sizeloc) __THROW; >> +extern __FILE *open_wmemstream (wchar_t **__bufloc, size_t *__sizeloc) __THROW >> + __attribute_malloc__ __attr_dealloc_fclose; >> #endif >> >> #if defined __USE_ISOC95 || defined __USE_UNIX98 > > Why is an alias for fclose needed here, but not for free? Because fclose is not a built-in so there's no __builtin_fclose to associate open_wmemstream with. free is a built-in and so __attr_dealloc_free just references __builtin_free and doesn't need an explicit declaration. Martin > > Thanks, > Florian >