Age | Commit message (Collapse) | Author |
|
set_iterate sets the output argument to NULL on error, and the return
value is not used in this case.
CID #1306804-09.
|
|
The code is correct, assuming that the kernel does not feed
us garbled data. Let's initialize those variables to avoid the
warning anyway.
|
|
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.
|
|
We have enough places where we parse an ifindex, hence introduce a
proper parsing function for it, that verifies all parameters.
|
|
|
|
|
|
|
|
|
|
There are more than enough to deserve their own .c file, hence move them
over.
|
|
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.
|
|
The kernel replaces '/' in device names with '!', we translate that back
to '/' in sysname, when taking sysname as input, we should translate it
back again.
|
|
Use %m where previously %s was used together with strerrno().
Fixes: e53fc357a9b "tree-wide: remove a number of invocations of
strerror() and replace by %m"
|
|
A few of the recent conversions to log_*_errno() were missing the errno
value arguments.
Fixes: e53fc357a9b "tree-wide: remove a number of invocations of
strerror() and replace by %m"
|
|
Let's clean up our tree a bit, and reduce invocations of the
thread-unsafe strerror() by replacing it with printf()'s %m specifier.
|
|
It is highly confusing if a getter function returns 0, but the value is
set to NULL. This, right now, triggers assertions as code relies on the
returned values to be non-NULL.
Like with sd-bus-creds and friends, return 0 only if a value is actually
available.
Discussed with Tom, and actually fixes real bugs as in #512.
|
|
Currently, the HASHMAP iterators stop at the first NULL entry in a
hashmap. This is non-obvious and breaks users like sd-device, which
legitimately store NULL values in a hashmap.
Fix all the iterators by taking a pointer to the value storage, instead of
returning it. The iterators now return a boolean that tells whether the
end of the list was reached.
Current users of HASHMAP_FOREACH() are *NOT* changed to explicitly check
for NULL. If it turns out, there were users that inserted NULL into
hashmaps, but didn't properly check for it during iteration, then we
really want to find those and fix them.
|
|
|
|
Don't try to read it again.
|
|
|
|
asprintf() does not set errno.
|
|
If for whatever reason there was nothing to load or loading failed, don't keep trying.
|
|
Only 'real' devices are required to have an uevent file.
|
|
This reverts b67f944. Lazy loading of device properties does not work for devices
that are received over netlink, as these are sealed. Reinstate the unconditional
loading of the device db.
Reported by: Mantas Mikulėnas <grawity@gmail.com>.
|
|
device
|
|
sd_device_new_from_* now returns -ENODEV when the device does not exist, and the enumerator
silently drops these errors as missing devices is exepected.
|
|
|
|
|
|
|
|
Right now, we always drop the last character of all values we write to
sysfs. Fix this!
|
|
This was getting leaked as a copy was added to the hashmap, simply add the
returned value instead.
This should fix CID #1292806.
|
|
sysnum would not be initialized if sysname had no trailing digits.
|
|
This provides equivalent functionality to libudev-device, but in the
systemd style. The public API only caters to creating sd_device objects
from for devices that already exist in /sys, there is no support for
listening for monitoring events or creating devices received over
the udev netlink protocol.
The private API contains the necessary functionality to make sd-device
a drop-in replacement for libudev-device, but which we would not
otherwise want to export.
|