X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Futil.c;h=d3876ded5b154ae17e6059139bd8d3bb472740de;hb=9a57c62944258c750d80bca4fe56de4dbab46d67;hp=21afdceb8cc4cf666de6d36318c1ea30be175de7;hpb=5f7c426e2a7f72c473f98be9978d243db79d8910;p=elogind.git diff --git a/src/util.c b/src/util.c index 21afdceb8..d3876ded5 100644 --- a/src/util.c +++ b/src/util.c @@ -2617,33 +2617,6 @@ int make_null_stdio(void) { return make_stdio(null_fd); } -bool is_clean_exit(int code, int status) { - - if (code == CLD_EXITED) - return status == 0; - - /* If a daemon does not implement handlers for some of the - * signals that's not considered an unclean shutdown */ - if (code == CLD_KILLED) - return - status == SIGHUP || - status == SIGINT || - status == SIGTERM || - status == SIGPIPE; - - return false; -} - -bool is_clean_exit_lsb(int code, int status) { - - if (is_clean_exit(code, status)) - return true; - - return - code == CLD_EXITED && - (status == EXIT_NOTINSTALLED || status == EXIT_NOTCONFIGURED); -} - bool is_device_path(const char *path) { /* Returns true on paths that refer to a device, either in @@ -3090,6 +3063,9 @@ void status_welcome(void) { status_printf("Welcome to \x1B[%sm%s\x1B[0m!\n", const_color ? const_color : ansi_color, const_pretty ? const_pretty : pretty_name); + + free(ansi_color); + free(pretty_name); } char *replace_env(const char *format, char **env) { @@ -3436,7 +3412,18 @@ bool null_or_empty(struct stat *st) { } DIR *xopendirat(int fd, const char *name, int flags) { - return fdopendir(openat(fd, name, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|flags)); + int nfd; + DIR *d; + + if ((nfd = openat(fd, name, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|flags)) < 0) + return NULL; + + if (!(d = fdopendir(nfd))) { + close_nointr_nofail(nfd); + return NULL; + } + + return d; } int signal_from_string_try_harder(const char *s) { @@ -3517,7 +3504,7 @@ char *fstab_node_to_udev_node(const char *p) { if (!t) return NULL; - r = asprintf(&dn, "/dev/disk/by-uuid/%s", ascii_strlower(t)); + r = asprintf(&dn, "/dev/disk/by-uuid/%s", t); free(t); if (r < 0)