]> git.sur5r.net Git - u-boot/commitdiff
mkimage: Refactor imagetool_get_source_date to take command name
authorAlex Kiernan <alex.kiernan@gmail.com>
Wed, 20 Jun 2018 20:10:51 +0000 (20:10 +0000)
committerTom Rini <trini@konsulko.com>
Tue, 10 Jul 2018 20:56:00 +0000 (16:56 -0400)
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>
tools/default_image.c
tools/fit_image.c
tools/imagetool.c
tools/imagetool.h

index 4abff4543a6c46b4016c0e4fabdfcdbfcd8a285a..4b7d1ed4a1a5247d72a1f73c65466c2daac486e9 100644 (file)
@@ -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;
 
index e55a8943e764f6e32e740455d5ab1ae2fea6b122..6f09a661067e53d4bbe61d23dbc6fffa459da664 100644 (file)
@@ -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);
        }
 
index a4e39b24bca79bdd24adabdafd54d9b6be2f1a37..b3e628f612f527f7a3ed11afb7c57395ae6a6bab 100644 (file)
@@ -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;
        }
 
index d191b9cfe709637a479b41697046f59b7263e2fe..63c08ebc09c3596a80378a341eb7716e01a5ba55 100644 (file)
@@ -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);
 
 /*