diff options
author | kay.sievers@vrfy.org <kay.sievers@vrfy.org> | 2003-12-19 18:29:01 -0800 |
---|---|---|
committer | Greg KH <gregkh@suse.de> | 2005-04-26 21:13:09 -0700 |
commit | a56ef382869bb76ade6d26cd7e8adc983ca3f89e (patch) | |
tree | eb8ba1359793fe3994643a8aab8a5ef871986cd2 /udevdb.c | |
parent | 7ecb8d23f371a38cd918334ee7bf8383f1807ddb (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.c | 15 |
1 files changed, 4 insertions, 11 deletions
@@ -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) |