diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2023-05-13 10:58:41 +0200 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2023-05-13 11:37:46 +0200 |
commit | cd917f48454875ad6b7fc69455281d72760c44ee (patch) | |
tree | 70a7a43fe43b7f893468f9120def5513774a242c /src/cmd_line.c | |
parent | add command module to handle request-response communications (diff) | |
download | cimple-cd917f48454875ad6b7fc69455281d72760c44ee.tar.gz cimple-cd917f48454875ad6b7fc69455281d72760c44ee.zip |
best practices & coding style fixes
* I don't really need to declare all variables at the top of the
function anymore.
* Default-initialize variables more.
* Don't set the output parameter until the object is completely
constructed.
Diffstat (limited to 'src/cmd_line.c')
-rw-r--r-- | src/cmd_line.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/cmd_line.c b/src/cmd_line.c index fee18d4..8651831 100644 --- a/src/cmd_line.c +++ b/src/cmd_line.c @@ -20,15 +20,13 @@ static char *get_current_binary_path() static char *get_current_binary_name() { - char *path, *name, *result; - - path = get_current_binary_path(); + char *path = get_current_binary_path(); if (!path) return NULL; - name = basename(path); + char *name = basename(path); - result = strdup(name); + char *result = strdup(name); if (!result) { log_errno("strdup"); goto free_path; @@ -42,14 +40,11 @@ free_path: void exit_with_usage(int ec) { - char *binary; - FILE *dest; - - dest = stdout; + FILE *dest = stdout; if (ec) dest = stderr; - binary = get_current_binary_name(); + char *binary = get_current_binary_name(); fprintf(dest, "usage: %s %s\n", binary ?: "prog", get_usage_string()); free(binary); |