platform: add macro FOR_EACH_DELAYED_ACTION()

This commit is contained in:
Thomas Haller
2016-04-07 17:14:03 +02:00
parent 198baca830
commit 15e357c30a

View File

@@ -198,6 +198,10 @@ typedef enum {
DELAYED_ACTION_TYPE_MAX = __DELAYED_ACTION_TYPE_MAX -1, DELAYED_ACTION_TYPE_MAX = __DELAYED_ACTION_TYPE_MAX -1,
} DelayedActionType; } DelayedActionType;
#define FOR_EACH_DELAYED_ACTION(iflags, flags_all) \
for ((iflags) = (DelayedActionType) 0x1LL; (iflags) <= DELAYED_ACTION_TYPE_MAX; (iflags) <<= 1) \
if (NM_FLAGS_HAS (flags_all, iflags))
typedef enum { typedef enum {
/* Negative values are errors from kernel. Add dummy member to /* Negative values are errors from kernel. Add dummy member to
* make enum signed. */ * make enum signed. */
@@ -2936,8 +2940,7 @@ delayed_action_handle_one (NMPlatform *platform)
priv->delayed_action.flags &= ~DELAYED_ACTION_TYPE_REFRESH_ALL; priv->delayed_action.flags &= ~DELAYED_ACTION_TYPE_REFRESH_ALL;
if (_LOGt_ENABLED ()) { if (_LOGt_ENABLED ()) {
for (iflags = (DelayedActionType) 0x1LL; iflags <= DELAYED_ACTION_TYPE_MAX; iflags <<= 1) { FOR_EACH_DELAYED_ACTION (iflags, flags) {
if (NM_FLAGS_HAS (flags, iflags))
_LOGt_delayed_action (iflags, NULL, "handle"); _LOGt_delayed_action (iflags, NULL, "handle");
} }
} }
@@ -3023,8 +3026,7 @@ delayed_action_schedule (NMPlatform *platform, DelayedActionType action_type, gp
priv->delayed_action.flags |= action_type; priv->delayed_action.flags |= action_type;
if (_LOGt_ENABLED ()) { if (_LOGt_ENABLED ()) {
for (iflags = (DelayedActionType) 0x1LL; iflags <= DELAYED_ACTION_TYPE_MAX; iflags <<= 1) { FOR_EACH_DELAYED_ACTION (iflags, action_type) {
if (NM_FLAGS_HAS (action_type, iflags))
_LOGt_delayed_action (iflags, user_data, "schedule"); _LOGt_delayed_action (iflags, user_data, "schedule");
} }
} }
@@ -3421,13 +3423,11 @@ do_request_all_no_delayed_actions (NMPlatform *platform, DelayedActionType actio
nm_assert (!NM_FLAGS_ANY (action_type, ~DELAYED_ACTION_TYPE_REFRESH_ALL)); nm_assert (!NM_FLAGS_ANY (action_type, ~DELAYED_ACTION_TYPE_REFRESH_ALL));
action_type &= DELAYED_ACTION_TYPE_REFRESH_ALL; action_type &= DELAYED_ACTION_TYPE_REFRESH_ALL;
for (iflags = (DelayedActionType) 0x1LL; iflags <= DELAYED_ACTION_TYPE_MAX; iflags <<= 1) { FOR_EACH_DELAYED_ACTION (iflags, action_type) {
if (NM_FLAGS_HAS (action_type, iflags))
cache_prune_candidates_record_all (platform, delayed_action_refresh_to_object_type (iflags)); cache_prune_candidates_record_all (platform, delayed_action_refresh_to_object_type (iflags));
} }
for (iflags = (DelayedActionType) 0x1LL; iflags <= DELAYED_ACTION_TYPE_MAX; iflags <<= 1) { FOR_EACH_DELAYED_ACTION (iflags, action_type) {
if (NM_FLAGS_HAS (action_type, iflags)) {
NMPObjectType obj_type = delayed_action_refresh_to_object_type (iflags); NMPObjectType obj_type = delayed_action_refresh_to_object_type (iflags);
const NMPClass *klass = nmp_class_from_type (obj_type); const NMPClass *klass = nmp_class_from_type (obj_type);
nm_auto_nlmsg struct nl_msg *nlmsg = NULL; nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
@@ -3453,17 +3453,14 @@ do_request_all_no_delayed_actions (NMPlatform *platform, DelayedActionType actio
*/ */
nlmsg = nlmsg_alloc_simple (klass->rtm_gettype, NLM_F_DUMP); nlmsg = nlmsg_alloc_simple (klass->rtm_gettype, NLM_F_DUMP);
if (!nlmsg) if (!nlmsg)
goto next; continue;
nle = nlmsg_append (nlmsg, &gmsg, sizeof (gmsg), NLMSG_ALIGNTO); nle = nlmsg_append (nlmsg, &gmsg, sizeof (gmsg), NLMSG_ALIGNTO);
if (nle < 0) if (nle < 0)
goto next; continue;
_nl_send_auto_with_seq (platform, nlmsg, NULL); _nl_send_auto_with_seq (platform, nlmsg, NULL);
} }
next:
;
}
} }
static void static void