Correct more uses of C11 features in common code.

This commit is contained in:
Gregory Nutt
2019-08-24 17:59:26 -06:00
parent b41093b020
commit cb340cbfdb
3 changed files with 28 additions and 13 deletions
+10 -5
View File
@@ -391,7 +391,9 @@ static const struct file_operations g_mx7_debug_fops =
static int node_from_name(FAR const char *name)
{
for (int n = 0; n < NODE_MAP_LEN; n++)
int n;
for (n = 0; n < NODE_MAP_LEN; n++)
{
if (!strcmp(name, node_map[n].path))
{
@@ -406,7 +408,9 @@ static int node_from_name(FAR const char *name)
static int regaddr_from_name(FAR const char *name)
{
for (int n = 0; n < REG_NAME_MAP_LEN; n++)
int n;
for (n = 0; n < REG_NAME_MAP_LEN; n++)
{
if (!strcmp(name, reg_name_map[n].path))
{
@@ -1778,6 +1782,7 @@ int max7456_register(FAR const char *path, FAR struct mx7_config_s *config)
FAR struct mx7_dev_s *dev = NULL;
int ret = 0;
int osdbl = 0;
int n;
/* Without config info, we can't do anything. */
@@ -1845,7 +1850,7 @@ int max7456_register(FAR const char *path, FAR struct mx7_config_s *config)
* /dev/osd0/cm
*/
for (int n = 0; ret >= 0 && n < NODE_MAP_LEN; n++)
for (n = 0; ret >= 0 && n < NODE_MAP_LEN; n++)
{
ret = add_interface(path, node_map[n].path, &g_mx7_fops, 0666, dev);
}
@@ -1857,7 +1862,7 @@ int max7456_register(FAR const char *path, FAR struct mx7_config_s *config)
* activities.
*/
for (int n = 0; ret >= 0 && n < REG_NAME_MAP_LEN; n++)
for (n = 0; ret >= 0 && n < REG_NAME_MAP_LEN; n++)
{
ret = add_interface(path, reg_name_map[n].path, &g_mx7_debug_fops,
0666, dev);
@@ -1879,7 +1884,7 @@ int max7456_register(FAR const char *path, FAR struct mx7_config_s *config)
*/
uint8_t buf[300];
for (int n = 0; n < sizeof(buf); n++)
for (n = 0; n < sizeof(buf); n++)
{
buf[n] = n;
}
+12 -6
View File
@@ -1269,8 +1269,9 @@ static void swap_in_place(FAR uint8_t * buf, uint16_t len)
static void array_shift(FAR const uint8_t *in, FAR uint8_t *out)
{
uint8_t overflow = 0;
int i;
for (int i = 15; i >= 0; i--)
for (i = 15; i >= 0; i--)
{
out[i] = in[i] << 1;
/* previous byte */
@@ -1362,10 +1363,12 @@ static int bt_smp_aes_cmac(FAR const uint8_t *key, FAR const uint8_t *in,
uint8_t flag;
uint8_t n;
int err;
int i;
swap_buf(key, key_s, 16);
/* (K1,K2) = Generate_Subkey(K) */
err = cmac_subkey(key_s, k1, k2);
if (err)
{
@@ -1374,13 +1377,13 @@ static int bt_smp_aes_cmac(FAR const uint8_t *key, FAR const uint8_t *in,
wlinfo("key %s subkeys k1 %s k2 %s\n", h(key, 16), h(k1, 16), h(k2, 16));
/* the number of blocks, n, is calculated, the block length is 16 bytes n =
/* The number of blocks, n, is calculated, the block length is 16 bytes n =
* ceil(len/const_Bsize)
*/
n = (len + 15) / 16;
/* check input length, flag indicate completed blocks */
/* Check input length, flag indicate completed blocks */
if (n == 0)
{
@@ -1407,7 +1410,8 @@ static int bt_smp_aes_cmac(FAR const uint8_t *key, FAR const uint8_t *in,
wlinfo("len %u n %u flag %u\n", len, n, flag);
/* if flag is true then M_last = M_n XOR K1 */
/* If flag is true then M_last = M_n XOR K1 */
if (flag)
{
xor_128((FAR struct uint128_s *)&in[16 * (n - 1)],
@@ -1425,15 +1429,17 @@ static int bt_smp_aes_cmac(FAR const uint8_t *key, FAR const uint8_t *in,
}
/* Reuse k1 and k2 buffers */
x = k1;
y = k2;
/* Zeroing x */
memset(x, 0, 16);
/* Rhe basic CBC-MAC is applied to M_1,...,M_{n-1},M_last */
/* The basic CBC-MAC is applied to M_1,...,M_{n-1},M_last */
for (int i = 0; i < n - 1; i++)
for (i = 0; i < n - 1; i++)
{
/* Y = X XOR M_i */
+6 -2
View File
@@ -136,12 +136,14 @@ int mac802154_req_data(MACHANDLE mac,
}
else if (meta->destaddr.mode == IEEE802154_ADDRMODE_EXTENDED)
{
int index;
/* The IEEE 802.15.4 Standard is confusing with regards to byte-order
* for * extended address. More research discovers that the extended
* address should be sent in reverse-canonical form.
*/
for (int index = IEEE802154_EADDRSIZE - 1; index >= 0; index--)
for (index = IEEE802154_EADDRSIZE - 1; index >= 0; index--)
{
frame->io_data[mhr_len++] = meta->destaddr.eaddr[index];
}
@@ -202,12 +204,14 @@ int mac802154_req_data(MACHANDLE mac,
}
else if (meta->srcmode == IEEE802154_ADDRMODE_EXTENDED)
{
int index;
/* The IEEE 802.15.4 Standard is confusing with regards to byte-order
* for * extended address. More research discovers that the extended
* address should be sent in reverse-canonical form.
*/
for (int index = IEEE802154_EADDRSIZE - 1; index >= 0; index--)
for (index = IEEE802154_EADDRSIZE - 1; index >= 0; index--)
{
frame->io_data[mhr_len++] = priv->addr.eaddr[index];
}