sys: util: use BITS_PER_BYTE macro instead of the magic number 8

Obviously, everyone knows that there are 8 bits per byte, so
there isn't a lot of magic happening, per se, but it's also
helpful to clearly denote where the magic number 8 is referring
to the number of bits in a byte.

Occasionally, 8 will refer to a field size or offset in a
structure, MMR, or word. Occasionally, the number 8 will refer
to the number of bytes in a 64-bit value (which should probably
be replaced with `sizeof(uint64_t)`).

For converting bits to bytes, or vice-versa, let's use
`BITS_PER_BYTE` for clarity (or other appropriate `BITS_PER_*`
macros).

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
This commit is contained in:
Chris Friedt 2024-11-03 10:08:19 -05:00 committed by Anas Nashif
commit 9504034733
14 changed files with 25 additions and 22 deletions

View file

@ -2,6 +2,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/ztest.h>
#include <zephyr/sys/util.h>
#include <psa/crypto.h>
#include <psa/internal_trusted_storage.h>
#include <psa/protected_storage.h>
@ -87,7 +88,7 @@ ZTEST(secure_storage_psa_crypto, test_persistent_key_usage)
psa_status_t ret;
psa_key_attributes_t key_attributes;
psa_key_id_t key_id;
uint8_t key_material[KEY_BITS / 8];
uint8_t key_material[KEY_BITS / BITS_PER_BYTE];
fill_key_attributes(&key_attributes);
fill_data(key_material, sizeof(key_material));