From patchwork Tue Jan 11 00:50:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1578225 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=nDnw+8St; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JXsZ31zgbz9sCD for ; Tue, 11 Jan 2022 11:50:51 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E000E8197D; Tue, 11 Jan 2022 01:50:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.b="nDnw+8St"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6EA15819D3; Tue, 11 Jan 2022 01:50:44 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_FILL_THIS_FORM_SHORT autolearn=ham autolearn_force=no version=3.4.2 Received: from smtp-relay-canonical-1.canonical.com (smtp-relay-canonical-1.canonical.com [185.125.188.121]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B72AA81429 for ; Tue, 11 Jan 2022 01:50:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=heinrich.schuchardt@canonical.com Received: from LT2ubnt.fritz.box (ip-88-152-144-157.hsi03.unitymediagroup.de [88.152.144.157]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id 9EA273F1D6; Tue, 11 Jan 2022 00:50:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1641862238; bh=8WCRAhC01pWIFzFCeVeuTvhLpc4PX7S59CBHXFDq1Cw=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=nDnw+8St0a7b7aaSAjNRP7rgPv3m8cEfIcuX4NgVYkUlIAkvlZX7VXPXkQFJ8EEgE MTAJi4HJBB5YA7cSDnySwnC+f9KhWPuXPJyy9QylJMyX3rO9fzAk3m2T8XyfT4Zseq MvH9pceSgJSsajlPIIRcjFhhZM178/++DYRn6zGbCuHurg2W8YvuV6tT2FSb/3pN3X 9XrgymDLC7zuAXr0xj+KNjAo4ZNiVo0A3y38l5gbePxpTtrjkZgV70xqg9728bypxc 10TwPO7BEOJRSzgOtX59kRW3i5ABHvD3rDT/T1GSIOOBXixfAnwHSae1vi3sYFRWFv vZ4hBloqVDllw== From: Heinrich Schuchardt To: Simon Glass Cc: u-boot@lists.denx.de, Heinrich Schuchardt , =?utf-8?q?Milan_P_?= =?utf-8?q?=2E_Stani=C4=87?= Subject: [PATCH 1/1] sandbox: compatibility of os_get_filesize() Date: Tue, 11 Jan 2022 01:50:24 +0100 Message-Id: <20220111005024.179632-1-heinrich.schuchardt@canonical.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 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 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ć Reviewed-by: Simon Glass Reviewed-by: Simon Glass --- 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