summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libudev/libudev-device.c2
-rw-r--r--src/libudev/libudev-enumerate.c2
-rw-r--r--src/libudev/libudev-list.c2
-rw-r--r--src/libudev/libudev-monitor.c2
-rw-r--r--src/libudev/libudev-queue-private.c4
-rw-r--r--src/libudev/libudev-queue.c2
-rw-r--r--src/libudev/libudev-util.c7
-rw-r--r--src/libudev/libudev.c2
-rw-r--r--src/udev/udev-ctrl.c2
-rw-r--r--src/udev/udev-event.c2
-rw-r--r--src/udev/udev-rules.c2
-rw-r--r--src/udev/udevadm-hwdb.c8
-rw-r--r--src/udev/udevd.c4
13 files changed, 21 insertions, 20 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;
diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c
index 2d315ea77f..7695404bca 100644
--- a/src/udev/udev-ctrl.c
+++ b/src/udev/udev-ctrl.c
@@ -76,7 +76,7 @@ struct udev_ctrl *udev_ctrl_new_from_fd(struct udev *udev, int fd)
struct udev_ctrl *uctrl;
const int on = 1;
- uctrl = calloc(1, sizeof(struct udev_ctrl));
+ uctrl = new0(struct udev_ctrl, 1);
if (uctrl == NULL)
return NULL;
uctrl->refcount = 1;
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index 01d579b455..c4cb686821 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -41,7 +41,7 @@ struct udev_event *udev_event_new(struct udev_device *dev)
struct udev *udev = udev_device_get_udev(dev);
struct udev_event *event;
- event = calloc(1, sizeof(struct udev_event));
+ event = new0(struct udev_event, 1);
if (event == NULL)
return NULL;
event->dev = dev;
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index e5a15aa934..814e7dcaef 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -1620,7 +1620,7 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names)
char **files, **f;
int r;
- rules = calloc(1, sizeof(struct udev_rules));
+ rules = new0(struct udev_rules, 1);
if (rules == NULL)
return NULL;
rules->udev = udev;
diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c
index 614c64789c..61662fb4ae 100644
--- a/src/udev/udevadm-hwdb.c
+++ b/src/udev/udevadm-hwdb.c
@@ -197,7 +197,7 @@ static int trie_insert(struct trie *trie, struct trie_node *node, const char *se
continue;
/* split node */
- new_child = calloc(sizeof(struct trie_node), 1);
+ new_child = new0(struct trie_node, 1);
if (!new_child)
return -ENOMEM;
@@ -240,7 +240,7 @@ static int trie_insert(struct trie *trie, struct trie_node *node, const char *se
ssize_t off;
/* new child */
- child = calloc(sizeof(struct trie_node), 1);
+ child = new0(struct trie_node, 1);
if (!child)
return -ENOMEM;
@@ -583,7 +583,7 @@ static int adm_hwdb(struct udev *udev, int argc, char *argv[]) {
char **files, **f;
_cleanup_free_ char *hwdb_bin = UDEV_HWDB_BIN;
- trie = calloc(sizeof(struct trie), 1);
+ trie = new0(struct trie, 1);
if (!trie) {
rc = EXIT_FAILURE;
goto out;
@@ -597,7 +597,7 @@ static int adm_hwdb(struct udev *udev, int argc, char *argv[]) {
}
/* index */
- trie->root = calloc(sizeof(struct trie_node), 1);
+ trie->root = new0(struct trie_node, 1);
if (!trie->root) {
rc = EXIT_FAILURE;
goto out;
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index ae2067cddf..d9d3d85f8b 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -200,7 +200,7 @@ static void worker_new(struct event *event)
udev_monitor_allow_unicast_sender(worker_monitor, monitor);
udev_monitor_enable_receiving(worker_monitor);
- worker = calloc(1, sizeof(struct worker));
+ worker = new0(struct worker, 1);
if (worker == NULL) {
udev_monitor_unref(worker_monitor);
return;
@@ -431,7 +431,7 @@ static int event_queue_insert(struct udev_device *dev)
{
struct event *event;
- event = calloc(1, sizeof(struct event));
+ event = new0(struct event, 1);
if (event == NULL)
return -1;