diff mbox series

[U-Boot,1/2] mkimage: Refactor imagetool_get_source_date to take command name

Message ID 20180620201052.15428-1-alex.kiernan@gmail.com
State Accepted
Commit 87925df2b3f8d308addc5c0fe5a22ae9712ca5ec
Delegated to: Tom Rini
Headers show
Series [U-Boot,1/2] mkimage: Refactor imagetool_get_source_date to take command name | expand

Commit Message

Alex Kiernan June 20, 2018, 8:10 p.m. UTC
So we can use imagetool_get_source_date() from callers who do not have
the image tool params struct, just pass in the command name for the error
message.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
---

 tools/default_image.c | 2 +-
 tools/fit_image.c     | 3 ++-
 tools/imagetool.c     | 4 ++--
 tools/imagetool.h     | 4 ++--
 4 files changed, 7 insertions(+), 6 deletions(-)

Comments

Simon Glass June 21, 2018, 7:45 p.m. UTC | #1
On 20 June 2018 at 14:10, Alex Kiernan <alex.kiernan@gmail.com> wrote:
> So we can use imagetool_get_source_date() from callers who do not have
> the image tool params struct, just pass in the command name for the error
> message.
>
> Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
> ---
>
>  tools/default_image.c | 2 +-
>  tools/fit_image.c     | 3 ++-
>  tools/imagetool.c     | 4 ++--
>  tools/imagetool.h     | 4 ++--
>  4 files changed, 7 insertions(+), 6 deletions(-)

Reviewed-by: Simon Glass <sjg@chromum.org>
Tom Rini July 11, 2018, 12:43 p.m. UTC | #2
On Wed, Jun 20, 2018 at 08:10:51PM +0000, Alex Kiernan wrote:

> So we can use imagetool_get_source_date() from callers who do not have
> the image tool params struct, just pass in the command name for the error
> message.
> 
> Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
> Reviewed-by: Simon Glass <sjg@chromum.org>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/tools/default_image.c b/tools/default_image.c
index 4abff4543a..4b7d1ed4a1 100644
--- a/tools/default_image.c
+++ b/tools/default_image.c
@@ -100,7 +100,7 @@  static void image_set_header(void *ptr, struct stat *sbuf, int ifd,
 				sizeof(image_header_t)),
 			sbuf->st_size - sizeof(image_header_t));
 
-	time = imagetool_get_source_date(params, sbuf->st_mtime);
+	time = imagetool_get_source_date(params->cmdname, sbuf->st_mtime);
 	ep = params->ep;
 	addr = params->addr;
 
diff --git a/tools/fit_image.c b/tools/fit_image.c
index e55a8943e7..6f09a66106 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -51,7 +51,8 @@  static int fit_add_file_data(struct image_tool_params *params, size_t size_inc,
 
 	/* for first image creation, add a timestamp at offset 0 i.e., root  */
 	if (params->datafile) {
-		time_t time = imagetool_get_source_date(params, sbuf.st_mtime);
+		time_t time = imagetool_get_source_date(params->cmdname,
+							sbuf.st_mtime);
 		ret = fit_set_timestamp(ptr, 0, time);
 	}
 
diff --git a/tools/imagetool.c b/tools/imagetool.c
index a4e39b24bc..b3e628f612 100644
--- a/tools/imagetool.c
+++ b/tools/imagetool.c
@@ -116,7 +116,7 @@  int imagetool_get_filesize(struct image_tool_params *params, const char *fname)
 }
 
 time_t imagetool_get_source_date(
-	 struct image_tool_params *params,
+	 const char *cmdname,
 	 time_t fallback)
 {
 	char *source_date_epoch = getenv("SOURCE_DATE_EPOCH");
@@ -128,7 +128,7 @@  time_t imagetool_get_source_date(
 
 	if (gmtime(&time) == NULL) {
 		fprintf(stderr, "%s: SOURCE_DATE_EPOCH is not valid\n",
-			params->cmdname);
+			cmdname);
 		time = 0;
 	}
 
diff --git a/tools/imagetool.h b/tools/imagetool.h
index d191b9cfe7..63c08ebc09 100644
--- a/tools/imagetool.h
+++ b/tools/imagetool.h
@@ -216,12 +216,12 @@  int imagetool_get_filesize(struct image_tool_params *params, const char *fname);
  * an error message if SOURCE_DATE_EPOCH contains an invalid value and returns
  * 0.
  *
- * @params:	mkimage parameters
+ * @cmdname:	command name
  * @fallback:	timestamp to use if SOURCE_DATE_EPOCH isn't set
  * @return timestamp based on SOURCE_DATE_EPOCH
  */
 time_t imagetool_get_source_date(
-	struct image_tool_params *params,
+	const char *cmdname,
 	time_t fallback);
 
 /*