From 4c8151674216cfaa0794ff8a7e63d81f992702d4 Mon Sep 17 00:00:00 2001 From: DTB Date: Sat, 10 Aug 2024 22:30:08 -0600 Subject: [PATCH] strcmp(1): further error-proofing --- src/strcmp.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/strcmp.c b/src/strcmp.c index ea20b1e..6d930d5 100644 --- a/src/strcmp.c +++ b/src/strcmp.c @@ -26,18 +26,22 @@ char *program_name = "strcmp"; int main(int argc, char *argv[]) { - program_name = argv[0] == NULL ? program_name : argv[0]; - int i; + unsigned int i; #ifdef __OpenBSD__ if (pledge("stdio", NULL) == -1) { - perror(program_name); + perror(argv[0] == NULL ? program_name : argv[0]); + return EX_OSERR; } #endif if (argc < 3) { - (void)fprintf(stderr, "Usage: %s string string...\n", program_name); + (void)fprintf( + stderr, + "Usage: %s string string...\n", + argv[0] == NULL ? program_name : argv[0] + ); return EX_USAGE; }