diff --git a/bench/benchctxswitch.cpp b/bench/benchctxswitch.cpp index 20089987..b3777f7d 100644 --- a/bench/benchctxswitch.cpp +++ b/bench/benchctxswitch.cpp @@ -20,6 +20,7 @@ *******************************************************************************/ +#include #include #include #include @@ -39,11 +40,13 @@ static int uptime(uintmax_t* usecs) int main(int /*argc*/, char* /*argv*/[]) { pid_t slavepid = fork(); - if ( slavepid < 0 ) { perror("fork"); return 1; } + if ( slavepid < 0 ) + err(1, "fork"); if ( slavepid == 0 ) { while ( true ) { usleep(0); } exit(0); } uintmax_t start; - if ( uptime(&start) ) { perror("uptime"); return 1; } + if ( uptime(&start) ) + err(1, "uptime"); uintmax_t end = start + 1ULL * 1000ULL * 1000ULL; // 1 second size_t count = 0; uintmax_t now; diff --git a/bench/benchsyscall.cpp b/bench/benchsyscall.cpp index df95d1d9..274ae117 100644 --- a/bench/benchsyscall.cpp +++ b/bench/benchsyscall.cpp @@ -21,6 +21,7 @@ *******************************************************************************/ +#include #include #include #include @@ -37,7 +38,8 @@ static int uptime(uintmax_t* usecs) int main(int /*argc*/, char* /*argv*/[]) { uintmax_t start; - if ( uptime(&start) ) { perror("uptime"); return 1; } + if ( uptime(&start) ) + err(1, "uptime"); uintmax_t end = start + 1ULL * 1000ULL * 1000ULL; // 1 second size_t count = 0; uintmax_t now; diff --git a/utils/find.cpp b/utils/find.cpp index 58792184..d06813eb 100644 --- a/utils/find.cpp +++ b/utils/find.cpp @@ -62,7 +62,7 @@ bool Find(int dirfd, const char* relpath, const char* path, int types) if ( types & TYPE_DIR ) printf("%s\n", path); DIR* dir = fdopendir(fd); - if ( !dir ) { perror("fdopendir"); close(fd); return false; } + if ( !dir ) { error(0, errno, "fdopendir"); close(fd); return false; } struct dirent* entry; while ( (entry = readdir(dir)) ) { diff --git a/utils/kernelinfo.cpp b/utils/kernelinfo.cpp index be9bb657..66f2811a 100644 --- a/utils/kernelinfo.cpp +++ b/utils/kernelinfo.cpp @@ -64,7 +64,8 @@ int main(int argc, char* argv[]) } size_t bufsize = 32; char* buf = (char*) malloc(bufsize); - if ( !buf ) { perror("malloc"); return 1; } + if ( !buf ) + error(1, errno, "malloc"); for ( int i = 1; i < argc; i++ ) { retry: @@ -80,7 +81,8 @@ retry: if ( ret ) { buf = (char*) realloc(buf, ret); - if ( !buf ) { perror("realloc"); return 1; } + if ( !buf ) + error(1, errno, "realloc"); bufsize = ret; goto retry; } diff --git a/utils/ls.cpp b/utils/ls.cpp index a8389e93..5b54dd9b 100644 --- a/utils/ls.cpp +++ b/utils/ls.cpp @@ -396,7 +396,7 @@ int ls(const char* path) { if ( errno == ENOTDIR ) return handle_entry_internal(path, path, DT_UNKNOWN); - perror(path); + error(0, errno, "%s", path); ret = 2; goto cleanup_entries; } diff --git a/utils/memstat.cpp b/utils/memstat.cpp index be092740..1d8de9b6 100644 --- a/utils/memstat.cpp +++ b/utils/memstat.cpp @@ -20,6 +20,7 @@ *******************************************************************************/ +#include #include #include #include @@ -66,7 +67,8 @@ int main(int /*argc*/, char* /*argv*/[]) { size_t memused = 0; size_t memtotal = 0; - if ( memstat(&memused, &memtotal) ) { perror("memstat"); return 1; } + if ( memstat(&memused, &memtotal) ) + err(1, "memstat"); printf("memory usage: "); printbytes(memused);