diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-02-13 14:45:51 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-02-13 14:45:51 +0100 |
commit | 955d98c9c1104d469c2989dbfb58f58ee6fe9bdc (patch) | |
tree | 6964487e69bfefbbb08b0de140c67c6f2a00d791 /src/libudev | |
parent | 7e2270246b0906675c8f34bc278b1608b969e65c (diff) |
everywhere: make use of new0() and macro() macros, and stop using perror()
Diffstat (limited to 'src/libudev')
-rw-r--r-- | src/libudev/libudev-device.c | 2 | ||||
-rw-r--r-- | src/libudev/libudev-enumerate.c | 2 | ||||
-rw-r--r-- | src/libudev/libudev-list.c | 2 | ||||
-rw-r--r-- | src/libudev/libudev-monitor.c | 2 | ||||
-rw-r--r-- | src/libudev/libudev-queue-private.c | 4 | ||||
-rw-r--r-- | src/libudev/libudev-queue.c | 2 | ||||
-rw-r--r-- | src/libudev/libudev-util.c | 7 | ||||
-rw-r--r-- | src/libudev/libudev.c | 2 |
8 files changed, 12 insertions, 11 deletions
diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c index 38144e3fbe..9f80f56d42 100644 --- a/src/libudev/libudev-device.c +++ b/src/libudev/libudev-device.c @@ -647,7 +647,7 @@ struct udev_device *udev_device_new(struct udev *udev) if (udev == NULL) return NULL; - udev_device = calloc(1, sizeof(struct udev_device)); + udev_device = new0(struct udev_device, 1); if (udev_device == NULL) return NULL; udev_device->refcount = 1; diff --git a/src/libudev/libudev-enumerate.c b/src/libudev/libudev-enumerate.c index 48ffe83d36..1a880c2a34 100644 --- a/src/libudev/libudev-enumerate.c +++ b/src/libudev/libudev-enumerate.c @@ -83,7 +83,7 @@ _public_ struct udev_enumerate *udev_enumerate_new(struct udev *udev) if (udev == NULL) return NULL; - udev_enumerate = calloc(1, sizeof(struct udev_enumerate)); + udev_enumerate = new0(struct udev_enumerate, 1); if (udev_enumerate == NULL) return NULL; udev_enumerate->refcount = 1; diff --git a/src/libudev/libudev-list.c b/src/libudev/libudev-list.c index c6e5a61fe9..42fcb853c7 100644 --- a/src/libudev/libudev-list.c +++ b/src/libudev/libudev-list.c @@ -165,7 +165,7 @@ struct udev_list_entry *udev_list_entry_add(struct udev_list *list, const char * } /* add new name */ - entry = calloc(1, sizeof(struct udev_list_entry)); + entry = new0(struct udev_list_entry, 1); if (entry == NULL) return NULL; entry->name = strdup(name); diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c index f976da0b8a..ba1b04d479 100644 --- a/src/libudev/libudev-monitor.c +++ b/src/libudev/libudev-monitor.c @@ -96,7 +96,7 @@ static struct udev_monitor *udev_monitor_new(struct udev *udev) { struct udev_monitor *udev_monitor; - udev_monitor = calloc(1, sizeof(struct udev_monitor)); + udev_monitor = new0(struct udev_monitor, 1); if (udev_monitor == NULL) return NULL; udev_monitor->refcount = 1; diff --git a/src/libudev/libudev-queue-private.c b/src/libudev/libudev-queue-private.c index 80d7ceef2b..d5a2b503dd 100644 --- a/src/libudev/libudev-queue-private.c +++ b/src/libudev/libudev-queue-private.c @@ -79,7 +79,7 @@ struct udev_queue_export *udev_queue_export_new(struct udev *udev) if (udev == NULL) return NULL; - udev_queue_export = calloc(1, sizeof(struct udev_queue_export)); + udev_queue_export = new0(struct udev_queue_export, 1); if (udev_queue_export == NULL) return NULL; udev_queue_export->udev = udev; @@ -162,7 +162,7 @@ static struct queue_devpaths *build_index(struct udev_queue_export *udev_queue_e udev_err(udev_queue_export->udev, "queue file overflow\n"); return NULL; } - devpaths = calloc(1, sizeof(struct queue_devpaths) + (range + 1) * sizeof(long)); + devpaths = malloc0(sizeof(struct queue_devpaths) + (range + 1) * sizeof(long)); if (devpaths == NULL) return NULL; devpaths->devpaths_size = range + 1; diff --git a/src/libudev/libudev-queue.c b/src/libudev/libudev-queue.c index f67dba9958..2cb4d67121 100644 --- a/src/libudev/libudev-queue.c +++ b/src/libudev/libudev-queue.c @@ -69,7 +69,7 @@ _public_ struct udev_queue *udev_queue_new(struct udev *udev) if (udev == NULL) return NULL; - udev_queue = calloc(1, sizeof(struct udev_queue)); + udev_queue = new0(struct udev_queue, 1); if (udev_queue == NULL) return NULL; udev_queue->refcount = 1; diff --git a/src/libudev/libudev-util.c b/src/libudev/libudev-util.c index c940e06f71..d9cdde1751 100644 --- a/src/libudev/libudev-util.c +++ b/src/libudev/libudev-util.c @@ -203,6 +203,7 @@ int util_resolve_subsys_kernel(struct udev *udev, const char *string, udev_device_unref(dev); return 0; } + ssize_t util_get_sys_core_link_value(struct udev *udev, const char *slink, const char *syspath, char *value, size_t size) { char path[UTIL_PATH_SIZE]; @@ -417,7 +418,7 @@ uint64_t util_string_bloom64(const char *str) ssize_t print_kmsg(const char *fmt, ...) { - int fd; + _cleanup_close_ int fd = -1; va_list ap; char text[1024]; ssize_t len; @@ -435,7 +436,7 @@ ssize_t print_kmsg(const char *fmt, ...) ret = write(fd, text, len); if (ret < 0) - ret = -errno; - close(fd); + return -errno; + return ret; } diff --git a/src/libudev/libudev.c b/src/libudev/libudev.c index e1ba82febf..e2ab960d55 100644 --- a/src/libudev/libudev.c +++ b/src/libudev/libudev.c @@ -121,7 +121,7 @@ _public_ struct udev *udev_new(void) const char *env; FILE *f; - udev = calloc(1, sizeof(struct udev)); + udev = new0(struct udev, 1); if (udev == NULL) return NULL; udev->refcount = 1; |