summaryrefslogtreecommitdiff
path: root/src/libudev/libudev-enumerate.c
AgeCommit message (Collapse)Author
2015-11-27tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easyLennart Poettering
GLIB has recently started to officially support the gcc cleanup attribute in its public API, hence let's do the same for our APIs. With this patch we'll define an xyz_unrefp() call for each public xyz_unref() call, to make it easy to use inside a __attribute__((cleanup())) expression. Then, all code is ported over to make use of this. The new calls are also documented in the man pages, with examples how to use them (well, I only added docs where the _unref() call itself already had docs, and the examples, only cover sd_bus_unrefp() and sd_event_unrefp()). This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we tend to call our destructors these days. Note that this defines no public macro that wraps gcc's attribute and makes it easier to use. While I think it's our duty in the library to make our stuff easy to use, I figure it's not our duty to make gcc's own features easy to use on its own. Most likely, client code which wants to make use of this should define its own: #define _cleanup_(function) __attribute__((cleanup(function))) Or similar, to make the gcc feature easier to use. Making this logic public has the benefit that we can remove three header files whose only purpose was to define these functions internally. See #2008.
2015-11-17tree-wide: group include of libudev.h with sd-*Thomas Hindoe Paaboel Andersen
2015-11-16tree-wide: sort includesThomas Hindoe Paaboel Andersen
Sort the includes accoding to the new coding style.
2015-10-27util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering
2015-10-24util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering
string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
2015-06-03libudev: enumerate - accept NULL parameters in add_match()Tom Gundersen
This was a regression introduced when moving to sd-device.
2015-04-17sd-device: enumerator - match only on initialized devices by defaultTom Gundersen
It is still possible to include uninitialized ones, but now that is opt-in. In most cases people only want initialized devices. Exception is if you want to work without udev running. Suggested by David Herrmann.
2015-04-17sd-device: enumerator - don't expose add_device()Tom Gundersen
This is rarely, if ever, used. Drop it from the new public API and only keep it for the legacy API. Suggested by David Herrmann.
2015-04-16libudev: make libudev-enumerate a thin wrapper around sd-deviceTom Gundersen
2015-02-23remove unused includesThomas Hindoe Paaboel Andersen
This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
2014-02-13everywhere: make use of new0() and macro() macros, and stop using perror()Lennart Poettering
2013-11-20libudev: always return NULL in _unref() APIsLennart Poettering
Returning anything else but NULL would suggest the caller's reference might still be valid, but it isn't, because the caller just invoked _unref() after all. This turns the return value into a typesafe shortcut that allows unreffing and resetting a reference in one line. In contrast to solutions for this which take a pointer to a pointer to accomplish the same this solution is just syntactic sugar the developer can make use of but doesn't have to, and this is particularly useful when immediately unreffing objects returned by function calls.
2013-10-13Never call qsort on potentially NULL arraysZbigniew Jędrzejewski-Szmek
This extends 62678ded 'efi: never call qsort on potentially NULL arrays' to all other places where qsort is used and it is not obvious that the count is non-zero.
2013-09-13libudev: fix move_later comparisonLukas Nykryn
At the beginning move_later is set to -1, but it is set to different value only if expression !move_later is true.
2013-09-04libudev: enumerate - do not try to match against an empty subsystemKay Sievers
2013-09-04libudev: enumerate: fix NULL-deref for subsystem-matchesDavid Herrmann
udev_device_get_subsystem() may return NULL if no subsystem could be figured out by libudev. This might be due to OOM or if the device disconnected between the udev_device_new() call and udev_device_get_subsystem(). Therefore, we need to handle subsystem==NULL safely. Instead of testing for it in each helper, we treat subsystem==NULL as empty subsystem in match_subsystem(). Backtrace of udev_enumerate with an input-device disconnecting in exactly this time-frame: (gdb) bt #0 0x00007ffff569dc24 in strnlen () from /usr/lib/libc.so.6 #1 0x00007ffff56d9e04 in fnmatch@@GLIBC_2.2.5 () from /usr/lib/libc.so.6 #2 0x00007ffff5beb83d in match_subsystem (udev_enumerate=0x7a05f0, subsystem=0x0) at src/libudev/libudev-enumerate.c:727 #3 0x00007ffff5bebb30 in parent_add_child (enumerate=enumerate@entry=0x7a05f0, path=<optimized out>) at src/libudev/libudev-enumerate.c:834 #4 0x00007ffff5bebc3f in parent_crawl_children (enumerate=enumerate@entry=0x7a05f0, path=0x7a56b0 "/sys/devices/<shortened>/input/input97", maxdepth=maxdepth@entry=254) at src/libudev/libudev-enumerate.c:866 #5 0x00007ffff5bebc54 in parent_crawl_children (enumerate=enumerate@entry=0x7a05f0, path=0x79e8c0 "/sys/devices/<shortened>/input", maxdepth=maxdepth@entry=255) at src/libudev/libudev-enumerate.c:868 #6 0x00007ffff5bebc54 in parent_crawl_children (enumerate=enumerate@entry=0x7a05f0, path=path@entry=0x753190 "/sys/devices/<shortened>", maxdepth=maxdepth@entry=256) at src/libudev/libudev-enumerate.c:868 #7 0x00007ffff5bec7df in scan_devices_children (enumerate=0x7a05f0) at src/libudev/libudev-enumerate.c:882 #8 udev_enumerate_scan_devices (udev_enumerate=udev_enumerate@entry=0x7a05f0) at src/libudev/libudev-enumerate.c:919 #9 0x00007ffff5df8777 in <random_caller> () at some/file.c:181
2013-09-04libudev: fix memleak when enumerating childsDavid Herrmann
We need to free udev-devices again if they don't match. Funny that no-one noticed it yet since valgrind is quite verbose about it. Fix it and free non-matching devices.
2013-08-19libudev-enumerate.c:udev_enumerate_get_list_entry() fixed possible stale pointerHarald Hoyer
If a realloc() happens in syspath_add(), the move_later pointer could point to an invalid memory region. Let move_later store the array index, instead of the pointer to the entry.
2013-02-13use strneq instead of strncmpThomas Hindoe Paaboel Andersen
2013-01-09udev: move string copy functions to shared/Kay Sievers
2012-12-14libudev: validate 'udev' argument to udev_enumerate_new()Michael Terry
https://bugs.freedesktop.org/show_bug.cgi?id=58289
2012-11-12libudev: update copyright headersKay Sievers
2012-08-10udev: export udev_device_new_from_device_id()Kay Sievers
2012-05-15udev: update docs, NEWSKay Sievers
2012-05-15udev: libudev - bump soname, remove deprecated functions, introduce symbol ↵Kay Sievers
versions
2012-04-20docs: hook-up gtk-doc to 'make check'Kay Sievers
2012-04-16udev: use startswith() and streq()Kay Sievers
2012-04-16udev: remove configuration options for /dev, /sys, /run directoriesKay Sievers
2012-04-13udev: move libudev, gudev to src/; move gudev/docs/, udev/docs/ to to docs/Kay Sievers