WPA: Clean up cipher suite counting in write routines

There is no need to maintain a separate counter for this in addition to
the pointer to the current location. In addition, this gets rid of
warnings about unused variable write.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2014-03-02 16:03:22 +02:00
parent 6ed626df40
commit 8a4ce28000

View file

@ -1197,66 +1197,57 @@ u32 wpa_cipher_to_suite(int proto, int cipher)
} }
int rsn_cipher_put_suites(u8 *pos, int ciphers) int rsn_cipher_put_suites(u8 *start, int ciphers)
{ {
int num_suites = 0; u8 *pos = start;
if (ciphers & WPA_CIPHER_CCMP_256) { if (ciphers & WPA_CIPHER_CCMP_256) {
RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_CCMP_256); RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_CCMP_256);
pos += RSN_SELECTOR_LEN; pos += RSN_SELECTOR_LEN;
num_suites++;
} }
if (ciphers & WPA_CIPHER_GCMP_256) { if (ciphers & WPA_CIPHER_GCMP_256) {
RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_GCMP_256); RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_GCMP_256);
pos += RSN_SELECTOR_LEN; pos += RSN_SELECTOR_LEN;
num_suites++;
} }
if (ciphers & WPA_CIPHER_CCMP) { if (ciphers & WPA_CIPHER_CCMP) {
RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_CCMP); RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_CCMP);
pos += RSN_SELECTOR_LEN; pos += RSN_SELECTOR_LEN;
num_suites++;
} }
if (ciphers & WPA_CIPHER_GCMP) { if (ciphers & WPA_CIPHER_GCMP) {
RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_GCMP); RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_GCMP);
pos += RSN_SELECTOR_LEN; pos += RSN_SELECTOR_LEN;
num_suites++;
} }
if (ciphers & WPA_CIPHER_TKIP) { if (ciphers & WPA_CIPHER_TKIP) {
RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_TKIP); RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_TKIP);
pos += RSN_SELECTOR_LEN; pos += RSN_SELECTOR_LEN;
num_suites++;
} }
if (ciphers & WPA_CIPHER_NONE) { if (ciphers & WPA_CIPHER_NONE) {
RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_NONE); RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_NONE);
pos += RSN_SELECTOR_LEN; pos += RSN_SELECTOR_LEN;
num_suites++;
} }
return num_suites; return (pos - start) / RSN_SELECTOR_LEN;
} }
int wpa_cipher_put_suites(u8 *pos, int ciphers) int wpa_cipher_put_suites(u8 *start, int ciphers)
{ {
int num_suites = 0; u8 *pos = start;
if (ciphers & WPA_CIPHER_CCMP) { if (ciphers & WPA_CIPHER_CCMP) {
RSN_SELECTOR_PUT(pos, WPA_CIPHER_SUITE_CCMP); RSN_SELECTOR_PUT(pos, WPA_CIPHER_SUITE_CCMP);
pos += WPA_SELECTOR_LEN; pos += WPA_SELECTOR_LEN;
num_suites++;
} }
if (ciphers & WPA_CIPHER_TKIP) { if (ciphers & WPA_CIPHER_TKIP) {
RSN_SELECTOR_PUT(pos, WPA_CIPHER_SUITE_TKIP); RSN_SELECTOR_PUT(pos, WPA_CIPHER_SUITE_TKIP);
pos += WPA_SELECTOR_LEN; pos += WPA_SELECTOR_LEN;
num_suites++;
} }
if (ciphers & WPA_CIPHER_NONE) { if (ciphers & WPA_CIPHER_NONE) {
RSN_SELECTOR_PUT(pos, WPA_CIPHER_SUITE_NONE); RSN_SELECTOR_PUT(pos, WPA_CIPHER_SUITE_NONE);
pos += WPA_SELECTOR_LEN; pos += WPA_SELECTOR_LEN;
num_suites++;
} }
return num_suites; return (pos - start) / RSN_SELECTOR_LEN;
} }