Date: Mon, 9 Apr 2007 04:10:55 GMT From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 117714 for review Message-ID: <200704090410.l394Atik065904@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=117714 Change 117714 by sam@sam_ebb on 2007/04/09 04:10:05 move idiom for copying an information element into a function Affected files ... .. //depot/projects/wifi/sys/net80211/ieee80211_ioctl.c#73 edit Differences ... ==== //depot/projects/wifi/sys/net80211/ieee80211_ioctl.c#73 (text+ko) ==== @@ -241,6 +241,16 @@ return error; } +static __inline u_int8_t * +copyie(u_int8_t *cp, const u_int8_t *ie) +{ + if (ie != NULL) { + memcpy(cp, ie, 2+ie[1]); + cp += 2+ie[1]; + } + return cp; +} + #ifdef COMPAT_FREEBSD6 #define IEEE80211_IOC_SCAN_RESULTS_OLD 24 @@ -331,14 +341,8 @@ memcpy(cp, se->se_ssid+2, sr->isr_ssid_len); cp += sr->isr_ssid_len; if (sr->isr_ie_len) { - if (se->se_wpa_ie != NULL) { - memcpy(cp, se->se_wpa_ie, 2+se->se_wpa_ie[1]); - cp += 2+se->se_wpa_ie[1]; - } - if (se->se_wme_ie != NULL) { - memcpy(cp, se->se_wme_ie, 2+se->se_wme_ie[1]); - cp += 2+se->se_wme_ie[1]; - } + cp = copyie(cp, se->se_wpa_ie); + cp = copyie(cp, se->se_wme_ie); } req->space -= len; @@ -453,22 +457,10 @@ memcpy(cp, se->se_ssid+2, sr->isr_ssid_len); cp += sr->isr_ssid_len; if (sr->isr_ie_len) { - if (se->se_wpa_ie != NULL) { - memcpy(cp, se->se_wpa_ie, 2+se->se_wpa_ie[1]); - cp += 2+se->se_wpa_ie[1]; - } - if (se->se_rsn_ie != NULL) { - memcpy(cp, se->se_rsn_ie, 2+se->se_rsn_ie[1]); - cp += 2+se->se_rsn_ie[1]; - } - if (se->se_wme_ie != NULL) { - memcpy(cp, se->se_wme_ie, 2+se->se_wme_ie[1]); - cp += 2+se->se_wme_ie[1]; - } - if (se->se_ath_ie != NULL) { - memcpy(cp, se->se_ath_ie, 2+se->se_ath_ie[1]); - cp += 2+se->se_ath_ie[1]; - } + cp = copyie(cp, se->se_wpa_ie); + cp = copyie(cp, se->se_rsn_ie); + cp = copyie(cp, se->se_wme_ie); + cp = copyie(cp, se->se_ath_ie); } req->space -= len; @@ -599,22 +591,10 @@ si->isi_inact = (si->isi_inact - ni->ni_inact) * IEEE80211_INACT_WAIT; cp = (u_int8_t *)(si+1); - if (ni->ni_wpa_ie != NULL) { - memcpy(cp, ni->ni_wpa_ie, 2+ni->ni_wpa_ie[1]); - cp += 2+ni->ni_wpa_ie[1]; - } - if (ni->ni_rsn_ie != NULL) { - memcpy(cp, ni->ni_rsn_ie, 2+ni->ni_rsn_ie[1]); - cp += 2+ni->ni_rsn_ie[1]; - } - if (ni->ni_wme_ie != NULL) { - memcpy(cp, ni->ni_wme_ie, 2+ni->ni_wme_ie[1]); - cp += 2+ni->ni_wme_ie[1]; - } - if (ni->ni_ath_ie != NULL) { - memcpy(cp, ni->ni_ath_ie, 2+ni->ni_ath_ie[1]); - cp += 2+ni->ni_ath_ie[1]; - } + cp = copyie(cp, ni->ni_wpa_ie); + cp = copyie(cp, ni->ni_rsn_ie); + cp = copyie(cp, ni->ni_wme_ie); + cp = copyie(cp, ni->ni_ath_ie); req->si = (struct ieee80211req_sta_info *)(((u_int8_t *)si) + len); req->space -= len;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200704090410.l394Atik065904>