diff mbox series

[v3,6/8] tool: use ALIGN() to align the size

Message ID 20200326100916.22532-6-kever.yang@rock-chips.com
State Superseded
Headers show
Series [v3,1/8] tool: Move ALIGN_MASK to header as common MACRO | expand

Commit Message

Kever Yang March 26, 2020, 10:09 a.m. UTC
Use the ALIGN() for size align so that the code is more readable.

Signed-off-by: Kever Yang <kever.yang at rock-chips.com>
---

Changes in v3: None
Changes in v2: None

 tools/fit_image.c    | 2 +-
 tools/socfpgaimage.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Heinrich Schuchardt March 26, 2020, 11:39 a.m. UTC | #1
On 3/26/20 11:09 AM, Kever Yang wrote:
> Use the ALIGN() for size align so that the code is more readable.
>
> Signed-off-by: Kever Yang <kever.yang at rock-chips.com>

Reviewed-by: Heinrich Schuchardt <xypron.glpk at gmx.de>

> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  tools/fit_image.c    | 2 +-
>  tools/socfpgaimage.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/fit_image.c b/tools/fit_image.c
> index 6aa4b1c733..a417182d4f 100644
> --- a/tools/fit_image.c
> +++ b/tools/fit_image.c
> @@ -540,7 +540,7 @@ static int fit_import_data(struct image_tool_params *params, const char *fname)
>  	if (fd < 0)
>  		return -EIO;
>  	fit_size = fdt_totalsize(old_fdt);
> -	data_base = (fit_size + 3) & ~3;
> +	data_base = ALIGN(fit_size, 4);
>
>  	/* Allocate space to hold the new FIT */
>  	size = sbuf.st_size + 16384;
> diff --git a/tools/socfpgaimage.c b/tools/socfpgaimage.c
> index 8fa098338b..6dfd64e31d 100644
> --- a/tools/socfpgaimage.c
> +++ b/tools/socfpgaimage.c
> @@ -203,7 +203,7 @@ static int sfp_sign_buffer(uint8_t *buf, uint8_t ver, uint8_t flags,
>  	uint32_t calc_crc;
>
>  	/* Align the length up */
> -	len = (len + 3) & ~3;
> +	len = ALIGN(len, 4);
>
>  	/* Build header, adding 4 bytes to length to hold the CRC32. */
>  	sfp_build_header(buf + HEADER_OFFSET, ver, flags, len + 4);
>
Tom Rini March 27, 2020, 6:16 p.m. UTC | #2
On Thu, Mar 26, 2020 at 06:09:14PM +0800, Kever Yang wrote:

> Use the ALIGN() for size align so that the code is more readable.
> 
> Signed-off-by: Kever Yang <kever.yang at rock-chips.com>

Reviewed-by: Tom Rini <trini at konsulko.com>
diff mbox series

Patch

diff --git a/tools/fit_image.c b/tools/fit_image.c
index 6aa4b1c733..a417182d4f 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -540,7 +540,7 @@  static int fit_import_data(struct image_tool_params *params, const char *fname)
 	if (fd < 0)
 		return -EIO;
 	fit_size = fdt_totalsize(old_fdt);
-	data_base = (fit_size + 3) & ~3;
+	data_base = ALIGN(fit_size, 4);
 
 	/* Allocate space to hold the new FIT */
 	size = sbuf.st_size + 16384;
diff --git a/tools/socfpgaimage.c b/tools/socfpgaimage.c
index 8fa098338b..6dfd64e31d 100644
--- a/tools/socfpgaimage.c
+++ b/tools/socfpgaimage.c
@@ -203,7 +203,7 @@  static int sfp_sign_buffer(uint8_t *buf, uint8_t ver, uint8_t flags,
 	uint32_t calc_crc;
 
 	/* Align the length up */
-	len = (len + 3) & ~3;
+	len = ALIGN(len, 4);
 
 	/* Build header, adding 4 bytes to length to hold the CRC32. */
 	sfp_build_header(buf + HEADER_OFFSET, ver, flags, len + 4);