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 86DD3C636D7 for ; Tue, 21 Feb 2023 20:50:09 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DEC6585AAA; Tue, 21 Feb 2023 21:49:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org 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=kernel.org header.i=@kernel.org header.b="DIpYZbm2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B562885AA2; Tue, 21 Feb 2023 21:48:56 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 348ED85AD0 for ; Tue, 21 Feb 2023 21:22:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 62A88611EF; Tue, 21 Feb 2023 20:22:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17DADC4339C; Tue, 21 Feb 2023 20:22:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677010955; bh=BCxN+gNeRDCnDfEFvPVEi9jjGvzFWBBOKeh4ODE6Ngw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DIpYZbm25V6ksGqRtJMLWl4R+gflZoUjotsiO6Tz5P5MbySMou2J0soyIzjwawArw j1b6OUKf1mZChR9Z5gwluO0sIWL91j+jJanL3koCbSTvBUt9f98mw9C05fkQgodcse p2wAbA79QmxBu+Ef9BvJ/MKGxXQLj6nGp+4PQY4GDURZRLkuGkEzTLYkzPGU4wuRlD jYKiYGxPo+4QMcSfDmEfTbQUhnIg4TgCWGYSmo+47tqIDsY1yEv6rxV6Eyfv/F4S7F VBPeziVupYvSxkJTBl1yfjsi6Hi6GVePeaf6V8ED4IGT26ND+48aEbJU5YcicYiwFc /K+t8IPwj+Z3Q== Received: by pali.im (Postfix) id C8B6D9FC; Tue, 21 Feb 2023 21:22:34 +0100 (CET) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: u-boot@lists.denx.de Cc: Stefan Roese , Tony Dinh , Josua Mayer Subject: [PATCH RFC u-boot-mvebu 42/59] tools: kwbimage: Rename imagesz to dataoff Date: Tue, 21 Feb 2023 21:19:08 +0100 Message-Id: <20230221201925.9644-43-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230221201925.9644-1-pali@kernel.org> References: <20230221201925.9644-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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.6 at phobos.denx.de X-Virus-Status: Clean Variable imagesz in functions image_create_v0(), image_create_v1() and kwbimage_set_header() stores offset to data from the beginning of the main header. So it is not image size. Signed-off-by: Pali Rohár --- tools/kwbimage.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 857af6a438a4..b32f845b7e2d 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -962,7 +962,7 @@ static size_t image_headersz_v0(int *hasext) return image_headersz_align(headersz, image_get_bootfrom()); } -static void *image_create_v0(size_t *imagesz, struct image_tool_params *params, +static void *image_create_v0(size_t *dataoff, struct image_tool_params *params, int payloadsz) { struct image_cfg_element *e; @@ -1050,7 +1050,7 @@ static void *image_create_v0(size_t *imagesz, struct image_tool_params *params, main_hdr->checksum = image_checksum8(image, sizeof(struct main_hdr_v0)); - *imagesz = headersz; + *dataoff = headersz; return image; } @@ -1385,7 +1385,7 @@ static void finish_register_set_header_v1(uint8_t **cur, uint8_t **next_ext, *datai = 0; } -static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, +static void *image_create_v1(size_t *dataoff, struct image_tool_params *params, uint8_t *ptr, int payloadsz) { struct image_cfg_element *e; @@ -1532,7 +1532,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, image, headersz, secure_hdr)) return NULL; - *imagesz = headersz; + *dataoff = headersz; /* Fill the real header size without padding into the main header */ headersz = sizeof(*main_hdr); @@ -1811,7 +1811,7 @@ static void kwbimage_set_header(void *ptr, struct stat *sbuf, int ifd, FILE *fcfg; void *image = NULL; int version; - size_t headersz = 0; + size_t dataoff = 0; size_t datasz; uint32_t checksum; struct stat s; @@ -1862,11 +1862,11 @@ static void kwbimage_set_header(void *ptr, struct stat *sbuf, int ifd, */ case -1: case 0: - image = image_create_v0(&headersz, params, datasz + 4); + image = image_create_v0(&dataoff, params, datasz + 4); break; case 1: - image = image_create_v1(&headersz, params, ptr, datasz + 4); + image = image_create_v1(&dataoff, params, ptr, datasz + 4); break; default: @@ -1884,12 +1884,12 @@ static void kwbimage_set_header(void *ptr, struct stat *sbuf, int ifd, free(image_cfg); /* Build and add image data checksum */ - checksum = cpu_to_le32(image_checksum32((uint8_t *)ptr + headersz, + checksum = cpu_to_le32(image_checksum32((uint8_t *)ptr + dataoff, datasz)); - memcpy((uint8_t *)ptr + headersz + datasz, &checksum, sizeof(uint32_t)); + memcpy((uint8_t *)ptr + dataoff + datasz, &checksum, sizeof(uint32_t)); /* Finally copy the header into the image area */ - memcpy(ptr, image, headersz); + memcpy(ptr, image, dataoff); free(image); } -- 2.20.1