coccinelle: make use of SYNTHETIC_ERRNO
Ideally, coccinelle would strip unnecessary braces too. But I do not see any option in coccinelle for this, so instead, I edited the patch text using search&replace to remove the braces. Unfortunately this is not fully automatic, in particular it didn't deal well with if-else-if-else blocks and ifdefs, so there is an increased likelikehood be some bugs in such spots. I also removed part of the patch that coccinelle generated for udev, where we returns -1 for failure. This should be fixed independently.
This commit is contained in:
@@ -3832,11 +3832,13 @@ static int build_struct_offsets(
|
||||
x = size - (n_variable * sz);
|
||||
|
||||
offset = m->rindex + x;
|
||||
if (offset < start) {
|
||||
log_debug("For type %s with alignment %zu, message specifies offset %zu which is smaller than previous end %zu + alignment = %zu",
|
||||
t, align, offset, previous, start);
|
||||
return -EBADMSG;
|
||||
}
|
||||
if (offset < start)
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG),
|
||||
"For type %s with alignment %zu, message specifies offset %zu which is smaller than previous end %zu + alignment = %zu",
|
||||
t, align,
|
||||
offset,
|
||||
previous,
|
||||
start);
|
||||
} else
|
||||
/* Fixed size */
|
||||
offset = start + k;
|
||||
|
||||
@@ -137,10 +137,10 @@ int device_set_syspath(sd_device *device, const char *_syspath, bool verify) {
|
||||
assert(_syspath);
|
||||
|
||||
/* must be a subdirectory of /sys */
|
||||
if (!path_startswith(_syspath, "/sys/")) {
|
||||
log_debug("sd-device: Syspath '%s' is not a subdirectory of /sys", _syspath);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!path_startswith(_syspath, "/sys/"))
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"sd-device: Syspath '%s' is not a subdirectory of /sys",
|
||||
_syspath);
|
||||
|
||||
if (verify) {
|
||||
r = chase_symlinks(_syspath, NULL, 0, &syspath);
|
||||
@@ -159,10 +159,10 @@ int device_set_syspath(sd_device *device, const char *_syspath, bool verify) {
|
||||
return log_debug_errno(r, "sd-device: Failed to chase symlink /sys: %m");
|
||||
|
||||
p = path_startswith(syspath, real_sys);
|
||||
if (!p) {
|
||||
log_debug("sd-device: Canonicalized path '%s' does not starts with sysfs mount point '%s'", syspath, real_sys);
|
||||
return -ENODEV;
|
||||
}
|
||||
if (!p)
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(ENODEV),
|
||||
"sd-device: Canonicalized path '%s' does not starts with sysfs mount point '%s'",
|
||||
syspath, real_sys);
|
||||
|
||||
new_syspath = strjoin("/sys/", p);
|
||||
if (!new_syspath)
|
||||
|
||||
@@ -224,10 +224,10 @@ int sd_netlink_send(sd_netlink *nl,
|
||||
int rtnl_rqueue_make_room(sd_netlink *rtnl) {
|
||||
assert(rtnl);
|
||||
|
||||
if (rtnl->rqueue_size >= RTNL_RQUEUE_MAX) {
|
||||
log_debug("rtnl: exhausted the read queue size (%d)", RTNL_RQUEUE_MAX);
|
||||
return -ENOBUFS;
|
||||
}
|
||||
if (rtnl->rqueue_size >= RTNL_RQUEUE_MAX)
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(ENOBUFS),
|
||||
"rtnl: exhausted the read queue size (%d)",
|
||||
RTNL_RQUEUE_MAX);
|
||||
|
||||
if (!GREEDY_REALLOC(rtnl->rqueue, rtnl->rqueue_allocated, rtnl->rqueue_size + 1))
|
||||
return -ENOMEM;
|
||||
@@ -238,10 +238,10 @@ int rtnl_rqueue_make_room(sd_netlink *rtnl) {
|
||||
int rtnl_rqueue_partial_make_room(sd_netlink *rtnl) {
|
||||
assert(rtnl);
|
||||
|
||||
if (rtnl->rqueue_partial_size >= RTNL_RQUEUE_MAX) {
|
||||
log_debug("rtnl: exhausted the partial read queue size (%d)", RTNL_RQUEUE_MAX);
|
||||
return -ENOBUFS;
|
||||
}
|
||||
if (rtnl->rqueue_partial_size >= RTNL_RQUEUE_MAX)
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(ENOBUFS),
|
||||
"rtnl: exhausted the partial read queue size (%d)",
|
||||
RTNL_RQUEUE_MAX);
|
||||
|
||||
if (!GREEDY_REALLOC(rtnl->rqueue_partial, rtnl->rqueue_partial_allocated,
|
||||
rtnl->rqueue_partial_size + 1))
|
||||
|
||||
Reference in New Issue
Block a user