* [PATCH 1/1] sandbox: compatibility of os_get_filesize()
@ 2022-01-11 0:50 Heinrich Schuchardt
2022-01-11 18:18 ` Milan P. Stanić
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2022-01-11 0:50 UTC (permalink / raw)
To: Simon Glass; +Cc: u-boot, Heinrich Schuchardt, Milan P . Stanić
U-Boot define loff_t as long long. But the header
/usr/include/linux/types.h may not define it.
This has lead to a build error on Alpine Linux.
So let's use long long instead of loff_t for
the size parameter of function os_get_filesize().
Reported-by: Milan P. Stanić <mps@arvanta.net>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
arch/sandbox/cpu/os.c | 10 ++++++++--
include/os.h | 2 +-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 6837bfceaf..40ebe322ae 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -624,7 +624,13 @@ const char *os_dirent_get_typename(enum os_dirent_t type)
return os_dirent_typename[OS_FILET_UNKNOWN];
}
-int os_get_filesize(const char *fname, loff_t *size)
+/*
+ * For compatibility reasons avoid loff_t here.
+ * U-Boot defines loff_t as long long.
+ * But /usr/include/linux/types.h may not define it at all.
+ * Alpine Linux being one example.
+ */
+int os_get_filesize(const char *fname, long long *size)
{
struct stat buf;
int ret;
@@ -667,7 +673,7 @@ int os_read_ram_buf(const char *fname)
{
struct sandbox_state *state = state_get_current();
int fd, ret;
- loff_t size;
+ long long size;
ret = os_get_filesize(fname, &size);
if (ret < 0)
diff --git a/include/os.h b/include/os.h
index 4cbcbd93a7..10e198cf50 100644
--- a/include/os.h
+++ b/include/os.h
@@ -266,7 +266,7 @@ const char *os_dirent_get_typename(enum os_dirent_t type);
* @size: size of file is returned if no error
* Return: 0 on success or -1 if an error ocurred
*/
-int os_get_filesize(const char *fname, loff_t *size);
+int os_get_filesize(const char *fname, long long *size);
/**
* os_putc() - write a character to the controlling OS terminal
--
2.33.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] sandbox: compatibility of os_get_filesize()
2022-01-11 0:50 [PATCH 1/1] sandbox: compatibility of os_get_filesize() Heinrich Schuchardt
@ 2022-01-11 18:18 ` Milan P. Stanić
2022-01-11 18:19 ` Simon Glass
2022-01-13 18:00 ` Simon Glass
2 siblings, 0 replies; 4+ messages in thread
From: Milan P. Stanić @ 2022-01-11 18:18 UTC (permalink / raw)
To: Heinrich Schuchardt; +Cc: Simon Glass, u-boot
On Tue, 2022-01-11 at 01:50, Heinrich Schuchardt wrote:
> U-Boot define loff_t as long long. But the header
> /usr/include/linux/types.h may not define it.
> This has lead to a build error on Alpine Linux.
>
> So let's use long long instead of loff_t for
> the size parameter of function os_get_filesize().
>
> Reported-by: Milan P. Stanić <mps@arvanta.net>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Tested-by: Milan P. Stanić <mps@arvanta.net>
> ---
> arch/sandbox/cpu/os.c | 10 ++++++++--
> include/os.h | 2 +-
> 2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
> index 6837bfceaf..40ebe322ae 100644
> --- a/arch/sandbox/cpu/os.c
> +++ b/arch/sandbox/cpu/os.c
> @@ -624,7 +624,13 @@ const char *os_dirent_get_typename(enum os_dirent_t type)
> return os_dirent_typename[OS_FILET_UNKNOWN];
> }
>
> -int os_get_filesize(const char *fname, loff_t *size)
> +/*
> + * For compatibility reasons avoid loff_t here.
> + * U-Boot defines loff_t as long long.
> + * But /usr/include/linux/types.h may not define it at all.
> + * Alpine Linux being one example.
> + */
> +int os_get_filesize(const char *fname, long long *size)
> {
> struct stat buf;
> int ret;
> @@ -667,7 +673,7 @@ int os_read_ram_buf(const char *fname)
> {
> struct sandbox_state *state = state_get_current();
> int fd, ret;
> - loff_t size;
> + long long size;
>
> ret = os_get_filesize(fname, &size);
> if (ret < 0)
> diff --git a/include/os.h b/include/os.h
> index 4cbcbd93a7..10e198cf50 100644
> --- a/include/os.h
> +++ b/include/os.h
> @@ -266,7 +266,7 @@ const char *os_dirent_get_typename(enum os_dirent_t type);
> * @size: size of file is returned if no error
> * Return: 0 on success or -1 if an error ocurred
> */
> -int os_get_filesize(const char *fname, loff_t *size);
> +int os_get_filesize(const char *fname, long long *size);
>
> /**
> * os_putc() - write a character to the controlling OS terminal
> --
> 2.33.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] sandbox: compatibility of os_get_filesize()
2022-01-11 0:50 [PATCH 1/1] sandbox: compatibility of os_get_filesize() Heinrich Schuchardt
2022-01-11 18:18 ` Milan P. Stanić
@ 2022-01-11 18:19 ` Simon Glass
2022-01-13 18:00 ` Simon Glass
2 siblings, 0 replies; 4+ messages in thread
From: Simon Glass @ 2022-01-11 18:19 UTC (permalink / raw)
To: Heinrich Schuchardt; +Cc: U-Boot Mailing List, Milan P . Stanić
On Mon, 10 Jan 2022 at 17:50, Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> U-Boot define loff_t as long long. But the header
> /usr/include/linux/types.h may not define it.
> This has lead to a build error on Alpine Linux.
>
> So let's use long long instead of loff_t for
> the size parameter of function os_get_filesize().
>
> Reported-by: Milan P. Stanić <mps@arvanta.net>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> arch/sandbox/cpu/os.c | 10 ++++++++--
> include/os.h | 2 +-
> 2 files changed, 9 insertions(+), 3 deletions(-)
Reviewed-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] sandbox: compatibility of os_get_filesize()
2022-01-11 0:50 [PATCH 1/1] sandbox: compatibility of os_get_filesize() Heinrich Schuchardt
2022-01-11 18:18 ` Milan P. Stanić
2022-01-11 18:19 ` Simon Glass
@ 2022-01-13 18:00 ` Simon Glass
2 siblings, 0 replies; 4+ messages in thread
From: Simon Glass @ 2022-01-13 18:00 UTC (permalink / raw)
To: Simon Glass
Cc: U-Boot Mailing List, Heinrich Schuchardt, Milan P . Stanić
On Mon, 10 Jan 2022 at 17:50, Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> U-Boot define loff_t as long long. But the header
> /usr/include/linux/types.h may not define it.
> This has lead to a build error on Alpine Linux.
>
> So let's use long long instead of loff_t for
> the size parameter of function os_get_filesize().
>
> Reported-by: Milan P. Stanić <mps@arvanta.net>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> arch/sandbox/cpu/os.c | 10 ++++++++--
> include/os.h | 2 +-
> 2 files changed, 9 insertions(+), 3 deletions(-)
Reviewed-by: Simon Glass <sjg@chromium.org>
Applied to u-boot-dm, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-01-13 18:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-11 0:50 [PATCH 1/1] sandbox: compatibility of os_get_filesize() Heinrich Schuchardt
2022-01-11 18:18 ` Milan P. Stanić
2022-01-11 18:19 ` Simon Glass
2022-01-13 18:00 ` Simon Glass
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.