[hackers] [skvm] Fixed a couple of corner cases. || Dimitrios Papastamos

From: <hg_AT_suckless.org>
Date: Fri, 1 May 2009 16:42:04 +0000 (UTC)

changeset: 4:20771e40b9c5
tag: tip
user: Dimitrios Papastamos <stateless [at] archlinux.us>
date: Fri May 01 17:41:36 2009 -0700
files: skvm.c
description:
Fixed a couple of corner cases.

diff -r 5a0c07eba218 -r 20771e40b9c5 skvm.c
--- a/skvm.c Wed Apr 29 18:57:39 2009 -0700
+++ b/skvm.c Fri May 01 17:41:36 2009 -0700
@@ -123,7 +123,7 @@
 static int do_mount(struct device_t *device);
 
 /* general function helpers */
-static int file_exists(const char *path);
+static inline int file_exists(const char *path);
 static void cleanup(int sig);
 static int is_running(void);
 static void debug_dump_device(const struct device_t *device);
@@ -155,9 +155,7 @@
    signal(SIGTERM, cleanup);
 
    if (!debug_mode_flag) {
- if (daemon(0, 0) < 0)
- return EXIT_FAILURE;
- if (is_running()) {
+ if (daemon(0, 0) < 0 || is_running()) {
          deinit();
          return EXIT_FAILURE;
       }
@@ -236,7 +234,6 @@
 deinit(void) {
    struct device_t *iter, *tmp;
 
- closelog();
    libhal_ctx_shutdown(hal_ctx, (DBusError *)NULL);
    libhal_ctx_free(hal_ctx);
    dbus_connection_unref(dbus_conn);
@@ -250,7 +247,9 @@
    }
 
    if (pid_fd >= 0)
- close(pid_fd); /* releases lock */
+ if (close(pid_fd) < 0) /* releases lock */
+ syslog(LOG_ERR, "%s:%d %s", __FILE__, __LINE__, strerror(errno));
+ closelog();
 }
 
 /* Callback function, called when a new device has been inserted. */
@@ -593,7 +592,7 @@
               (GError **)NULL) ? 0 : -1);
 }
 
-static int
+static inline int
 file_exists(const char *s) {
    struct stat sb;
    return ((stat(s, &sb) < 0 && errno == ENOENT) ? -ENOENT : 0);
Received on Fri May 01 2009 - 16:42:04 UTC

This archive was generated by hypermail 2.2.0 : Fri May 01 2009 - 16:48:04 UTC