network: make DEFINE_NETDEV_CAST() assert on input and output
The macro used to return NULL if input was NULL or had the wrong type. Now it asserts that input is nonnull and it has the expected type. There are a few places where a missing or mismatched type was OK, but in a majority of places, we would do both of the asserts. In various places we'd only do one, but that was by ommission/mistake. So moving the asserts into the macro allows us to save some lines.
This commit is contained in:
@@ -10,17 +10,12 @@
|
||||
#include "vlan.h"
|
||||
|
||||
static int netdev_vlan_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *req) {
|
||||
struct ifla_vlan_flags flags = {};
|
||||
VLan *v;
|
||||
int r;
|
||||
|
||||
assert(netdev);
|
||||
assert(link);
|
||||
assert(req);
|
||||
|
||||
v = VLAN(netdev);
|
||||
|
||||
assert(v);
|
||||
struct ifla_vlan_flags flags = {};
|
||||
VLan *v = VLAN(netdev);
|
||||
int r;
|
||||
|
||||
r = sd_netlink_message_append_u16(req, IFLA_VLAN_ID, v->id);
|
||||
if (r < 0)
|
||||
@@ -180,14 +175,9 @@ int config_parse_vlan_qos_maps(
|
||||
}
|
||||
|
||||
static int netdev_vlan_verify(NetDev *netdev, const char *filename) {
|
||||
VLan *v;
|
||||
|
||||
assert(netdev);
|
||||
assert(filename);
|
||||
|
||||
v = VLAN(netdev);
|
||||
|
||||
assert(v);
|
||||
VLan *v = VLAN(netdev);
|
||||
|
||||
if (v->id == VLANID_INVALID) {
|
||||
log_netdev_warning(netdev, "VLAN without valid Id (%"PRIu16") configured in %s.", v->id, filename);
|
||||
@@ -197,12 +187,8 @@ static int netdev_vlan_verify(NetDev *netdev, const char *filename) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void vlan_done(NetDev *n) {
|
||||
VLan *v;
|
||||
|
||||
v = VLAN(n);
|
||||
|
||||
assert(v);
|
||||
static void vlan_done(NetDev *netdev) {
|
||||
VLan *v = VLAN(netdev);
|
||||
|
||||
set_free(v->egress_qos_maps);
|
||||
set_free(v->ingress_qos_maps);
|
||||
@@ -211,9 +197,6 @@ static void vlan_done(NetDev *n) {
|
||||
static void vlan_init(NetDev *netdev) {
|
||||
VLan *v = VLAN(netdev);
|
||||
|
||||
assert(netdev);
|
||||
assert(v);
|
||||
|
||||
v->id = VLANID_INVALID;
|
||||
v->protocol = -1;
|
||||
v->gvrp = -1;
|
||||
|
||||
Reference in New Issue
Block a user