From cc34f04efd63dfdd31ef2dbfd46c15fb485b2888 Mon Sep 17 00:00:00 2001 From: Philippe Reynes Date: Fri, 13 Nov 2020 16:37:46 +0100 Subject: tools: image-host.c: use random instead of rand According to the manpage of rand, it is recommended to use random instead of rand. This commit updates the function get_random_data to use random. Reported-by: Coverity (CID: 312953) Signed-off-by: Philippe Reynes Reviewed-by: Simon Glass --- tools/image-host.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/image-host.c b/tools/image-host.c index 7cef78eab8f..5e1dec23384 100644 --- a/tools/image-host.c +++ b/tools/image-host.c @@ -339,10 +339,10 @@ static int get_random_data(void *data, int size) goto out; } - srand(date.tv_nsec); + srandom(date.tv_nsec); for (i = 0; i < size; i++) { - *tmp = rand() & 0xff; + *tmp = random() & 0xff; tmp++; } -- cgit v1.3.1 From 26927493161e16d90101c8a6abae551597d46e72 Mon Sep 17 00:00:00 2001 From: Philippe Reynes Date: Fri, 13 Nov 2020 15:15:18 +0100 Subject: tools: image-host.c: use correct variable for strerrno In the function get_random_data, strerrno is called with the variable ret (which is the return of the function clock_gettime). It should be called with errnor. This commit fixes this mistake. Reported-by: Coverity (CID: 312956) Signed-off-by: Philippe Reynes Reviewed-by: Simon Glass --- tools/image-host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/image-host.c b/tools/image-host.c index 5e1dec23384..e32cc642579 100644 --- a/tools/image-host.c +++ b/tools/image-host.c @@ -335,7 +335,7 @@ static int get_random_data(void *data, int size) ret = clock_gettime(CLOCK_MONOTONIC, &date); if (ret < 0) { printf("%s: clock_gettime has failed (err=%d, str=%s)\n", - __func__, ret, strerror(ret)); + __func__, ret, strerror(errno)); goto out; } -- cgit v1.3.1 From e157a1114e4f9294219f4257d0e7983ecb4c328d Mon Sep 17 00:00:00 2001 From: Tyler Hicks Date: Mon, 26 Oct 2020 10:40:24 -0500 Subject: tools: dumpimage: Remove remaining mentions of the -i option The -i option of the dumpimage tool has been removed so it should no longer be documented in the README file. Refer readers to the tool's help output rather than maintain a copy of the usage in the README. Finally, adjust the example dumpfile invocation in imagetool.h to use the -o option instead of the removed -i option. Fixes: 12b831879a76 ("tools: dumpimage: Simplify arguments") Signed-off-by: Tyler Hicks Cc: Martyn Welch Acked-by: Martyn Welch --- README | 12 ++---------- tools/imagetool.h | 6 +++--- 2 files changed, 5 insertions(+), 13 deletions(-) (limited to 'tools') diff --git a/README b/README index cb49aa15dae..7b73a1c9732 100644 --- a/README +++ b/README @@ -3832,16 +3832,8 @@ when your kernel is intended to use an initial ramdisk: Load Address: 0x00000000 Entry Point: 0x00000000 -The "dumpimage" is a tool to disassemble images built by mkimage. Its "-i" -option performs the converse operation of the mkimage's second form (the "-d" -option). Given an image built by mkimage, the dumpimage extracts a "data file" -from the image: - - tools/dumpimage -i image -T type -p position data_file - -i ==> extract from the 'image' a specific 'data_file' - -T ==> set image type to 'type' - -p ==> 'position' (starting at 0) of the 'data_file' inside the 'image' - +The "dumpimage" tool can be used to disassemble or list the contents of images +built by mkimage. See dumpimage's help output (-h) for details. Installing a Linux Image: ------------------------- diff --git a/tools/imagetool.h b/tools/imagetool.h index acbc48e9be0..8726792c8c0 100644 --- a/tools/imagetool.h +++ b/tools/imagetool.h @@ -126,9 +126,9 @@ struct image_type_params { struct image_tool_params *); /* * This function is used by the command to retrieve a component - * (sub-image) from the image (i.e. dumpimage -i -p - * ). - * Thus the code to extract a file from an image must be put here. + * (sub-image) from the image (i.e. dumpimage -p + * -o ). Thus the code to extract a file + * from an image must be put here. * * Returns 0 if the file was successfully retrieved from the image, * or a negative value on error. -- cgit v1.3.1