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(-) 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(-) 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(-) 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 95e6164284bd1c5b70dcdffc0270e825043ce105 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 16 Jan 2020 18:52:07 +1300 Subject: Fix and extend GCC options --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e263d11..b5ddaf2 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ .POSIX: .PHONY: all clean distclean install PREFIX = /usr/local -#CFLAGS = -Werror -Wstrict -pedantic # Recommended for GCC +#CC = gcc +#CFLAGS = -Wall -Werror -Wextra -ansi -pedantic LDFLAGS = -lcrypt ALL = crypt all: $(ALL) -- 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 ++++++++-------- crypt.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) 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); } diff --git a/crypt.h b/crypt.h index 6612e01..0a25c0d 100644 --- a/crypt.h +++ b/crypt.h @@ -5,5 +5,5 @@ #include /* strerror(3) */ #include /* crypt(3) */ -void usage(FILE *, int); void error(char *); +void usage(FILE *, int); -- cgit v1.2.3 From 07a58e34bb49ab8e63d6e6f0197300cd7a4caef1 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 16 Jan 2020 19:00:33 +1300 Subject: Bump VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 9084fa2..26aaba0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.0 +1.2.0 -- cgit v1.2.3