diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-02-17 08:39:47 -0500 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2014-02-21 10:05:22 -0500 |
commit | 9fa108ac48c9b76111589967184436bf63109731 (patch) | |
tree | a17d913ab78fdb340c1b7ce13c83563937cc316c /src/libudev | |
parent | c1db5c60e38fa4b1cd2c590dbc8ce95c4fc3844b (diff) |
everywhere: make use of new0() and macro() macros, and stop using perror()
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
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 bd22741c66..ff522b8607 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 2c31d5b1db..531c76c6a3 100644 --- a/src/libudev/libudev-util.c +++ b/src/libudev/libudev-util.c @@ -211,6 +211,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]; @@ -425,7 +426,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; @@ -443,7 +444,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 c7f9dc4639..4373ab4d54 100644 --- a/src/libudev/libudev.c +++ b/src/libudev/libudev.c @@ -120,7 +120,7 @@ _public_ struct udev *udev_new(void) struct udev *udev; FILE *f; - udev = calloc(1, sizeof(struct udev)); + udev = new0(struct udev, 1); if (udev == NULL) return NULL; udev->refcount = 1; |