From fe95cbe077e22ed43bdf5c338fd73894c5eb1d3a Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Tue, 11 Jan 2022 10:51:11 -0600 Subject: [PATCH] treewide: Various style fixups - Mostly problems with whitespace: - Use of spaces instead of tabs - Stray spaces before closing ') - Missing spaces - Missing 'void' from function declarations & definitions that take no arguments. - Wrong indentation level --- src/adhoc.c | 2 +- src/backtrace.c | 3 ++- src/backtrace.h | 2 +- src/band.c | 10 +++++----- src/crypto.c | 15 ++++++++------- src/dpp-util.c | 2 +- src/eap-peap.c | 8 ++++---- src/eap-tls-common.c | 4 ++-- src/eap-wsc.c | 2 +- src/fils.c | 2 +- src/frame-xchg.c | 8 ++++---- src/ft.c | 7 ++++--- src/handshake.c | 2 +- src/ie.c | 2 +- src/json.c | 4 ++-- src/json.h | 14 +++++++------- src/main.c | 2 +- src/manager.c | 6 +++--- src/mpdu.c | 1 + src/netdev.c | 3 +-- src/p2putil.h | 4 ++-- src/sae.c | 6 +++--- src/scan.c | 3 ++- src/simauth.h | 4 ++-- src/station.c | 12 ++++++------ src/util.c | 4 ++-- src/wiphy.c | 1 + src/wsc.c | 2 +- src/wscutil.c | 1 + 29 files changed, 71 insertions(+), 65 deletions(-) diff --git a/src/adhoc.c b/src/adhoc.c index 7db405c5..2b15f2bd 100644 --- a/src/adhoc.c +++ b/src/adhoc.c @@ -668,7 +668,7 @@ static void sta_append(void *data, void *user_data) { struct sta_state *sta = data; struct l_dbus_message_builder *builder = user_data; - const char* macstr; + const char *macstr; if (!sta->authenticated) return; diff --git a/src/backtrace.c b/src/backtrace.c index 42eebf97..60709721 100644 --- a/src/backtrace.c +++ b/src/backtrace.c @@ -162,7 +162,7 @@ static void signal_handler(int signo) exit(EXIT_FAILURE); } -void __iwd_backtrace_init() +void __iwd_backtrace_init(void) { static char path[PATH_MAX]; static char cwd[PATH_MAX]; @@ -174,6 +174,7 @@ void __iwd_backtrace_init() len = readlink("/proc/self/exe", path, sizeof(path) - 1); if (len > 0) { int i; + path[len] = '\0'; for (i = len - 1; i >= 0; i--) { diff --git a/src/backtrace.h b/src/backtrace.h index 32d6ce8b..c0f00899 100644 --- a/src/backtrace.h +++ b/src/backtrace.h @@ -20,6 +20,6 @@ * */ #ifdef HAVE_BACKTRACE -void __iwd_backtrace_init(); +void __iwd_backtrace_init(void); void __iwd_backtrace_print(unsigned int offset); #endif diff --git a/src/band.c b/src/band.c index 4d9624f1..9024d186 100644 --- a/src/band.c +++ b/src/band.c @@ -151,11 +151,11 @@ static const int32_t ht_vht_base_rssi[] = { * nsds = [52, 108, 234, 468] * * for nsd in nsds: - * rates = [] - * for i in xrange(0, 10): - * data_rate = (nsd * rfactors[i] * nbpscs[i]) / 0.004 - * rates.append(int(data_rate) * 1000) - * print('rates for nsd: ' + nsd + ': ' + rates) + * rates = [] + * for i in xrange(0, 10): + * data_rate = (nsd * rfactors[i] * nbpscs[i]) / 0.004 + * rates.append(int(data_rate) * 1000) + * print('rates for nsd: ' + nsd + ': ' + rates) */ static const uint64_t ht_vht_rates[4][10] = { diff --git a/src/crypto.c b/src/crypto.c index cd50d6f7..19d55e70 100644 --- a/src/crypto.c +++ b/src/crypto.c @@ -72,8 +72,9 @@ const unsigned char crypto_dh5_generator[] = { 0x2 }; size_t crypto_dh5_generator_size = sizeof(crypto_dh5_generator); static bool hmac_common(enum l_checksum_type type, - const void *key, size_t key_len, - const void *data, size_t data_len, void *output, size_t size) + const void *key, size_t key_len, + const void *data, size_t data_len, + void *output, size_t size) { struct l_checksum *hmac; @@ -438,9 +439,9 @@ free_ctr: return false; } -#define SWAP(a,b) do { int _t = a; a = b; b = _t; } while (0) +#define SWAP(a, b) do { int _t = a; a = b; b = _t; } while (0) -static void arc4_set_key(struct arc4_ctx *ctx, unsigned length, +static void arc4_set_key(struct arc4_ctx *ctx, unsigned int length, const uint8_t *key) { unsigned int i, j, k; @@ -458,8 +459,8 @@ static void arc4_set_key(struct arc4_ctx *ctx, unsigned length, ctx->i = ctx->j = 0; } -static void arc4_crypt(struct arc4_ctx *ctx, unsigned length, uint8_t *dst, - const uint8_t *src) +static void arc4_crypt(struct arc4_ctx *ctx, unsigned int length, + uint8_t *dst, const uint8_t *src) { uint8_t i, j; @@ -470,7 +471,7 @@ static void arc4_crypt(struct arc4_ctx *ctx, unsigned length, uint8_t *dst, SWAP(ctx->S[i], ctx->S[j]); if (!dst || !src) continue; - *dst++ = *src++ ^ ctx->S[ (ctx->S[i] + ctx->S[j]) & 0xff ]; + *dst++ = *src++ ^ ctx->S[(ctx->S[i] + ctx->S[j]) & 0xff]; } ctx->i = i; ctx->j = j; } diff --git a/src/dpp-util.c b/src/dpp-util.c index 55d6f3f1..aaca2c48 100644 --- a/src/dpp-util.c +++ b/src/dpp-util.c @@ -155,7 +155,7 @@ struct dpp_configuration *dpp_parse_configuration_object(const char *json, JSON_UNDEFINED)) goto free_contents; - if (!ssid || !util_ssid_is_utf8(strlen(ssid),(const uint8_t *)ssid)) + if (!ssid || !util_ssid_is_utf8(strlen(ssid), (const uint8_t *) ssid)) goto free_contents; if (!json_iter_parse(&cred, diff --git a/src/eap-peap.c b/src/eap-peap.c index c17e5b92..38ecd6a9 100644 --- a/src/eap-peap.c +++ b/src/eap-peap.c @@ -473,10 +473,10 @@ static bool eap_peap_tunnel_ready(struct eap_state *eap, struct peap_state *peap_state = eap_tls_common_get_variant_data(eap); /* - * PEAPv1: draft-josefsson-pppext-eap-tls-eap-05, Section 2.1.1 - * - * Cleartext Success/Failure packets MUST be silently discarded once TLS - * tunnel has been brought up. + * PEAPv1: draft-josefsson-pppext-eap-tls-eap-05, Section 2.1.1 + * + * Cleartext Success/Failure packets MUST be silently discarded once + * TLS tunnel has been brought up. */ eap_discard_success_and_failure(eap, true); diff --git a/src/eap-tls-common.c b/src/eap-tls-common.c index 5edbfc5d..75d3aa33 100644 --- a/src/eap-tls-common.c +++ b/src/eap-tls-common.c @@ -725,8 +725,8 @@ void eap_tls_common_handle_request(struct eap_state *eap, proceed: if (eap_tls->tx_pdu_buf) { /* - * tx_pdu_buf is used for the re-transmission and needs to be - * cleared on a new request. + * tx_pdu_buf is used for the re-transmission and needs to be + * cleared on a new request. */ databuf_free(eap_tls->tx_pdu_buf); eap_tls->tx_pdu_buf = NULL; diff --git a/src/eap-wsc.c b/src/eap-wsc.c index bbf32ed3..65a97da4 100644 --- a/src/eap-wsc.c +++ b/src/eap-wsc.c @@ -223,7 +223,7 @@ static uint8_t *encrypted_settings_decrypt(struct eap_wsc_state *wsc, * * Account for the IV being in the beginning 16 bytes */ - if (len < 16 ) + if (len < 16) return NULL; encrypted_len = len - 16; diff --git a/src/fils.c b/src/fils.c index c05281bb..d1d46d65 100644 --- a/src/fils.c +++ b/src/fils.c @@ -222,7 +222,7 @@ static int fils_derive_key_data(struct fils_sm *fils) /* * IEEE 802.11ai - 12.12.2.6.2 (Re)Association Request for FILS key - * confirmation + * confirmation * * Key-Auth = HMAC-Hash(ICK, SNonce || ANonce || STA-MAC || AP-BSSID) */ diff --git a/src/frame-xchg.c b/src/frame-xchg.c index 4ecfc45d..6eec29ea 100644 --- a/src/frame-xchg.c +++ b/src/frame-xchg.c @@ -726,10 +726,10 @@ static bool frame_watch_remove_by_handler(uint64_t wdev_id, uint32_t group_id, frame_watch_cb_t handler, void *user_data) { - struct watch_group_match_info group_info = - { group_id == 0 ? 0 : wdev_id, group_id }; - struct frame_watch_handler_check_info handler_info = - { wdev_id, handler, user_data }; + struct watch_group_match_info group_info = { + group_id == 0 ? 0 : wdev_id, group_id }; + struct frame_watch_handler_check_info handler_info = { + wdev_id, handler, user_data }; struct watch_group *group = l_queue_find(watch_groups, frame_watch_group_match, &group_info); diff --git a/src/ft.c b/src/ft.c index 7a4b16f3..2b41ae18 100644 --- a/src/ft.c +++ b/src/ft.c @@ -640,9 +640,10 @@ static int ft_rx_authenticate(struct auth_proto *ap, const uint8_t *frame, * FT Protocol. */ if (!ft_parse_authentication_resp_frame(frame, frame_len, ft->hs->spa, - ft->hs->aa, ft->hs->aa, 2, &status_code, - &ies, &ies_len)) - goto auth_error; + ft->hs->aa, ft->hs->aa, + 2, &status_code, + &ies, &ies_len)) + goto auth_error; /* AP Rejected the authenticate / associate */ if (status_code != 0) diff --git a/src/handshake.c b/src/handshake.c index 8169ec69..60ec0969 100644 --- a/src/handshake.c +++ b/src/handshake.c @@ -44,7 +44,7 @@ #include "src/erp.h" #include "src/band.h" -static inline unsigned int n_ecc_groups() +static inline unsigned int n_ecc_groups(void) { const unsigned int *groups = l_ecc_supported_ike_groups(); unsigned int j = 0; diff --git a/src/ie.c b/src/ie.c index 8108c02a..7ef07c37 100644 --- a/src/ie.c +++ b/src/ie.c @@ -923,7 +923,7 @@ static bool ie_build_cipher_suite(uint8_t *data, const uint8_t *oui, memcpy((data), (oui), 3); \ (data)[3] = (id); \ return true; \ - } while(0) + } while (0) /* 802.11-2016, Section 9.4.2.25.3 */ static bool ie_build_rsn_akm_suite(uint8_t *data, enum ie_rsn_akm_suite suite) diff --git a/src/json.c b/src/json.c index 69c1dcdb..da445096 100644 --- a/src/json.c +++ b/src/json.c @@ -302,7 +302,7 @@ bool json_iter_get_int(struct json_iter *iter, int *i) { void *ptr; size_t len; - long int r; + long r; int t; char *endp; @@ -328,7 +328,7 @@ bool json_iter_get_uint(struct json_iter *iter, unsigned int *i) { void *ptr; size_t len; - unsigned long int r; + unsigned long r; unsigned int t; char *endp; diff --git a/src/json.h b/src/json.h index 1db3428d..c6220667 100644 --- a/src/json.h +++ b/src/json.h @@ -69,17 +69,17 @@ void json_iter_init(struct json_iter *iter, struct json_contents *c); * Arguments should be specified using JSON_MANDATORY or JSON_OPTIONAL: * * r = json_iter_parse(iter, JSON_MANDATORY("mykey", JSON_STRING, &strvalue), - * JSON_OPTIONAL("optkey", JSON_STRING, &optvalue), - * JSON_UNDEFINED); + * JSON_OPTIONAL("optkey", JSON_STRING, &optvalue), + * JSON_UNDEFINED); * * String values should be of type char ** and must be freed * Object values should be of type struct json_iter * * Primitive types (numbers, booleans, null) should be of type - * struct json_iter *. This is to allow the caller to distinguish - * between the actual value type after parsing using a getter for - * the expected type (get_uint/get_int/get_boolean etc.). In - * addition this lets the caller use JSON_OPTIONAL and check post - * json_iter_parse if the iterator is valid (json_iter_is_valid). + * struct json_iter *. This is to allow the caller to distinguish + * between the actual value type after parsing using a getter for + * the expected type (get_uint/get_int/get_boolean etc.). In + * addition this lets the caller use JSON_OPTIONAL and check post + * json_iter_parse if the iterator is valid (json_iter_is_valid). * * No other types are supported at this time, and json_iter_parse will fail if * other types are encountered. diff --git a/src/main.c b/src/main.c index 989665e4..d0dbedc8 100644 --- a/src/main.c +++ b/src/main.c @@ -265,7 +265,7 @@ static void print_koption(const void *key, void *value, void *user_data) #define ADD_OPTIONAL(opt) \ l_hashmap_replace(optional, opt, &r, NULL) -static int check_crypto() +static int check_crypto(void) { int r = 0; struct l_hashmap *options = l_hashmap_string_new(); diff --git a/src/manager.c b/src/manager.c index 558b71b0..46e0e906 100644 --- a/src/manager.c +++ b/src/manager.c @@ -196,7 +196,7 @@ static void manager_create_interfaces(struct wiphy_setup_state *state) struct l_genl_msg *msg; char ifname[10]; uint32_t iftype; - unsigned cmd_id; + unsigned int cmd_id; if (state->aborted) return; @@ -341,7 +341,7 @@ static void manager_get_interface_cb(struct l_genl_msg *msg, void *user_data) uint64_t wdev; const char *ifname; struct l_genl_msg *del_msg; - unsigned cmd_id; + unsigned int cmd_id; char *pattern; unsigned int i; bool whitelisted = false, blacklisted = false; @@ -703,7 +703,7 @@ static void manager_config_notify(struct l_genl_msg *msg, void *user_data) case NL80211_CMD_NEW_INTERFACE: /* * Interfaces are normally dumped on the NEW_WIPHY events and - * and we have nothing to do here. But check if by any chance + * we have nothing to do here. But check if by any chance * we've queried this wiphy and it was still busy initialising, * in that case retry the setup now that an interface, likely * the initial default one, has been added. diff --git a/src/mpdu.c b/src/mpdu.c index 3ee5be5c..9d0409d2 100644 --- a/src/mpdu.c +++ b/src/mpdu.c @@ -364,6 +364,7 @@ static bool validate_mgmt_ies(const uint8_t *ies, size_t ies_len, while (ie_tlv_iter_next(&iter)) { int i = 0; + tag = ie_tlv_iter_get_tag(&iter); /* Check that the tag is part of the valid set */ diff --git a/src/netdev.c b/src/netdev.c index 78467d3e..ce06894a 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -2901,7 +2901,7 @@ process_resp_ies: if (netdev_get_oci(netdev) < 0) goto deauth; } else if (!eapol_start(netdev->sm)) - goto deauth; + goto deauth; return; } @@ -2912,7 +2912,6 @@ process_resp_ies: HANDSHAKE_EVENT_SETTING_KEYS); netdev_connect_ok(netdev); - return; error: diff --git a/src/p2putil.h b/src/p2putil.h index 23bf1dae..3a76414b 100644 --- a/src/p2putil.h +++ b/src/p2putil.h @@ -121,8 +121,8 @@ enum p2p_public_action_frame_type { /* Table 75 */ enum p2p_action_frame_type { P2P_ACTION_NOTICE_OF_ABSENCE = 0, - P2P_ACTION_PRESENCE_REQ = 1, - P2P_ACTION_PRESENCE_RESP = 2, + P2P_ACTION_PRESENCE_REQ = 1, + P2P_ACTION_PRESENCE_RESP = 2, P2P_ACTION_GO_DISCOVERABILITY_REQ = 3, }; diff --git a/src/sae.c b/src/sae.c index 7e6377f5..b0f80bb6 100644 --- a/src/sae.c +++ b/src/sae.c @@ -438,7 +438,7 @@ static struct l_ecc_point *sae_compute_pwe(const struct l_ecc_curve *curve, * Set base to either dummy or password, depending on found's * value. * A non-secure version would be: - * base = (found ? dummy : password); + * base = (found ? dummy : password); */ util_secure_select(found, dummy, (uint8_t *)password, base, base_len); @@ -729,7 +729,7 @@ static int sae_process_commit(struct sae_sm *sm, const uint8_t *from, * * NOTE: We use hkdf_extract here since it is just an hmac invocation * and it handles the case of the zero key for us. - */ + */ if (sm->sae_type != CRYPTO_SAE_LOOPING && sm->rejected_groups) { salt = sm->rejected_groups + 1; salt_len = sm->rejected_groups[0] * sizeof(uint16_t); @@ -999,7 +999,7 @@ static int sae_verify_committed(struct sae_sm *sm, uint16_t transaction, * checking that the group matches here, e.g. * * if (l_get_le16(frame) != sm->group) - * return false; + * return false; * * According to 802.11 Section 12.4.8.6.4: * diff --git a/src/scan.c b/src/scan.c index 54159dfd..f49d2f2a 100644 --- a/src/scan.c +++ b/src/scan.c @@ -562,6 +562,7 @@ static int scan_request_send_trigger(struct scan_context *sc, struct scan_request *sr) { struct l_genl_msg *cmd = l_queue_peek_head(sr->cmds); + if (!cmd) return -ENOMSG; @@ -2087,7 +2088,7 @@ static int scan_init(void) return 0; } -static void scan_exit() +static void scan_exit(void) { l_queue_destroy(scan_contexts, (l_queue_destroy_func_t) scan_context_free); diff --git a/src/simauth.h b/src/simauth.h index 8043e20b..9fb9af96 100644 --- a/src/simauth.h +++ b/src/simauth.h @@ -125,7 +125,7 @@ struct iwd_sim_auth *iwd_sim_auth_find(bool sim, bool aka); * @param data User data * * @return Transaction ID, used to cancel the request if needed - * < 0 in case of an error + * < 0 in case of an error */ int sim_auth_check_milenage(struct iwd_sim_auth *auth, const uint8_t *rand, const uint8_t *autn, @@ -141,7 +141,7 @@ int sim_auth_check_milenage(struct iwd_sim_auth *auth, * @param data User data * * @return Transaction ID, used to cancel the request if needed - * < 0 in case of an error + * < 0 in case of an error */ int sim_auth_run_gsm(struct iwd_sim_auth *auth, const uint8_t *rands, int num_rands, sim_auth_run_gsm_cb_t cb, void *data); diff --git a/src/station.c b/src/station.c index 173b944d..b04c1b15 100644 --- a/src/station.c +++ b/src/station.c @@ -1105,7 +1105,7 @@ build_ie: * any offload features are detected (since IWD prefers to use offload). */ info.ocvc = !disable_ocv && bss_info.ocvc && info.mfpc && - !wiphy_can_offload(wiphy);; + !wiphy_can_offload(wiphy); /* * IEEE 802.11-2020 9.4.2.24.4 states extended key IDs can only be used @@ -1887,9 +1887,9 @@ static void station_ft_ds_action_start(struct station *station) continue; /* - * Fire and forget. Netdev will maintain a cache of responses and - * when the time comes these can be referenced for a roam - */ + * Fire and forget. Netdev will maintain a cache of responses + * and when the time comes these can be referenced for a roam + */ netdev_fast_transition_over_ds_action(station->netdev, bss); } } @@ -2601,7 +2601,7 @@ static void station_ap_directed_roam(struct station *station, pos += 12; } - if (req_mode & WNM_REQUEST_MODE_ESS_DISASSOCIATION_IMMINENT ) { + if (req_mode & WNM_REQUEST_MODE_ESS_DISASSOCIATION_IMMINENT) { uint8_t url_len; if (pos + 1 > body_len) @@ -2625,7 +2625,7 @@ static void station_ap_directed_roam(struct station *station, if (req_mode & WNM_REQUEST_MODE_PREFERRED_CANDIDATE_LIST) { l_debug("roam: AP sent a preferred candidate list"); station_neighbor_report_cb(station->netdev, 0, body + pos, - body_len - pos,station); + body_len - pos, station); } else { l_debug("roam: AP did not include a preferred candidate list"); if (station_roam_scan(station, NULL) < 0) diff --git a/src/util.c b/src/util.c index ca0f46ae..20e179a6 100644 --- a/src/util.c +++ b/src/util.c @@ -39,7 +39,7 @@ const char *util_ssid_to_utf8(size_t len, const uint8_t *ssid) { - static char buf[3* 32 + 1]; + static char buf[3 * 32 + 1]; size_t i = 0, pos = 0; const uint8_t *start = ssid, *end; @@ -136,7 +136,7 @@ bool util_string_to_address(const char *str, uint8_t *out_addr) if (str[i + 2] != ':') return false; - } + } if (!l_ascii_isxdigit(str[i])) return false; diff --git a/src/wiphy.c b/src/wiphy.c index 56400ea8..bd2094a8 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -918,6 +918,7 @@ static void wiphy_print_band_info(struct band *band, const char *name) if (band->ht_supported) { uint8_t max_nss = bit_field(band->ht_mcs_set[12], 2, 2) + 1; + l_info("\t\tHT Capabilities:"); if (test_bit(band->ht_capabilities, 1)) diff --git a/src/wsc.c b/src/wsc.c index f7b9d8c9..224c721a 100644 --- a/src/wsc.c +++ b/src/wsc.c @@ -555,7 +555,7 @@ static void wsc_store_credentials(struct wsc_credentials_info *creds, else l_settings_set_bytes(settings, "Security", "PreSharedKey", creds[i].psk, - sizeof(creds[i].psk)); + sizeof(creds[i].psk)); } l_debug("Storing credential for '%s(%s)'", ssid, diff --git a/src/wscutil.c b/src/wscutil.c index dac10f73..ce8d4b2a 100644 --- a/src/wscutil.c +++ b/src/wscutil.c @@ -1751,6 +1751,7 @@ static uint8_t *wsc_attr_builder_free(struct wsc_attr_builder *builder, if (builder->curlen > 0) { uint8_t *bytes = builder->buf + builder->offset; + l_put_be16(builder->curlen - 4, bytes + 2); builder->offset += builder->curlen; builder->curlen = 0;