From patchwork Sun Feb 16 22:04:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniu Rosca X-Patchwork-Id: 236416 List-Id: U-Boot discussion From: roscaeugeniu at gmail.com (Eugeniu Rosca) Date: Sun, 16 Feb 2020 23:04:33 +0100 Subject: [PATCH] image.h: Change android_image_get_dtb* to use uint and not u32 In-Reply-To: <20200216165323.GC18302@bill-the-cat> References: <20200214173819.9277-1-trini@konsulko.com> <20200216162314.GA26923@lxhi-065.adit-jv.com> <20200216165323.GC18302@bill-the-cat> Message-ID: <20200216220433.GA973@erosca> Hi Tom, On Sun, Feb 16, 2020 at 11:53:23AM -0500, Tom Rini wrote: > On Sun, Feb 16, 2020 at 05:23:14PM +0100, Eugeniu Rosca wrote: > > On Fri, Feb 14, 2020 at 12:38:19PM -0500, Tom Rini wrote: > > > The image.h header can be used fairly widely in U-Boot builds. We > > > cannot use u32 here as it may be used in cases where we don't have that > > > typedef available and don't want to expose it either. Use uint instead > > > here. > > > > > > Cc: Eugeniu Rosca > > > Cc: Sam Protsenko > > > Signed-off-by: Tom Rini > > > --- > > > include/image.h | 6 +++--- > > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > > > diff --git a/include/image.h b/include/image.h > > > index b316d167d8d7..1dc3b48d8689 100644 > > > --- a/include/image.h > > > +++ b/include/image.h > > > @@ -1425,9 +1425,9 @@ int android_image_get_ramdisk(const struct andr_img_hdr *hdr, > > > ulong *rd_data, ulong *rd_len); > > > int android_image_get_second(const struct andr_img_hdr *hdr, > > > ulong *second_data, ulong *second_len); > > > -bool android_image_get_dtbo(ulong hdr_addr, ulong *addr, u32 *size); > > > -bool android_image_get_dtb_by_index(ulong hdr_addr, u32 index, ulong *addr, > > > - u32 *size); > > > +bool android_image_get_dtbo(ulong hdr_addr, ulong *addr, uint *size); > > > +bool android_image_get_dtb_by_index(ulong hdr_addr, uint index, ulong *addr, > > > + uint *size); > > > > While I think the change is harmless and brings some consistency and > > visual comfort when reviewing the types employed in 'include/image.h', > > I can hardly imagine a real-life breakage introduced by u32 in > > 'include/image.h'. > > I ran in to this in practice with > http://patchwork.ozlabs.org/project/uboot/list/?series=155410&state=* > applied. Applying this series to u-boot/master, I am running into below build failure [1], which I believe is something you try to fix in this patch. It looks to me that U-Boot's 'include/image.h' is used not only by files which are compiled for the target device, but also by files located in 'tools/', which are compiled for the host with -DUSE_HOSTCC. After inspecting the 'tools/' path of U-Boot repository, it looks like the definition of 'u32' is indeed missing there, so I believe that's the root cause of the build failure. W.r.t. 'android_image_*' functions, I really doubt that they were designed to be compiled with USE_HOSTCC. If so, then IMHO we shouldn't try to make them compliant with USE_HOSTCC compilation, since this will impose additional constraints/requirements to the development style of those functions. IMHO we should just hide the android_image functions on enabling -DUSE_HOSTCC, as shown in [2]. What's your view on that? [1] Build error after applying to u-boot/master below series: http://patchwork.ozlabs.org/project/uboot/list/?series=155410&state=* In file included from include/u-boot/rsa-mod-exp.h:10, from ./tools/../lib/rsa/rsa-verify.c:22, from tools/lib/rsa/rsa-verify.c:1: include/image.h:1440:58: error: unknown type name ?u32? 1440 | bool android_image_get_dtbo(ulong hdr_addr, ulong *addr, u32 *size); | ^~~ include/image.h:1441:53: error: unknown type name ?u32? 1441 | bool android_image_get_dtb_by_index(ulong hdr_addr, u32 index, ulong *addr, | ^~~ include/image.h:1442:9: error: unknown type name ?u32? 1442 | u32 *size); | ^~~ HOSTCC tools/asn1_compiler make[1]: *** [scripts/Makefile.host:114: tools/lib/rsa/rsa-verify.o] Error 1 make[1]: *** Waiting for unfinished jobs.... HOSTLD tools/mkenvimage make: *** [Makefile:1728: tools] Error 2 [2] Hide the android_image_* functions when USE_HOSTCC is enabled diff --git a/include/image.h b/include/image.h index ebec329582eb..0cdb2165fdaf 100644 --- a/include/image.h +++ b/include/image.h @@ -1429,7 +1429,7 @@ struct cipher_algo *image_get_cipher_algo(const char *full_name); #endif /* CONFIG_FIT_VERBOSE */ #endif /* CONFIG_FIT */ -#if defined(CONFIG_ANDROID_BOOT_IMAGE) +#if defined(CONFIG_ANDROID_BOOT_IMAGE) && !defined(USE_HOSTCC) struct andr_img_hdr; int android_image_check_header(const struct andr_img_hdr *hdr); int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify, @@ -1449,7 +1449,7 @@ void android_print_contents(const struct andr_img_hdr *hdr); bool android_image_print_dtb_contents(ulong hdr_addr); #endif -#endif /* CONFIG_ANDROID_BOOT_IMAGE */ +#endif /* CONFIG_ANDROID_BOOT_IMAGE && !USE_HOSTCC */ /** * board_fit_config_name_match() - Check for a matching board name