From 95d2b2682b54d780c99ab8d8411aac7a55171a8c Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 2 Feb 2017 16:34:14 +0900 Subject: [PATCH 1/3] fiptool: print new lines of usage to stdout instead of stderr The strings in usage functions are sent to stdout by printf(), but some new lines are sent to stderr by fputc(..., stderr). This inconsistency will break the usage format when users re-direct stdout or stderr. Just use printf() for consistency. Signed-off-by: Masahiro Yamada --- tools/fiptool/fiptool.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/fiptool/fiptool.c b/tools/fiptool/fiptool.c index 865aeae1d9..8cf7ecec5d 100644 --- a/tools/fiptool/fiptool.c +++ b/tools/fiptool/fiptool.c @@ -826,7 +826,7 @@ static void create_usage(void) "pointed to by file.\n"); printf(" --plat-toc-flags \t16-bit platform specific flag field " "occupying bits 32-47 in 64-bit ToC header.\n"); - fputc('\n', stderr); + printf("\n"); printf("Specific images are packed with the following options:\n"); for (; toc_entry->cmdline_name != NULL; toc_entry++) printf(" --%-16s FILENAME\t%s\n", toc_entry->cmdline_name, @@ -943,7 +943,7 @@ static void update_usage(void) printf(" --out FIP_FILENAME\t\tSet an alternative output FIP file.\n"); printf(" --plat-toc-flags \t16-bit platform specific flag field " "occupying bits 32-47 in 64-bit ToC header.\n"); - fputc('\n', stderr); + printf("\n"); printf("Specific images are packed with the following options:\n"); for (; toc_entry->cmdline_name != NULL; toc_entry++) printf(" --%-16s FILENAME\t%s\n", toc_entry->cmdline_name, @@ -1081,12 +1081,12 @@ static void unpack_usage(void) printf(" --force\t\t\tIf the output file already exists, use --force to " "overwrite it.\n"); printf(" --out path\t\t\tSet the output directory path.\n"); - fputc('\n', stderr); + printf("\n"); printf("Specific images are unpacked with the following options:\n"); for (; toc_entry->cmdline_name != NULL; toc_entry++) printf(" --%-16s FILENAME\t%s\n", toc_entry->cmdline_name, toc_entry->name); - fputc('\n', stderr); + printf("\n"); printf("If no options are provided, all images will be unpacked.\n"); exit(1); } @@ -1210,7 +1210,7 @@ static void remove_usage(void) printf(" --force\t\tIf the output FIP file already exists, use --force to " "overwrite it.\n"); printf(" --out FIP_FILENAME\tSet an alternative output FIP file.\n"); - fputc('\n', stderr); + printf("\n"); printf("Specific images are removed with the following options:\n"); for (; toc_entry->cmdline_name != NULL; toc_entry++) printf(" --%-16s\t%s\n", toc_entry->cmdline_name, @@ -1258,7 +1258,7 @@ static void usage(void) printf("usage: fiptool [--verbose] []\n"); printf("Global options supported:\n"); printf(" --verbose\tEnable verbose output for all commands.\n"); - fputc('\n', stderr); + printf("\n"); printf("Commands supported:\n"); printf(" info\t\tList images contained in FIP.\n"); printf(" create\tCreate a new FIP with the given images.\n"); From 802b42a0cfc390bb69222e5b6f83e705f03ab2e6 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 2 Feb 2017 16:37:37 +0900 Subject: [PATCH 2/3] fiptool: stretch out printf strings for readability and grep'ability We should follow the Linux coding style, which is clearly stated in the docs/user-guide.mk: When making changes to the source for submission to the project, the source must be in compliance with the Linux style guide and Documentation/process/coding-style.rst of Linux Kernel says: The limit on the length of lines is 80 columns and this is a strongly preferred limit. [ snip ] However, never break user-visible strings such as printk messages, because that breaks the ability to grep for them. The strings for printf() are user-visible, and can exceed the 80 column limit. Signed-off-by: Masahiro Yamada --- tools/fiptool/fiptool.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/tools/fiptool/fiptool.c b/tools/fiptool/fiptool.c index 8cf7ecec5d..1e4451f8c0 100644 --- a/tools/fiptool/fiptool.c +++ b/tools/fiptool/fiptool.c @@ -822,10 +822,8 @@ static void create_usage(void) printf("\n"); printf("Options:\n"); printf(" --align \t\tEach image is aligned to (default: 1).\n"); - printf(" --blob uuid=...,file=...\tAdd an image with the given UUID " - "pointed to by file.\n"); - printf(" --plat-toc-flags \t16-bit platform specific flag field " - "occupying bits 32-47 in 64-bit ToC header.\n"); + printf(" --blob uuid=...,file=...\tAdd an image with the given UUID pointed to by file.\n"); + printf(" --plat-toc-flags \t16-bit platform specific flag field occupying bits 32-47 in 64-bit ToC header.\n"); printf("\n"); printf("Specific images are packed with the following options:\n"); for (; toc_entry->cmdline_name != NULL; toc_entry++) @@ -938,11 +936,9 @@ static void update_usage(void) printf("\n"); printf("Options:\n"); printf(" --align \t\tEach image is aligned to (default: 1).\n"); - printf(" --blob uuid=...,file=...\tAdd or update an image " - "with the given UUID pointed to by file.\n"); + printf(" --blob uuid=...,file=...\tAdd or update an image with the given UUID pointed to by file.\n"); printf(" --out FIP_FILENAME\t\tSet an alternative output FIP file.\n"); - printf(" --plat-toc-flags \t16-bit platform specific flag field " - "occupying bits 32-47 in 64-bit ToC header.\n"); + printf(" --plat-toc-flags \t16-bit platform specific flag field occupying bits 32-47 in 64-bit ToC header.\n"); printf("\n"); printf("Specific images are packed with the following options:\n"); for (; toc_entry->cmdline_name != NULL; toc_entry++) @@ -1076,10 +1072,8 @@ static void unpack_usage(void) printf("fiptool unpack [opts] FIP_FILENAME\n"); printf("\n"); printf("Options:\n"); - printf(" --blob uuid=...,file=...\tUnpack an image with the given UUID " - "to file.\n"); - printf(" --force\t\t\tIf the output file already exists, use --force to " - "overwrite it.\n"); + printf(" --blob uuid=...,file=...\tUnpack an image with the given UUID to file.\n"); + printf(" --force\t\t\tIf the output file already exists, use --force to overwrite it.\n"); printf(" --out path\t\t\tSet the output directory path.\n"); printf("\n"); printf("Specific images are unpacked with the following options:\n"); @@ -1207,8 +1201,7 @@ static void remove_usage(void) printf("Options:\n"); printf(" --align \tEach image is aligned to (default: 1).\n"); printf(" --blob uuid=...\tRemove an image with the given UUID.\n"); - printf(" --force\t\tIf the output FIP file already exists, use --force to " - "overwrite it.\n"); + printf(" --force\t\tIf the output FIP file already exists, use --force to overwrite it.\n"); printf(" --out FIP_FILENAME\tSet an alternative output FIP file.\n"); printf("\n"); printf("Specific images are removed with the following options:\n"); From 9dd5edb86d8cb626cad7c8a26066c9bce36d9b5d Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 11 Feb 2017 13:02:12 +0900 Subject: [PATCH 3/3] fiptool: remove unneeded declarations These functions are defined above any calls. Signed-off-by: Masahiro Yamada --- tools/fiptool/fiptool.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/fiptool/fiptool.c b/tools/fiptool/fiptool.c index 1e4451f8c0..f3f831bd20 100644 --- a/tools/fiptool/fiptool.c +++ b/tools/fiptool/fiptool.c @@ -52,8 +52,6 @@ #define OPT_PLAT_TOC_FLAGS 1 #define OPT_ALIGN 2 -static image_desc_t *lookup_image_desc_from_uuid(const uuid_t *uuid); -static image_t *lookup_image_from_uuid(const uuid_t *uuid); static int info_cmd(int argc, char *argv[]); static void info_usage(void); static int create_cmd(int argc, char *argv[]);