From e96fb7137fb2fea83a9d3eee31d37fc3dd00af82 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 16 Jan 2020 18:43:51 +1300 Subject: Use consistent layout for function braces --- crypt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'crypt.c') diff --git a/crypt.c b/crypt.c index 5e13fbd..4f085b1 100644 --- a/crypt.c +++ b/crypt.c @@ -42,7 +42,8 @@ int main (int argc, char **argv) /* * Show usage to given stream, and exit with given code */ -void usage(FILE *stream, int status) { +void usage(FILE *stream, int status) +{ fputs("USAGE: crypt [-h | KEY SALT]\n", stream); exit(status); } @@ -50,7 +51,8 @@ void usage(FILE *stream, int status) { /* * Exit with error error message */ -void error(char *message) { +void error(char *message) +{ fprintf(stderr, "%s\n", message); exit(EXIT_FAILURE); } -- cgit v1.2.3 From 3927568ecb614e58fd869e4defcf3dcc8ab7938e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 16 Jan 2020 18:47:33 +1300 Subject: Adjust indentation of switch block --- crypt.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'crypt.c') diff --git a/crypt.c b/crypt.c index 4f085b1..e704cfa 100644 --- a/crypt.c +++ b/crypt.c @@ -7,14 +7,14 @@ int main (int argc, char **argv) while ((opt = getopt(argc, argv, "h")) != -1) { switch (opt) { - case 'h': /* Help */ - usage(stdout, EXIT_SUCCESS); - break; - case '?': /* Unknown option */ - usage(stderr, EXIT_FAILURE); - break; - default: /* Shouldn't happen */ - abort(); + case 'h': /* Help */ + usage(stdout, EXIT_SUCCESS); + break; + case '?': /* Unknown option */ + usage(stderr, EXIT_FAILURE); + break; + default: /* Shouldn't happen */ + abort(); } } -- cgit v1.2.3 From f49416fb25710f6a1c6cb0d927087b2cb5e28305 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 16 Jan 2020 18:48:15 +1300 Subject: Add braces around single-statement if blocks --- crypt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'crypt.c') diff --git a/crypt.c b/crypt.c index e704cfa..457a245 100644 --- a/crypt.c +++ b/crypt.c @@ -22,8 +22,9 @@ int main (int argc, char **argv) * If we don't have three arguments left after processing the options, * exit with usage information and error status */ - if (argc != 3) + if (argc != 3) { usage(stderr, EXIT_FAILURE); + } key = argv[1]; salt = argv[2]; @@ -32,8 +33,9 @@ int main (int argc, char **argv) * Create the hash, but exit immediately with the system error string * if it returns a null pointer (error condition) */ - if (!(hash = crypt(key, salt))) + if (!(hash = crypt(key, salt))) { error(strerror(errno)); + } puts(hash); exit(EXIT_SUCCESS); -- cgit v1.2.3 From 5a1102ccceac1346500afd740296b2d6f95f0f97 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 16 Jan 2020 18:58:04 +1300 Subject: Reorder functions --- crypt.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'crypt.c') diff --git a/crypt.c b/crypt.c index 457a245..7ba42ef 100644 --- a/crypt.c +++ b/crypt.c @@ -42,19 +42,19 @@ int main (int argc, char **argv) } /* - * Show usage to given stream, and exit with given code + * Exit with error error message */ -void usage(FILE *stream, int status) +void error(char *message) { - fputs("USAGE: crypt [-h | KEY SALT]\n", stream); - exit(status); + fprintf(stderr, "%s\n", message); + exit(EXIT_FAILURE); } /* - * Exit with error error message + * Show usage to given stream, and exit with given code */ -void error(char *message) +void usage(FILE *stream, int status) { - fprintf(stderr, "%s\n", message); - exit(EXIT_FAILURE); + fputs("USAGE: crypt [-h | KEY SALT]\n", stream); + exit(status); } -- cgit v1.2.3