*: code cleanup
This commit is contained in:
parent
5f9186af41
commit
3d98bea289
5 changed files with 8 additions and 11 deletions
2
udev.c
2
udev.c
|
|
@ -27,7 +27,7 @@ struct udev *udev_new(void)
|
||||||
{
|
{
|
||||||
struct udev *udev;
|
struct udev *udev;
|
||||||
|
|
||||||
udev = calloc(1, sizeof(struct udev));
|
udev = calloc(1, sizeof(*udev));
|
||||||
|
|
||||||
if (!udev) {
|
if (!udev) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,6 @@
|
||||||
#include "udev.h"
|
#include "udev.h"
|
||||||
#include "udev_list.h"
|
#include "udev_list.h"
|
||||||
|
|
||||||
// sizeof(unsigned long) == 4 * 8 == 32 on 32-bit systems.
|
|
||||||
// sizeof(unsigned long) == 8 * 8 == 64 on 64-bit systems.
|
|
||||||
#ifndef LONG_BIT
|
#ifndef LONG_BIT
|
||||||
#define LONG_BIT (sizeof(unsigned long) * 8)
|
#define LONG_BIT (sizeof(unsigned long) * 8)
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -547,7 +545,7 @@ struct udev_device *udev_device_new_from_syspath(struct udev *udev, const char *
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
udev_device = calloc(1, sizeof(struct udev_device));
|
udev_device = calloc(1, sizeof(*udev_device));
|
||||||
|
|
||||||
if (!udev_device) {
|
if (!udev_device) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -650,7 +648,7 @@ struct udev_device *udev_device_new_from_file(struct udev *udev, const char *pat
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
udev_device = calloc(1, sizeof(struct udev_device));
|
udev_device = calloc(1, sizeof(*udev_device));
|
||||||
|
|
||||||
if (!udev_device) {
|
if (!udev_device) {
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
|
||||||
|
|
@ -275,8 +275,8 @@ static int scan_devices(struct udev_enumerate *udev_enumerate, const char *path)
|
||||||
{
|
{
|
||||||
struct udev_enumerate_thread *thread;
|
struct udev_enumerate_thread *thread;
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
|
int i, cnt, ret = 1;
|
||||||
struct dirent **de;
|
struct dirent **de;
|
||||||
int ret, cnt, i;
|
|
||||||
|
|
||||||
cnt = scandir(path, &de, filter_dot, NULL);
|
cnt = scandir(path, &de, filter_dot, NULL);
|
||||||
|
|
||||||
|
|
@ -284,8 +284,7 @@ static int scan_devices(struct udev_enumerate *udev_enumerate, const char *path)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 1;
|
thread = calloc(cnt, sizeof(*thread));
|
||||||
thread = calloc(cnt, sizeof(struct udev_enumerate_thread));
|
|
||||||
|
|
||||||
if (!thread) {
|
if (!thread) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
@ -368,7 +367,7 @@ struct udev_enumerate *udev_enumerate_new(struct udev *udev)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
udev_enumerate = calloc(1, sizeof(struct udev_enumerate));
|
udev_enumerate = calloc(1, sizeof(*udev_enumerate));
|
||||||
|
|
||||||
if (!udev_enumerate) {
|
if (!udev_enumerate) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ struct udev_list_entry *udev_list_entry_add(struct udev_list_entry *list_entry,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list_entry2 = calloc(1, sizeof(struct udev_list_entry));
|
list_entry2 = calloc(1, sizeof(*list_entry2));
|
||||||
|
|
||||||
if (!list_entry2) {
|
if (!list_entry2) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
|
|
@ -248,7 +248,7 @@ struct udev_monitor *udev_monitor_new_from_netlink(struct udev *udev, const char
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
udev_monitor = calloc(1, sizeof(struct udev_monitor));
|
udev_monitor = calloc(1, sizeof(*udev_monitor));
|
||||||
|
|
||||||
if (!udev_monitor) {
|
if (!udev_monitor) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue