From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.tiscali.it (michael-notr.mail.tiscali.it [213.205.33.216]) by sourceware.org (Postfix) with ESMTP id 4EEAD3844008 for ; Thu, 13 Aug 2020 08:05:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4EEAD3844008 Received: from [10.4.107.101] ([62.19.201.173]) by michael.mail.tiscali.it with id Ew5j230193kyJtq01w5kf4; Thu, 13 Aug 2020 08:05:44 +0000 x-auth-user: cl.velati Date: Thu, 13 Aug 2020 10:05:41 +0200 User-Agent: K-9 Mail for Android In-Reply-To: <20200813080112.GT53219@calimero.vinschen.de> References: <20200813080112.GT53219@calimero.vinschen.de> MIME-Version: 1.0 Subject: Re: [PATCH] libc/stdlib: Fix build failure in nano_calloc To: newlib@sourceware.org From: Claudio Message-ID: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Aug 2020 08:05:47 -0000 Please, stop to send mail =2E=2E=2E Thanks Il 13 agosto 2020 10:01:12 CEST, Corinna Vinschen via Newlib ha scritto: >On Aug 12 15:33, Craig Blackmore wrote: >> commit 588a5e1ddebdf6d74391c7409680ea20e050c0e1 added a non-reentrant >> call to nano_malloc which causes a build failure if INTERNAL_NEWLIB >is >> defined=2E >>=20 >> Here is a snippet of the error: >>=20 >> In file included from >=2E=2E=2E/newlib/newlib/libc/stdlib/nano-mallocr=2Ec:38: >> =2E=2E=2E/newlib/newlib/libc/include/malloc=2Eh:42:25: note: expected '= struct >_reent *' but argument is of type 'ptrdiff_t' {aka 'int'} >> 42 | extern void *_malloc_r (struct _reent *, size_t); >> | ^~~~~~~~~~~~~~~ >> =2E=2E=2E/newlib/newlib/libc/stdlib/nano-mallocr=2Ec:67:22: error: too = few >arguments to function '_malloc_r' >> 67 | #define nano_malloc _malloc_r >> | ^~~~~~~~~ >> =2E=2E=2E/newlib/newlib/libc/stdlib/nano-mallocr=2Ec:456:11: note: in >expansion of macro 'nano_malloc' >> 456 | mem =3D nano_malloc(bytes); >> | ^~~~~~~~~~~ >> In file included from >=2E=2E=2E/newlib/newlib/libc/stdlib/nano-mallocr=2Ec:38: >> =2E=2E=2E/newlib/newlib/libc/include/malloc=2Eh:42:14: note: declared h= ere >> 42 | extern void *_malloc_r (struct _reent *, size_t); >> | ^~~~~~~~~ >> =2E=2E=2E/newlib/newlib/libc/stdlib/nano-mallocr=2Ec:43: warning: "asse= rt" >redefined >> 43 | #define assert(x) ((void)0) >> | >>=20 >> This patch adds a missing RCALL to the args when calling nano_malloc >> from nano_calloc, so that if the call is reentrant, reent_ptr is >passed >> as the first argument=2E >>=20 >> The variable `bytes` (also added in 588a5e1d) has been changed from a >> `ptrdiff_t` to `malloc_size_t` as it does not need to be signed=2E It >is >> used to store the product of two unsigned malloc_size_t variables and >> then iff there was no overflow is it passed to malloc and memset >which >> both expect size_t which is unsigned=2E >>=20 >> Signed-off-by: Craig Blackmore >> --- >> newlib/libc/stdlib/nano-mallocr=2Ec | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) > >Pushed=2E > > >Thanks, >Corinna > >--=20 >Corinna Vinschen >Cygwin Maintainer >Red Hat Inviato dall'app Tiscali Mail=2E