From dd928a1f7b28d3680a5ecdcfcefddcec657f3adb Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Sun, 27 Jun 2010 14:16:01 +0200 Subject: [PATCH] Now exit on min size syntax error, and added 'dus: ' to error messages. --- dus.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/dus.c b/dus.c index b90a0bd..6557c7f 100644 --- a/dus.c +++ b/dus.c @@ -73,7 +73,7 @@ size_sum_t size_min = -1; /* -1 means no minimum size, otherwise lower void *safe_malloc(size_t n) { void *p = malloc(n); if (!p && n != 0) { - fprintf(stderr, "Can not allocate memory: %s\n", strerror(errno)); + fprintf(stderr, "dus: Can not allocate memory: %s\n", strerror(errno)); exit(EXIT_FAILURE); } return p; @@ -98,7 +98,7 @@ size_sum_t entry_size(const char *name) { result = 0; if(lstat(name, &dummy) != 0) { - fprintf(stderr, "Can not stat %s: %s\n", name, strerror(errno)); + fprintf(stderr, "dus: Can not stat %s: %s\n", name, strerror(errno)); exit(EXIT_FAILURE); } @@ -117,7 +117,7 @@ size_sum_t entry_size(const char *name) { } closedir(dir); } else { - fprintf(stderr, "Can not open directory %s: %s\n", name, strerror(errno)); + fprintf(stderr, "dus: Can not open directory %s: %s\n", name, strerror(errno)); exit(EXIT_FAILURE); } } else if(S_ISREG(dummy.st_mode)) { @@ -149,7 +149,8 @@ size_sum_t atoss(const char *string) { total += partial_total * 1024 * 1024 * 1024; partial_total = 0; } else { - fprintf(stderr, "Syntax error in %s\n", string); + fprintf(stderr, "dus: Syntax error in size specification `%s'\n", string); + exit(EXIT_FAILURE); } } @@ -189,7 +190,7 @@ struct entry_node *push_dir_content(char *name, struct entry_node *head) { } closedir(dir); } else { - fprintf(stderr, "Can not open directory %s: %s\n", name, strerror(errno)); + fprintf(stderr, "dus: Can not open directory %s: %s\n", name, strerror(errno)); exit (EXIT_FAILURE); } return head; @@ -239,7 +240,7 @@ void raw_print(char *buffer, size_t buffer_size, b = buffer; do { if(b >= buffer + buffer_size) { - fprintf(stderr, "Buffer overflow in raw_print (hu?!).\n"); + fprintf(stderr, "dus: Buffer overflow in raw_print (hu?!).\n"); exit(EXIT_FAILURE); } *(b++) = size%10 + '0'; -- 2.20.1