From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A8E96C433F5 for ; Tue, 11 Jan 2022 19:57:20 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1EA69811DE; Tue, 11 Jan 2022 20:57:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=arvanta.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id D3EC881B4B; Tue, 11 Jan 2022 19:18:52 +0100 (CET) Received: from fx.arvanta.net (unknown [109.72.52.77]) by phobos.denx.de (Postfix) with ESMTP id 55E8E81429 for ; Tue, 11 Jan 2022 19:18:50 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=arvanta.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mps@arvanta.net Received: from m1 (unknown [10.5.1.15]) by fx.arvanta.net (Postfix) with ESMTP id A31B1245DA; Tue, 11 Jan 2022 19:18:49 +0100 (CET) Date: Tue, 11 Jan 2022 19:18:49 +0100 From: Milan =?utf-8?Q?P=2E_Stani=C4=87?= To: Heinrich Schuchardt Cc: Simon Glass , u-boot@lists.denx.de Subject: Re: [PATCH 1/1] sandbox: compatibility of os_get_filesize() Message-ID: References: <20220111005024.179632-1-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220111005024.179632-1-heinrich.schuchardt@canonical.com> X-Mailman-Approved-At: Tue, 11 Jan 2022 20:57:17 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean 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ć > Signed-off-by: Heinrich Schuchardt Tested-by: Milan P. Stanić > --- > 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 >