diff options
author | Jeremy Sowden <jeremy@azazel.net> | 2021-11-30 10:55:31 +0000 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2021-11-30 20:55:17 +0100 |
commit | b612f69e558bb9dad8140c1d793955e1fb2d9332 (patch) | |
tree | d13f7da59e833f822ead00546479cffde0f27f6c | |
parent | e9ae548078135f047b855177906040d86d75ee08 (diff) |
filter: HWHDR: simplify flow-control
The `interp_mac2str` function concludes with a `switch` followed by a
`return` statement.
The `switch` has one case falling through to a default:
switch (expr) {
case X:
// ... X code ...
default:
// ... default code ...
}
This is equivalent to the simpler and more readily comprehensible:
if (expr == X) {
// ... X code ...
}
// ... default code ...
Replace the former with the latter.
Doing so makes it obvious that the following `return` statement is never
reached. Remove it.
Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r-- | filter/ulogd_filter_HWHDR.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/filter/ulogd_filter_HWHDR.c b/filter/ulogd_filter_HWHDR.c index 10c95c4..d756d35 100644 --- a/filter/ulogd_filter_HWHDR.c +++ b/filter/ulogd_filter_HWHDR.c @@ -207,19 +207,17 @@ static int interp_mac2str(struct ulogd_pluginstance *pi) okey_set_u16(&ret[KEY_MAC_TYPE], type); } - switch (type) { - case ARPHRD_ETHER: - parse_ethernet(ret, inp); - default: - if (!pp_is_valid(inp, KEY_RAW_MAC)) - return ULOGD_IRET_OK; - /* convert raw header to string */ - return parse_mac2str(ret, - ikey_get_ptr(&inp[KEY_RAW_MAC]), - KEY_MAC_ADDR, - ikey_get_u16(&inp[KEY_RAW_MACLEN])); - } - return ULOGD_IRET_OK; + if (type == ARPHRD_ETHER) + parse_ethernet(ret, inp); + + if (!pp_is_valid(inp, KEY_RAW_MAC)) + return ULOGD_IRET_OK; + + /* convert raw header to string */ + return parse_mac2str(ret, + ikey_get_ptr(&inp[KEY_RAW_MAC]), + KEY_MAC_ADDR, + ikey_get_u16(&inp[KEY_RAW_MACLEN])); } |