X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fremount-fs%2Fremount-fs.c;h=e30c3443100517ba49d775114e2d253bb3956835;hp=f432718d6b9148d615fda958a88f90f4790318c3;hb=0a1beeb64207eaa88ab9236787b1cbc2f704ae14;hpb=b92bea5d2a9481de69bb627a7b442a9f58fca43d diff --git a/src/remount-fs/remount-fs.c b/src/remount-fs/remount-fs.c index f432718d6..e30c34431 100644 --- a/src/remount-fs/remount-fs.c +++ b/src/remount-fs/remount-fs.c @@ -40,7 +40,7 @@ int main(int argc, char *argv[]) { int ret = EXIT_FAILURE; - FILE *f = NULL; + _cleanup_endmntent_ FILE *f = NULL; struct mntent* me; Hashmap *pids = NULL; @@ -57,16 +57,14 @@ int main(int argc, char *argv[]) { f = setmntent("/etc/fstab", "r"); if (!f) { - if (errno == ENOENT) { - ret = EXIT_SUCCESS; - goto finish; - } + if (errno == ENOENT) + return EXIT_SUCCESS; log_error("Failed to open /etc/fstab: %m"); - goto finish; + return EXIT_FAILURE; } - pids = hashmap_new(trivial_hash_func, trivial_compare_func); + pids = hashmap_new(NULL); if (!pids) { log_error("Failed to allocate set"); goto finish; @@ -122,7 +120,7 @@ int main(int argc, char *argv[]) { k = hashmap_put(pids, UINT_TO_PTR(pid), s); if (k < 0) { - log_error("Failed to add PID to set: %s", strerror(-k)); + log_error_errno(-k, "Failed to add PID to set: %m"); ret = EXIT_FAILURE; continue; } @@ -162,8 +160,5 @@ finish: if (pids) hashmap_free_free(pids); - if (f) - endmntent(f); - return ret; }