[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJ3WTWRQcZN5JSNAhUKXfpH8Q5sW_-EorMpgCE24G3NpczpqZQ@mail.gmail.com>
Date: Mon, 13 May 2024 11:43:08 +0200
From: Mirsad Todorovac <mtodorovac69@...il.com>
To: Jarkko Sakkinen <jarkko@...nel.org>
Cc: John Hubbard <jhubbard@...dia.com>, linux-kselftest@...r.kernel.org,
Dave Hansen <dave.hansen@...ux.intel.com>, Shuah Khan <shuah@...nel.org>,
linux-sgx@...r.kernel.org, linux-kernel@...r.kernel.org,
Edward Liaw <edliaw@...gle.com>
Subject: Re: [PATCH v1 1/1] selftests/sgx: Fix the implicit declaration of
asprintf() compiler error
Thanks for your explanation.
I did not realise that __USE_GNU is evil. :-/
FWIW, there is a sound explanation of the difference between
_GNU_SOURCE and __USE_GNU
here: https://stackoverflow.com/questions/7296963/gnu-source-and-use-gnu
Thanks,
Mirsad
On Mon, May 13, 2024 at 1:02 AM Jarkko Sakkinen <jarkko@...nel.org> wrote:
>
> On Sat May 11, 2024 at 12:02 AM EEST, Mirsad Todorovac wrote:
> > On 5/10/24 22:52, John Hubbard wrote:
> > > On 5/10/24 1:37 PM, Mirsad Todorovac wrote:
> > > ...
> > >> The fix defines __USE_GNU before including <stdio.h> in case it isn't already
> > >> defined. After this intervention the module compiles OK.
> > >
> > > Instead of interventions, I believe the standard way to do this is to simply
> > > define _GNU_SOURCE before including the header file(s). For example, the
> > > following also fixes the compilation failure on Ubuntu:
> > >
> > > diff --git a/tools/testing/selftests/sgx/main.c b/tools/testing/selftests/sgx/main.c
> > > index 9820b3809c69..bb6e795d06e2 100644
> > > --- a/tools/testing/selftests/sgx/main.c
> > > +++ b/tools/testing/selftests/sgx/main.c
> > > @@ -1,6 +1,7 @@
> > > // SPDX-License-Identifier: GPL-2.0
> > > /* Copyright(c) 2016-20 Intel Corporation. */
> > >
> > > +#define _GNU_SOURCE
> > > #include <cpuid.h>
> > > #include <elf.h>
> > > #include <errno.h>
> > >
> > >
> > > However, that's not required, because Edward Liaw is already on v4 of
> > > a patchset[1] that fixes up the _GNU_SOURCE problem for all selftests.
> > >
> > > [1] https://lore.kernel.org/all/20240510000842.410729-2-edliaw@googlecom/
> > >
> > > thanks,
> >
> > Hi,
> >
> > Yes, I actually like Ed's solution more, because it solves the asprintf() prototype
> > problem with TEST_HARNESS_MAIN macro for all of the tests.
> >
> > Sorry for the noise and the time wasted reviewing. 8-|
> >
> > Best regards,
> > Mirsad Todorovac
>
> Yeah, well, it does not cause any harm and I was not sure when the patch
> set is in mainline so thus gave the pointers. Anyway, never ever touch
> __USE_GNU and always look at the man page from man7.org next time and
> should cause less friction...
>
> BR, Jarkko
Powered by blists - more mailing lists