From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by sourceware.org (Postfix) with ESMTPS id CDCCA3850408 for ; Tue, 21 Feb 2023 18:44:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CDCCA3850408 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f50.google.com with SMTP id l7-20020a05600c1d0700b003dc4050c94aso3782683wms.4 for ; Tue, 21 Feb 2023 10:44:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:cc:to:subject :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ctWJNsHVn9czYYrwLXYi5Vp4oac9s5dxYTmXegWu80A=; b=cAmIAvZwKw0c6/ftoXaWK4IjS40v3AY+CA9i+uCpJE+x1z1cllSmkCkakyFfVsjL7R JT9yfNixXGUr2VrvZDmviiSDy28NxRCftPLXA2FTVobmkOBDrDQO+ooP+WBEioibXQok nf59AAPGWMS2aEuso4S0B3EHhLSaohrQyoSW0evAYuGlE6lpBgHZQTYmHHT2p/cmwBnA YPmzyTp9Z75p6rne4YSkyfwSHUqISjvXF2X6qydQ9coEf1abViDrf+9E43c0+njYmy5v jq3hpIwI+FvJ3O6bGMkCPA9e9wnwUti2BHuU0OoKS5m7DbmLEzwQryPExUvgSZ5RYS0o 9FhA== X-Gm-Message-State: AO0yUKW6SHSEloUiOjvVHu9O3o8scjszS9gJbZmbmA6Hv2L6qMaQURL+ GXifpXdxXSSJ9Y2srNIzEA8= X-Google-Smtp-Source: AK7set/QGYlsrcrs4RS7NHZz+Y8yLveVZWQLzqGyIRpXLYCtoxUY9CtprDno9REmt1kUwMj8u7Xy5g== X-Received: by 2002:a05:600c:1615:b0:3e5:16a1:f478 with SMTP id m21-20020a05600c161500b003e516a1f478mr4649564wmn.27.1677005084596; Tue, 21 Feb 2023 10:44:44 -0800 (PST) Received: from ?IPv6:2001:8a0:f92b:9e00::1fe? ([2001:8a0:f92b:9e00::1fe]) by smtp.gmail.com with ESMTPSA id k17-20020a7bc411000000b003dfee43863fsm4734927wmi.26.2023.02.21.10.44.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Feb 2023 10:44:44 -0800 (PST) Subject: Re: [PATCH] ld: Sort section contributions in PDB files To: Jan Beulich , Nick Clifton Cc: binutils@sourceware.org, Mark Harmstone , Alan Modra References: <20230220141328.20441-1-mark@harmstone.com> <7027c7ac-0e65-0bbb-22d3-167b929247f9@redhat.com> <6ab057e8-43aa-93b4-511c-348b3b2e23e3@suse.com> From: Pedro Alves Message-ID: Date: Tue, 21 Feb 2023 18:44:42 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <6ab057e8-43aa-93b4-511c-348b3b2e23e3@suse.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 2023-02-21 11:03 a.m., Jan Beulich via Binutils wrote: > On 21.02.2023 11:49, Nick Clifton wrote: >> On a related note - I would consider this line to be problematic: >> >> sc_in = xmalloc (num_sc * sizeof (struct in_sc)); >> >> The code here implies that "sc_in" is a pointer to the "struct in_sc" type. >> If at some future date the code is changed and the type of "sc_in" is changed >> then the above line will still work, but the wrong amount of space will be >> allocated. > > Oh, indeed, another pattern I would normally feel tempted to comment on, just > that I've overlooked it this time. > >> So I would suggest changing it to either: >> >> sc_in = xmalloc (num_sc * sizeof (* sc_in)); > > Yes. > >> Or: >> >> sc_in = xmalloc (num_sc * sizeof * sc_in); /* I like this version, but nobody else does ... :-) */ > > Well ... * is commutative as a binary operator, so how about re-writing > it to > > sc_in = xmalloc (num_sc * sc_in * sizeof); > > ;-) ? > >> Or: >> >> sc_in = XNEWVEC (typeof (sc_in), num_sc); > > I guess this one's the form that's best in line with what's used elsewhere > in binutils. 'typeof' is a GNU extension, though. Switch to C++ and use 'decltype'? :-D