mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
Merge pull request #30040 from yuwata/assert-return-fixes
several assert_return() fixes
This commit is contained in:
@@ -931,7 +931,10 @@ int dhcp_lease_parse_search_domains(const uint8_t *option, size_t len, char ***d
|
||||
int r;
|
||||
|
||||
assert(domains);
|
||||
assert_return(option && len > 0, -ENODATA);
|
||||
assert(option || len == 0);
|
||||
|
||||
if (len == 0)
|
||||
return -EBADMSG;
|
||||
|
||||
while (pos < len) {
|
||||
_cleanup_free_ char *name = NULL;
|
||||
|
||||
@@ -60,8 +60,8 @@ TEST(dhcp_lease_parse_search_domains_no_data) {
|
||||
_cleanup_strv_free_ char **domains = NULL;
|
||||
static const uint8_t optionbuf[3] = {0, 0, 0};
|
||||
|
||||
assert_se(dhcp_lease_parse_search_domains(NULL, 0, &domains) == -ENODATA);
|
||||
assert_se(dhcp_lease_parse_search_domains(optionbuf, 0, &domains) == -ENODATA);
|
||||
assert_se(dhcp_lease_parse_search_domains(NULL, 0, &domains) == -EBADMSG);
|
||||
assert_se(dhcp_lease_parse_search_domains(optionbuf, 0, &domains) == -EBADMSG);
|
||||
}
|
||||
|
||||
TEST(dhcp_lease_parse_search_domains_loops) {
|
||||
|
||||
@@ -422,8 +422,13 @@ _public_ int sd_device_new_from_subsystem_sysname(
|
||||
int r;
|
||||
|
||||
assert_return(ret, -EINVAL);
|
||||
assert_return(path_is_normalized(subsystem), -EINVAL);
|
||||
assert_return(path_is_normalized(sysname), -EINVAL);
|
||||
assert_return(subsystem, -EINVAL);
|
||||
assert_return(sysname, -EINVAL);
|
||||
|
||||
if (!path_is_normalized(subsystem))
|
||||
return -EINVAL;
|
||||
if (!path_is_normalized(sysname))
|
||||
return -EINVAL;
|
||||
|
||||
/* translate sysname back to sysfs filename */
|
||||
name = strdupa_safe(sysname);
|
||||
|
||||
@@ -739,6 +739,10 @@ static int netdev_request_to_create(NetDev *netdev) {
|
||||
int r;
|
||||
|
||||
assert(netdev);
|
||||
assert(netdev->manager);
|
||||
|
||||
if (netdev->manager->test_mode)
|
||||
return 0;
|
||||
|
||||
if (netdev_is_stacked(netdev))
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user