From: Ahmad Fatoum <a.fatoum@pengutronix.de> To: barebox@lists.infradead.org Cc: Ahmad Fatoum <a.fatoum@pengutronix.de> Subject: [PATCH v2 5/6] pbl: compressed-dtb: use flexible array member to access data Date: Wed, 13 Jul 2022 11:57:29 +0200 [thread overview] Message-ID: <20220713095730.1878941-5-a.fatoum@pengutronix.de> (raw) In-Reply-To: <20220713095730.1878941-1-a.fatoum@pengutronix.de> While data = compressed_dtb + 1 has the equivalent effect of skipping over the struct barebox_boarddata_compressed_dtb header, using a flexible array member aids code readability, so use that instead. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> --- v1 -> v2: - new patch --- arch/arm/cpu/start.c | 7 ++----- arch/riscv/boot/start.c | 6 ++---- include/compressed-dtb.h | 1 + 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c index 14cc310312ab..755d48851956 100644 --- a/arch/arm/cpu/start.c +++ b/arch/arm/cpu/start.c @@ -52,7 +52,6 @@ u32 barebox_arm_machine(void) void *barebox_arm_boot_dtb(void) { void *dtb; - void *data; int ret; struct barebox_boarddata_compressed_dtb *compressed_dtb; static void *boot_dtb; @@ -76,10 +75,8 @@ void *barebox_arm_boot_dtb(void) if (!dtb) return NULL; - data = compressed_dtb + 1; - - ret = uncompress(data, compressed_dtb->datalen, NULL, NULL, - dtb, NULL, NULL); + ret = uncompress(compressed_dtb->data, compressed_dtb->datalen, + NULL, NULL, dtb, NULL, NULL); if (ret) { pr_err("uncompressing dtb failed\n"); free(dtb); diff --git a/arch/riscv/boot/start.c b/arch/riscv/boot/start.c index 72ab93cb7691..8b4c8bb2f019 100644 --- a/arch/riscv/boot/start.c +++ b/arch/riscv/boot/start.c @@ -32,7 +32,6 @@ unsigned barebox_riscv_pbl_flags; void *barebox_riscv_boot_dtb(void) { void *dtb; - void *data; int ret; struct barebox_boarddata_compressed_dtb *compressed_dtb; static void *boot_dtb; @@ -56,9 +55,8 @@ void *barebox_riscv_boot_dtb(void) if (!dtb) return NULL; - data = compressed_dtb + 1; - - ret = uncompress(data, compressed_dtb->datalen, NULL, NULL, dtb, NULL, NULL); + ret = uncompress(compressed_dtb->data, compressed_dtb->datalen, + NULL, NULL, dtb, NULL, NULL); if (ret) { pr_err("uncompressing dtb failed\n"); free(dtb); diff --git a/include/compressed-dtb.h b/include/compressed-dtb.h index 1ba98a7e2b92..3359d1ee115d 100644 --- a/include/compressed-dtb.h +++ b/include/compressed-dtb.h @@ -10,6 +10,7 @@ struct barebox_boarddata_compressed_dtb { u32 magic; u32 datalen; u32 datalen_uncompressed; + u8 data[]; }; static inline bool blob_is_compressed_fdt(const void *blob) -- 2.30.2
next prev parent reply other threads:[~2022-07-13 9:59 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-07-13 9:57 [PATCH v2 1/6] common: don't allow compressing in-barebox binaries again Ahmad Fatoum 2022-07-13 9:57 ` [PATCH v2 2/6] pbl: make USE_COMPRESSED_DTB a PBL-only feature Ahmad Fatoum 2022-07-13 9:57 ` [PATCH v2 3/6] pbl: remove redundant select UNCOMRPESS Ahmad Fatoum 2022-07-13 9:57 ` [PATCH v2 4/6] kbuild: gen-dtb-s: use Makefile.lib instead of duplicating cmd_lzo Ahmad Fatoum 2022-07-13 9:57 ` Ahmad Fatoum [this message] 2022-07-13 9:57 ` [PATCH v2 6/6] kbuild: pbl: use same compression algo for both barebox and DTB Ahmad Fatoum 2022-07-15 10:53 ` Sascha Hauer 2022-07-15 15:57 ` [PATCH] fixup! " Ahmad Fatoum 2022-07-14 8:08 ` [PATCH v2 1/6] common: don't allow compressing in-barebox binaries again Sascha Hauer
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220713095730.1878941-5-a.fatoum@pengutronix.de \ --to=a.fatoum@pengutronix.de \ --cc=barebox@lists.infradead.org \ --subject='Re: [PATCH v2 5/6] pbl: compressed-dtb: use flexible array member to access data' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox