summaryrefslogtreecommitdiff
path: root/gsupplicant
diff options
context:
space:
mode:
authorGrant Erickson <marathon96@gmail.com>2012-05-15 23:03:17 (GMT)
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-05-16 09:12:37 (GMT)
commit206729685687b1c4309ece1e402b628ba768f675 (patch)
treec6665c562d7c3bed869b9b923c19be5dbb76ae71 /gsupplicant
parentbc3a689afbd58bd6072fb77769ca4b021214662f (diff)
downloadconnman-206729685687b1c4309ece1e402b628ba768f675.zip
connman-206729685687b1c4309ece1e402b628ba768f675.tar.gz
connman-206729685687b1c4309ece1e402b628ba768f675.tar.bz2
gsupplicant: Coding style clean-up
This resolves several post-commit review coding style comments for raw PSK support.
Diffstat (limited to 'gsupplicant')
-rw-r--r--gsupplicant/supplicant.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 829ceb7..0ae5540 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -2964,23 +2964,22 @@ static dbus_bool_t is_psk_raw_key(const char *psk)
static unsigned char hexchar2bin(char c)
{
if ((c >= '0') && (c <= '9'))
- return (c - '0');
+ return c - '0';
else if ((c >= 'A') && (c <= 'F'))
- return (c - 'A' + 10);
+ return c - 'A' + 10;
else if ((c >= 'a') && (c <= 'f'))
- return (c - 'a' + 10);
+ return c - 'a' + 10;
else
- return (c);
+ return c;
}
static void hexstring2bin(const char *string, unsigned char *data, size_t data_len)
{
size_t i;
- if ((data != NULL) && (string != NULL))
- for (i = 0; i < data_len; i++)
- data[i] = (hexchar2bin(string[i * 2 + 0]) << 4 |
- hexchar2bin(string[i * 2 + 1]) << 0);
+ for (i = 0; i < data_len; i++)
+ data[i] = (hexchar2bin(string[i * 2 + 0]) << 4 |
+ hexchar2bin(string[i * 2 + 1]) << 0);
}
static void add_network_security_psk(DBusMessageIter *dict,
@@ -2990,15 +2989,18 @@ static void add_network_security_psk(DBusMessageIter *dict,
const char *key = "psk";
if (is_psk_raw_key(ssid->passphrase) == TRUE) {
- const size_t size = 32;
- unsigned char data[size];
+ unsigned char data[32];
unsigned char *datap = data;
- hexstring2bin(ssid->passphrase, datap, size);
+ /* The above pointer alias is required by D-Bus because
+ * with D-Bus and GCC, non-heap-allocated arrays cannot
+ * be passed directly by their base pointer. */
+
+ hexstring2bin(ssid->passphrase, datap, sizeof(data));
supplicant_dbus_dict_append_fixed_array(dict,
key, DBUS_TYPE_BYTE,
- &datap, size);
+ &datap, sizeof(data));
} else
supplicant_dbus_dict_append_basic(dict,
key, DBUS_TYPE_STRING,