]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WPA: Clean up cipher suite counting in write routines
authorJouni Malinen <j@w1.fi>
Sun, 2 Mar 2014 14:03:22 +0000 (16:03 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 2 Mar 2014 15:15:12 +0000 (17:15 +0200)
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>
src/common/wpa_common.c

index 02ee508ae1d50ebf04b881f759e5453560805d16..27f58aa3172a0aed10016fdd700d4a97f8b44f0f 100644 (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) {
                RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_CCMP_256);
                pos += RSN_SELECTOR_LEN;
-               num_suites++;
        }
        if (ciphers & WPA_CIPHER_GCMP_256) {
                RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_GCMP_256);
                pos += RSN_SELECTOR_LEN;
-               num_suites++;
        }
        if (ciphers & WPA_CIPHER_CCMP) {
                RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_CCMP);
                pos += RSN_SELECTOR_LEN;
-               num_suites++;
        }
        if (ciphers & WPA_CIPHER_GCMP) {
                RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_GCMP);
                pos += RSN_SELECTOR_LEN;
-               num_suites++;
        }
        if (ciphers & WPA_CIPHER_TKIP) {
                RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_TKIP);
                pos += RSN_SELECTOR_LEN;
-               num_suites++;
        }
        if (ciphers & WPA_CIPHER_NONE) {
                RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_NONE);
                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) {
                RSN_SELECTOR_PUT(pos, WPA_CIPHER_SUITE_CCMP);
                pos += WPA_SELECTOR_LEN;
-               num_suites++;
        }
        if (ciphers & WPA_CIPHER_TKIP) {
                RSN_SELECTOR_PUT(pos, WPA_CIPHER_SUITE_TKIP);
                pos += WPA_SELECTOR_LEN;
-               num_suites++;
        }
        if (ciphers & WPA_CIPHER_NONE) {
                RSN_SELECTOR_PUT(pos, WPA_CIPHER_SUITE_NONE);
                pos += WPA_SELECTOR_LEN;
-               num_suites++;
        }
 
-       return num_suites;
+       return (pos - start) / RSN_SELECTOR_LEN;
 }