[PATCH v2 2/6] nl80211: Use macro to reference netlink object.

Jouni Malinen j at w1.fi
Thu Oct 20 19:14:16 EDT 2011


On Thu, Oct 20, 2011 at 01:21:20PM -0700, greearb at candelatech.com wrote:
> This will allow us to change it later without having
> to touch so much code.

> +#define DRVNL nl80211

> -	genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, NLM_F_DUMP,
> +	genlmsg_put(msg, 0, 0, genl_family_get_id(drv->DRVNL), 0, NLM_F_DUMP,
>  		    NL80211_CMD_GET_SCAN, 0);

While splitting the patch sounds like a good idea in general, this does
not look like the way to do that.. Those macros are just ugly (and
couple of them even ended up remaining there in the end of the patch
series?!). You'd have quite a bit better luck with cleaner wrapper here.
Something like this would actually would be of use on its own (save over
1 kB in binary size):


@@ -403,6 +403,14 @@ nla_put_failure:
+static void * nl80211_cmd(struct wpa_driver_nl80211_data *drv,
+			  struct nl_msg *msg, int flags, uint8_t cmd)
+{
+	return genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
+			   flags, cmd, 0);
+}
+
+
@@ -653,8 +661,7 @@ static unsigned int nl80211_get_assoc_freq(struct wpa_driver_nl80211_data *drv)
-	genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, NLM_F_DUMP,
-		    NL80211_CMD_GET_SCAN, 0);
+	nl80211_cmd(drv, msg, NLM_F_DUMP, NL80211_CMD_GET_SCAN);


See
http://w1.fi/p/nl80211-share-netlink/0001-nl80211-Use-a-wrapper-for-genlmsg_put.patch
for a complete patch.

-- 
Jouni Malinen                                            PGP id EFC895FA


More information about the HostAP mailing list