[Replicant] [libsamsung-ipc] [PATCH 12/26] tools: ipc-modem: group contiguous printf calls

Denis 'GNUtoo' Carikli GNUtoo at cyberdimension.org
Mon Mar 28 20:20:26 UTC 2022


There is no use in making multiple calls to printf when only one call
is sufficient.

It's also a good practice to do that in general, especially when part
of the code can print to the console at any time, to ensure that that
all the buffer is printed contiguously and not interleaved with other
prints.

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
---
 tools/ipc-modem.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/tools/ipc-modem.c b/tools/ipc-modem.c
index ae410e6..31fd54e 100644
--- a/tools/ipc-modem.c
+++ b/tools/ipc-modem.c
@@ -476,19 +476,19 @@ int modem_stop(struct ipc_client *client)
 
 void print_help(void)
 {
-	printf("usage: ipc-modem <command>\n");
-	printf("commands:\n");
-	printf("\tboot                  boot modem only\n");
-	printf("\tpower-on              power on the modem only\n");
-	printf("\tpower-off             power off the modem only\n");
-	printf("\tstart                 boot modem and start read loop\n");
-	printf("arguments:\n");
-	printf("\t--call=[NUMBER]       call NUMBER\n");
-	printf("\t--debug               enable debug messages\n");
-	printf("\t--dry-run             "
-	       "Test the ipc-modem program without talking to the modem.\n");
-	printf("\t--help                print this help message\n");
-	printf("\t--pin=[PIN]           provide SIM card PIN\n");
+	printf("usage: ipc-modem <command>\n"
+	       "commands:\n"
+	       "\tboot                  boot modem only\n"
+	       "\tpower-on              power on the modem only\n"
+	       "\tpower-off             power off the modem only\n"
+	       "\tstart                 boot modem and start read loop\n"
+	       "arguments:\n"
+	       "\t--call=[NUMBER]       call NUMBER\n"
+	       "\t--debug               enable debug messages\n"
+	       "\t--dry-run             "
+	       "Test the ipc-modem program without talking to the modem.\n"
+	       "\t--help                print this help message\n"
+	       "\t--pin=[PIN]           provide SIM card PIN\n");
 }
 
 int handle_command(struct cmdline_opts *cmdline_opts)
@@ -673,10 +673,10 @@ int main(int argc, char *argv[])
 	}
 
 	if (cmdline_opts.command == CMD_NONE) {
-		printf("\n");
-		printf("Error: No command given. You need to use a command.\n");
-		printf("       See the help below for more details.\n");
-		printf("\n");
+		printf("\n"
+		       "Error: No command given. You need to use a command.\n"
+		       "       See the help below for more details.\n"
+		       "\n");
 		print_help();
 		return 1;
 	}
-- 
2.35.1



More information about the Replicant mailing list