From: Kay Sievers <kay.sievers@vrfy.org>
To: linux-hotplug@vger.kernel.org
Subject: [udev] small cleanup udev-remove.c
Date: Mon, 22 Dec 2003 22:32:11 +0000 [thread overview]
Message-ID: <marc-linux-hotplug-107213252012039@msgid-missing> (raw)
[-- Attachment #1: Type: text/plain, Size: 120 bytes --]
Here is a small cleanup. It replaces the malloc in udev-remove.c
with a struct, like we do in udev-add.c
thanks,
Kay
[-- Attachment #2: 01-struct-instead-of-malloc.diff --]
[-- Type: text/plain, Size: 1037 bytes --]
diff -Nru a/udev-remove.c b/udev-remove.c
--- a/udev-remove.c Mon Dec 22 21:56:33 2003
+++ b/udev-remove.c Mon Dec 22 21:56:33 2003
@@ -118,30 +118,26 @@
*/
int udev_remove_device(char *path, char *subsystem)
{
- struct udevice *dev;
+ struct udevice dev;
char *temp;
int retval;
- dev = malloc(sizeof(*dev));
- if (dev == NULL)
- return -ENOMEM;
- memset(dev, 0, sizeof(*dev));
+ memset(&dev, 0, sizeof(dev));
- retval = udevdb_get_dev(path, dev);
+ retval = udevdb_get_dev(path, &dev);
if (retval) {
dbg("'%s' not found in database, falling back on default name", path);
temp = strrchr(path, '/');
if (temp == NULL)
return -ENODEV;
- strncpy(dev->name, &temp[1], sizeof(dev->name));
+ strncpy(dev.name, &temp[1], sizeof(dev.name));
}
- dbg("name is '%s'", dev->name);
+ dbg("name is '%s'", dev.name);
udevdb_delete_dev(path);
- sysbus_send_remove(dev->name, path);
+ sysbus_send_remove(dev.name, path);
- retval = delete_node(dev);
- free(dev);
+ retval = delete_node(&dev);
return retval;
}
next reply other threads:[~2003-12-22 22:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-12-22 22:32 Kay Sievers [this message]
-- strict thread matches above, loose matches on Subject: below --
2003-12-22 22:57 [udev] small cleanup udev-remove.c Rob Love
2003-12-22 22:57 ` Greg KH
2003-12-22 23:23 ` Kay Sievers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=marc-linux-hotplug-107213252012039@msgid-missing \
--to=kay.sievers@vrfy.org \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.