summaryrefslogtreecommitdiff
path: root/udevdb.c
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2003-12-19 18:29:01 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:13:09 -0700
commita56ef382869bb76ade6d26cd7e8adc983ca3f89e (patch)
treeeb8ba1359793fe3994643a8aab8a5ef871986cd2 /udevdb.c
parent7ecb8d23f371a38cd918334ee7bf8383f1807ddb (diff)
[PATCH] udev-remove.c cleanups
I've moved the malloc out of the udevdb into udev-remove to free the struct after use and not to allocate a different struct in the case the device is not in the data base. I seems a bit easier to read.
Diffstat (limited to 'udevdb.c')
-rw-r--r--udevdb.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/udevdb.c b/udevdb.c
index 5be3c25151..bbbeddad47 100644
--- a/udevdb.c
+++ b/udevdb.c
@@ -62,29 +62,22 @@ int udevdb_add_dev(const char *path, const struct udevice *dev)
return tdb_store(udevdb, key, data, TDB_REPLACE);
}
-struct udevice *udevdb_get_dev(const char *path)
+int udevdb_get_dev(const char *path, struct udevice *dev)
{
TDB_DATA key, data;
- struct udevice *dev;
if (path == NULL)
- return NULL;
+ return -ENODEV;
key.dptr = (void *)path;
key.dsize = strlen(path) + 1;
data = tdb_fetch(udevdb, key);
if (data.dptr == NULL || data.dsize == 0)
- return NULL;
-
- dev = malloc(sizeof(*dev));
- if (dev == NULL)
- goto exit;
+ return -ENODEV;
memcpy(dev, data.dptr, sizeof(*dev));
-exit:
- free(data.dptr);
- return dev;
+ return 0;
}
int udevdb_delete_dev(const char *path)