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;
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);
}
}
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)) {
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);
}
}
}
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;
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';