ltp.lists.linux.it archive mirror
 help / color / mirror / Atom feed
* [LTP] [PATCH 0/2] Build fixes
@ 2024-04-23 13:28 Petr Vorel
  2024-04-23 13:28 ` [LTP] [PATCH 1/2] lapi/fs: Include lapi/fcntl.h + define _GNU_SOURCE Petr Vorel
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Petr Vorel @ 2024-04-23 13:28 UTC (permalink / raw)
  To: ltp

Petr Vorel (2):
  lapi/fs: Include lapi/fcntl.h + define _GNU_SOURCE
  lapi: getrandom05: Add getrandom() fallback

 configure.ac                                      |  1 +
 include/lapi/fs.h                                 |  5 ++++-
 include/lapi/getrandom.h                          | 15 +++++++++++++--
 testcases/kernel/syscalls/getrandom/getrandom05.c |  3 ++-
 testcases/kernel/syscalls/unlink/unlink09.c       |  2 ++
 5 files changed, 22 insertions(+), 4 deletions(-)

-- 
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [LTP] [PATCH 1/2] lapi/fs: Include lapi/fcntl.h + define _GNU_SOURCE
  2024-04-23 13:28 [LTP] [PATCH 0/2] Build fixes Petr Vorel
@ 2024-04-23 13:28 ` Petr Vorel
  2024-04-24  7:59   ` Jan Stancek
  2024-04-23 13:28 ` [LTP] [PATCH 2/2] lapi: getrandom05: Add getrandom() fallback Petr Vorel
  2024-04-23 13:30 ` [LTP] [PATCH 0/2] Build fixes Petr Vorel
  2 siblings, 1 reply; 8+ messages in thread
From: Petr Vorel @ 2024-04-23 13:28 UTC (permalink / raw)
  To: ltp

This fixes build error on musl (alpine):

In file included from unlink09.c:18:
../../../../include/lapi/fs.h:58:15: error: unknown type name 'loff_t'
   58 | static inline loff_t tst_max_lfs_filesize(void)

loff_t is defined in <fcntl.h> (but guarded _GNU_SOURCE), but just for
safety include lapi/fcntl.h in case lapi/fs.h is included in test which
needs fallback definitions from lapi/fs.h.

Because we require _GNU_SOURCE definition for code in lapi/fs.h, that's
why there is the definition in both unlink09.c (the actual fix) and
lapi/fs.h for visibility of the problem.

Fixes: 2cf78f47a ("unlink: Add error tests for EPERM and EROFS")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
#define _GNU_SOURCE pain again. Would you solve it differently?

 include/lapi/fs.h                           | 5 ++++-
 testcases/kernel/syscalls/unlink/unlink09.c | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/lapi/fs.h b/include/lapi/fs.h
index c19ee821d..4680f0090 100644
--- a/include/lapi/fs.h
+++ b/include/lapi/fs.h
@@ -9,15 +9,18 @@
 #ifndef LAPI_FS_H__
 #define LAPI_FS_H__
 
+#define _GNU_SOURCE /* loff_t in <fcntl.h> */
+
 #include "config.h"
+
 #ifndef HAVE_MOUNT_SETATTR
 # ifdef HAVE_LINUX_FS_H
 #  include <linux/fs.h>
 # endif
 #endif
 
-#include <sys/user.h>
 #include <limits.h>
+#include "lapi/fcntl.h"
 #include "lapi/abisize.h"
 
 #ifndef FS_IOC_GETFLAGS
diff --git a/testcases/kernel/syscalls/unlink/unlink09.c b/testcases/kernel/syscalls/unlink/unlink09.c
index cc4b4a07e..7e3fffe5c 100644
--- a/testcases/kernel/syscalls/unlink/unlink09.c
+++ b/testcases/kernel/syscalls/unlink/unlink09.c
@@ -13,6 +13,8 @@
  * - EROFS when target file is on a read-only filesystem.
  */
 
+#define _GNU_SOURCE /* loff_t in <fcntl.h> */
+
 #include <sys/ioctl.h>
 #include "tst_test.h"
 #include "lapi/fs.h"
-- 
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [LTP] [PATCH 2/2] lapi: getrandom05: Add getrandom() fallback
  2024-04-23 13:28 [LTP] [PATCH 0/2] Build fixes Petr Vorel
  2024-04-23 13:28 ` [LTP] [PATCH 1/2] lapi/fs: Include lapi/fcntl.h + define _GNU_SOURCE Petr Vorel
@ 2024-04-23 13:28 ` Petr Vorel
  2024-04-23 13:30 ` [LTP] [PATCH 0/2] Build fixes Petr Vorel
  2 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2024-04-23 13:28 UTC (permalink / raw)
  To: ltp

Fix missing getrandom() support detection on glibc < 2.25 and musl
< 1.1.20.

Add m4 check and use lapi header in getrandom05 to fix error:

    getrandom05.c:16:24: fatal error: sys/random.h: No such file or directory
    #include <sys/random.h>

on openSUSE Leap 42.2 (glibc 2.22, kernel 4.4).

NOTE: getrandom() requires Linux >= 3.17, which is not supported. While
it'd be quite easy to check (it would require e.g. AC_LINK_IFELSE()
check), I skipped that, because we are going to drop kernel 3.10 support.

Fixes: d9280782d ("getrandom: Add negative tests for getrandom")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Based on the fix I did some this last year for nfs-utils:

https://git.linux-nfs.org/?p=steved/nfs-utils.git;a=commitdiff;h=f92fd6ca815025c435dabf45da28472ac0aa04a4

For LTP I decided to ignore kernel 3.10 support check, thus it's enough
just to check for <sys/random.h>.

Can we drop 3.10 support? I suppose yes, but more ack for my commit
would be great.

https://patchwork.ozlabs.org/project/ltp/patch/20240419124221.207445-1-pvorel@suse.cz/
https://lore.kernel.org/ltp/20240419124221.207445-1-pvorel@suse.cz/

Kind regards,
Petr

 configure.ac                                      |  1 +
 include/lapi/getrandom.h                          | 15 +++++++++++++--
 testcases/kernel/syscalls/getrandom/getrandom05.c |  3 ++-
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1d7e862d8..15a5847fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -76,6 +76,7 @@ AC_CHECK_HEADERS_ONCE([ \
     sys/inotify.h \
     sys/pidfd.h
     sys/prctl.h \
+    sys/random.h \
     sys/shm.h \
     sys/timerfd.h \
     sys/ustat.h \
diff --git a/include/lapi/getrandom.h b/include/lapi/getrandom.h
index c654ca1ac..706ef9b8f 100644
--- a/include/lapi/getrandom.h
+++ b/include/lapi/getrandom.h
@@ -8,10 +8,14 @@
 
 #include "config.h"
 
-#if HAVE_LINUX_RANDOM_H
-#include <linux/random.h>
+#ifdef HAVE_SYS_RANDOM_H
+# include <sys/random.h>
+#elif HAVE_LINUX_RANDOM_H
+# include <linux/random.h>
 #endif
 
+#include "lapi/syscalls.h"
+
 /*
  * Flags for getrandom(2)
  *
@@ -27,4 +31,11 @@
 # define GRND_RANDOM	0x0002
 #endif
 
+#ifndef HAVE_SYS_RANDOM_H
+static inline int getrandom(void *buf, size_t buflen, unsigned int flags)
+{
+	return tst_syscall(SYS_getrandom, buf, buflen, flags);
+}
+#endif
+
 #endif /* LAPI_GETRANDOM_H__ */
diff --git a/testcases/kernel/syscalls/getrandom/getrandom05.c b/testcases/kernel/syscalls/getrandom/getrandom05.c
index 1a9614330..92098deb7 100644
--- a/testcases/kernel/syscalls/getrandom/getrandom05.c
+++ b/testcases/kernel/syscalls/getrandom/getrandom05.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (c) 2024 FUJITSU LIMITED. All Rights Reserved.
+ * Copyright (c) Linux Test Project, 2024
  * Author: Yang Xu <xuyang2018.jy@fujitsu.com>
  */
 
@@ -13,8 +14,8 @@
  * - EINVAL when flag is invalid
  */
 
-#include <sys/random.h>
 #include "tst_test.h"
+#include "lapi/getrandom.h"
 
 static char buff_efault[64];
 static char buff_einval[64];
-- 
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [LTP] [PATCH 0/2] Build fixes
  2024-04-23 13:28 [LTP] [PATCH 0/2] Build fixes Petr Vorel
  2024-04-23 13:28 ` [LTP] [PATCH 1/2] lapi/fs: Include lapi/fcntl.h + define _GNU_SOURCE Petr Vorel
  2024-04-23 13:28 ` [LTP] [PATCH 2/2] lapi: getrandom05: Add getrandom() fallback Petr Vorel
@ 2024-04-23 13:30 ` Petr Vorel
  2 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2024-04-23 13:30 UTC (permalink / raw)
  To: ltp

Hi,

> Petr Vorel (2):
>   lapi/fs: Include lapi/fcntl.h + define _GNU_SOURCE
>   lapi: getrandom05: Add getrandom() fallback

FYI tested:
https://github.com/pevik/ltp/actions/runs/8801203188

Kind regards,
Petr

>  configure.ac                                      |  1 +
>  include/lapi/fs.h                                 |  5 ++++-
>  include/lapi/getrandom.h                          | 15 +++++++++++++--
>  testcases/kernel/syscalls/getrandom/getrandom05.c |  3 ++-
>  testcases/kernel/syscalls/unlink/unlink09.c       |  2 ++
>  5 files changed, 22 insertions(+), 4 deletions(-)

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [LTP] [PATCH 1/2] lapi/fs: Include lapi/fcntl.h + define _GNU_SOURCE
  2024-04-23 13:28 ` [LTP] [PATCH 1/2] lapi/fs: Include lapi/fcntl.h + define _GNU_SOURCE Petr Vorel
@ 2024-04-24  7:59   ` Jan Stancek
  2024-04-24 12:17     ` Petr Vorel
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Stancek @ 2024-04-24  7:59 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

On Tue, Apr 23, 2024 at 3:28 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> This fixes build error on musl (alpine):
>
> In file included from unlink09.c:18:
> ../../../../include/lapi/fs.h:58:15: error: unknown type name 'loff_t'
>    58 | static inline loff_t tst_max_lfs_filesize(void)
>
> loff_t is defined in <fcntl.h> (but guarded _GNU_SOURCE), but just for
> safety include lapi/fcntl.h in case lapi/fs.h is included in test which
> needs fallback definitions from lapi/fs.h.

You probably meant lapi/fcntl.h here ^^

>
> Because we require _GNU_SOURCE definition for code in lapi/fs.h, that's
> why there is the definition in both unlink09.c (the actual fix) and
> lapi/fs.h for visibility of the problem.
>
> Fixes: 2cf78f47a ("unlink: Add error tests for EPERM and EROFS")
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> #define _GNU_SOURCE pain again. Would you solve it differently?

I'd likely go similar route, but I'd drop the hunk from unlink09.c.
The test is not using loff_t directly, it includes a header, so it
should be up to
that header to work without pre-existing defines.

>
>  include/lapi/fs.h                           | 5 ++++-
>  testcases/kernel/syscalls/unlink/unlink09.c | 2 ++
>  2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/include/lapi/fs.h b/include/lapi/fs.h
> index c19ee821d..4680f0090 100644
> --- a/include/lapi/fs.h
> +++ b/include/lapi/fs.h
> @@ -9,15 +9,18 @@
>  #ifndef LAPI_FS_H__
>  #define LAPI_FS_H__
>
> +#define _GNU_SOURCE /* loff_t in <fcntl.h> */

I'd also add to comment here that it's included via lapi/fcntl.h

> +
>  #include "config.h"
> +
>  #ifndef HAVE_MOUNT_SETATTR
>  # ifdef HAVE_LINUX_FS_H
>  #  include <linux/fs.h>
>  # endif
>  #endif
>
> -#include <sys/user.h>
>  #include <limits.h>
> +#include "lapi/fcntl.h"
>  #include "lapi/abisize.h"
>
>  #ifndef FS_IOC_GETFLAGS
> diff --git a/testcases/kernel/syscalls/unlink/unlink09.c b/testcases/kernel/syscalls/unlink/unlink09.c
> index cc4b4a07e..7e3fffe5c 100644
> --- a/testcases/kernel/syscalls/unlink/unlink09.c
> +++ b/testcases/kernel/syscalls/unlink/unlink09.c
> @@ -13,6 +13,8 @@
>   * - EROFS when target file is on a read-only filesystem.
>   */
>
> +#define _GNU_SOURCE /* loff_t in <fcntl.h> */
> +
>  #include <sys/ioctl.h>
>  #include "tst_test.h"
>  #include "lapi/fs.h"
> --
> 2.43.0
>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [LTP] [PATCH 1/2] lapi/fs: Include lapi/fcntl.h + define _GNU_SOURCE
  2024-04-24  7:59   ` Jan Stancek
@ 2024-04-24 12:17     ` Petr Vorel
  2024-04-25 13:23       ` Jan Stancek
  0 siblings, 1 reply; 8+ messages in thread
From: Petr Vorel @ 2024-04-24 12:17 UTC (permalink / raw)
  To: Jan Stancek; +Cc: ltp

Hi Jan,

> On Tue, Apr 23, 2024 at 3:28 PM Petr Vorel <pvorel@suse.cz> wrote:

> > This fixes build error on musl (alpine):

> > In file included from unlink09.c:18:
> > ../../../../include/lapi/fs.h:58:15: error: unknown type name 'loff_t'
> >    58 | static inline loff_t tst_max_lfs_filesize(void)

> > loff_t is defined in <fcntl.h> (but guarded _GNU_SOURCE), but just for
> > safety include lapi/fcntl.h in case lapi/fs.h is included in test which
> > needs fallback definitions from lapi/fs.h.

> You probably meant lapi/fcntl.h here ^^

+1

> > Because we require _GNU_SOURCE definition for code in lapi/fs.h, that's
> > why there is the definition in both unlink09.c (the actual fix) and
> > lapi/fs.h for visibility of the problem.

> > Fixes: 2cf78f47a ("unlink: Add error tests for EPERM and EROFS")
> > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> > ---
> > #define _GNU_SOURCE pain again. Would you solve it differently?

> I'd likely go similar route, but I'd drop the hunk from unlink09.c.
> The test is not using loff_t directly, it includes a header, so it
> should be up to

First, thanks a lot for your review!

OK, this will work, just lapi/fs.h must be loaded before tst_test.h,
othewise it would fail on Alpine:

In file included from unlink09.c:20:
../../../../include/lapi/fs.h:61:15: error: unknown type name 'loff_t'
   61 | static inline loff_t tst_max_lfs_filesize(void)
      |               ^~~~~~
../../../../include/lapi/fs.h: In function 'tst_max_lfs_filesize':
../../../../include/lapi/fs.h:64:17: error: 'loff_t' undeclared (first use in this function); did you mean 'off_t'?
   64 |         return (loff_t)LLONG_MAX;
      |                 ^~~~~~
      |                 off_t
../../../../include/lapi/fs.h:64:17: note: each undeclared identifier is reported only once for each function it appears in
../../../../include/lapi/fs.h:64:24: error: expected ';' before numeric constant
   64 |         return (loff_t)LLONG_MAX;
      |                        ^
      |                        ;
make: *** [../../../../include/mk/rules.mk:45: unlink09] Error 1

(glibc hides loff_t behind __USE_MISC, which I thought it it's in the end
_GNU_SOURCE, but obviously not).

And using include/lapi/fs.h and most of lapi headers it's ok to use them before
tst_test.h (some of them are still used for the old API). But
include/lapi/getrandom.h will break this assumption and it can cause the
troubles if include/lapi/getrandom.h needs include/lapi/fcntl.h or <fcntl.h>).

Also my not-yet-finished effort with safe_fallocate() [1] had this problem
(requires <fcntl.h>), but I'll solve this with providing fallocate() declaration
as you suggested.

> that header to work without pre-existing defines.


> >  include/lapi/fs.h                           | 5 ++++-
> >  testcases/kernel/syscalls/unlink/unlink09.c | 2 ++
> >  2 files changed, 6 insertions(+), 1 deletion(-)

> > diff --git a/include/lapi/fs.h b/include/lapi/fs.h
> > index c19ee821d..4680f0090 100644
> > --- a/include/lapi/fs.h
> > +++ b/include/lapi/fs.h
> > @@ -9,15 +9,18 @@
> >  #ifndef LAPI_FS_H__
> >  #define LAPI_FS_H__

> > +#define _GNU_SOURCE /* loff_t in <fcntl.h> */

> I'd also add to comment here that it's included via lapi/fcntl.h

+1

Kind regards,
Petr

[1] https://lore.kernel.org/ltp/20240412114616.GB427746@pevik/

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [LTP] [PATCH 1/2] lapi/fs: Include lapi/fcntl.h + define _GNU_SOURCE
  2024-04-24 12:17     ` Petr Vorel
@ 2024-04-25 13:23       ` Jan Stancek
  2024-04-25 15:38         ` Petr Vorel
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Stancek @ 2024-04-25 13:23 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

On Wed, Apr 24, 2024 at 2:17 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi Jan,
>
> > On Tue, Apr 23, 2024 at 3:28 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> > > This fixes build error on musl (alpine):
>
> > > In file included from unlink09.c:18:
> > > ../../../../include/lapi/fs.h:58:15: error: unknown type name 'loff_t'
> > >    58 | static inline loff_t tst_max_lfs_filesize(void)
>
> > > loff_t is defined in <fcntl.h> (but guarded _GNU_SOURCE), but just for
> > > safety include lapi/fcntl.h in case lapi/fs.h is included in test which
> > > needs fallback definitions from lapi/fs.h.
>
> > You probably meant lapi/fcntl.h here ^^
>
> +1
>
> > > Because we require _GNU_SOURCE definition for code in lapi/fs.h, that's
> > > why there is the definition in both unlink09.c (the actual fix) and
> > > lapi/fs.h for visibility of the problem.
>
> > > Fixes: 2cf78f47a ("unlink: Add error tests for EPERM and EROFS")
> > > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> > > ---
> > > #define _GNU_SOURCE pain again. Would you solve it differently?
>
> > I'd likely go similar route, but I'd drop the hunk from unlink09.c.
> > The test is not using loff_t directly, it includes a header, so it
> > should be up to
>
> First, thanks a lot for your review!
>
> OK, this will work, just lapi/fs.h must be loaded before tst_test.h,
> othewise it would fail on Alpine:

So this is essentially:
------------------------------------------
#include <fcntl.h> // from tst_test.h include chain
#define _GNU_SOURCE // from lapi/fs.h
#include <fcntl.h>

int main(void)
{
        loff_t asd;
        return 0;
}
------------------------------------------

and it doesn't compile. And same applies if you include first any of
these first:
include/lapi/fcntl.h:#include <fcntl.h>
include/lapi/io_uring.h:#include <fcntl.h>
include/lapi/pidfd.h:#include <fcntl.h>
include/safe_macros_fn.h:#include <fcntl.h>
include/tst_safe_macros.h:#include <fcntl.h>

Do we really need for tst_max_lfs_filesize() to return loff_t? If we
changed it to "long long",
we'd avoid lot of issues with includes and _GNU_SOURCE for just single
user of this function.






>
> In file included from unlink09.c:20:
> ../../../../include/lapi/fs.h:61:15: error: unknown type name 'loff_t'
>    61 | static inline loff_t tst_max_lfs_filesize(void)
>       |               ^~~~~~
> ../../../../include/lapi/fs.h: In function 'tst_max_lfs_filesize':
> ../../../../include/lapi/fs.h:64:17: error: 'loff_t' undeclared (first use in this function); did you mean 'off_t'?
>    64 |         return (loff_t)LLONG_MAX;
>       |                 ^~~~~~
>       |                 off_t
> ../../../../include/lapi/fs.h:64:17: note: each undeclared identifier is reported only once for each function it appears in
> ../../../../include/lapi/fs.h:64:24: error: expected ';' before numeric constant
>    64 |         return (loff_t)LLONG_MAX;
>       |                        ^
>       |                        ;
> make: *** [../../../../include/mk/rules.mk:45: unlink09] Error 1
>
> (glibc hides loff_t behind __USE_MISC, which I thought it it's in the end
> _GNU_SOURCE, but obviously not).
>
> And using include/lapi/fs.h and most of lapi headers it's ok to use them before
> tst_test.h (some of them are still used for the old API). But
> include/lapi/getrandom.h will break this assumption and it can cause the
> troubles if include/lapi/getrandom.h needs include/lapi/fcntl.h or <fcntl.h>).
>
> Also my not-yet-finished effort with safe_fallocate() [1] had this problem
> (requires <fcntl.h>), but I'll solve this with providing fallocate() declaration
> as you suggested.
>
> > that header to work without pre-existing defines.
>
>
> > >  include/lapi/fs.h                           | 5 ++++-
> > >  testcases/kernel/syscalls/unlink/unlink09.c | 2 ++
> > >  2 files changed, 6 insertions(+), 1 deletion(-)
>
> > > diff --git a/include/lapi/fs.h b/include/lapi/fs.h
> > > index c19ee821d..4680f0090 100644
> > > --- a/include/lapi/fs.h
> > > +++ b/include/lapi/fs.h
> > > @@ -9,15 +9,18 @@
> > >  #ifndef LAPI_FS_H__
> > >  #define LAPI_FS_H__
>
> > > +#define _GNU_SOURCE /* loff_t in <fcntl.h> */
>
> > I'd also add to comment here that it's included via lapi/fcntl.h
>
> +1
>
> Kind regards,
> Petr
>
> [1] https://lore.kernel.org/ltp/20240412114616.GB427746@pevik/
>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [LTP] [PATCH 1/2] lapi/fs: Include lapi/fcntl.h + define _GNU_SOURCE
  2024-04-25 13:23       ` Jan Stancek
@ 2024-04-25 15:38         ` Petr Vorel
  0 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2024-04-25 15:38 UTC (permalink / raw)
  To: Jan Stancek; +Cc: ltp

Hi Jan, all,

...
> > OK, this will work, just lapi/fs.h must be loaded before tst_test.h,
> > othewise it would fail on Alpine:

> So this is essentially:
> ------------------------------------------
> #include <fcntl.h> // from tst_test.h include chain
> #define _GNU_SOURCE // from lapi/fs.h
> #include <fcntl.h>

> int main(void)
> {
>         loff_t asd;
>         return 0;
> }
> ------------------------------------------

> and it doesn't compile. And same applies if you include first any of
> these first:
> include/lapi/fcntl.h:#include <fcntl.h>
> include/lapi/io_uring.h:#include <fcntl.h>
> include/lapi/pidfd.h:#include <fcntl.h>
> include/safe_macros_fn.h:#include <fcntl.h>
> include/tst_safe_macros.h:#include <fcntl.h>

> Do we really need for tst_max_lfs_filesize() to return loff_t? If we
> changed it to "long long",
> we'd avoid lot of issues with includes and _GNU_SOURCE for just single
> user of this function.

+1. We might get extra warning when there is 32 bit, but it would make things
much easier => I'll send another version.

Kind regards,
Petr


> > In file included from unlink09.c:20:
> > ../../../../include/lapi/fs.h:61:15: error: unknown type name 'loff_t'
> >    61 | static inline loff_t tst_max_lfs_filesize(void)
> >       |               ^~~~~~
> > ../../../../include/lapi/fs.h: In function 'tst_max_lfs_filesize':
> > ../../../../include/lapi/fs.h:64:17: error: 'loff_t' undeclared (first use in this function); did you mean 'off_t'?
> >    64 |         return (loff_t)LLONG_MAX;
> >       |                 ^~~~~~
> >       |                 off_t
> > ../../../../include/lapi/fs.h:64:17: note: each undeclared identifier is reported only once for each function it appears in
> > ../../../../include/lapi/fs.h:64:24: error: expected ';' before numeric constant
> >    64 |         return (loff_t)LLONG_MAX;
> >       |                        ^
> >       |                        ;
> > make: *** [../../../../include/mk/rules.mk:45: unlink09] Error 1

> > (glibc hides loff_t behind __USE_MISC, which I thought it it's in the end
> > _GNU_SOURCE, but obviously not).
...

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-04-25 15:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-23 13:28 [LTP] [PATCH 0/2] Build fixes Petr Vorel
2024-04-23 13:28 ` [LTP] [PATCH 1/2] lapi/fs: Include lapi/fcntl.h + define _GNU_SOURCE Petr Vorel
2024-04-24  7:59   ` Jan Stancek
2024-04-24 12:17     ` Petr Vorel
2024-04-25 13:23       ` Jan Stancek
2024-04-25 15:38         ` Petr Vorel
2024-04-23 13:28 ` [LTP] [PATCH 2/2] lapi: getrandom05: Add getrandom() fallback Petr Vorel
2024-04-23 13:30 ` [LTP] [PATCH 0/2] Build fixes Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).