*/
#include "gunicode.h"
+#include "macro.h"
#define unichar uint32_t
{0x20000, 0x2FFFD}, {0x30000, 0x3FFFD},
};
- if (bsearch ((void *)(uintptr_t)c, wide, (sizeof (wide) / sizeof ((wide)[0])), sizeof wide[0],
+ if (bsearch ((void *)(uintptr_t)c, wide, ELEMENTSOF(wide), sizeof wide[0],
interval_compare))
return true;
};
uint8_t res[SHA256_DIGEST_SIZE];
- for (size_t i = 0; i < sizeof(test_vectors)/sizeof(test_vectors[0]); i++) {
-
+ FOREACH_ELEMENT(vector, test_vectors) {
int rc = tpm2_util_pbkdf2_hmac_sha256(
- test_vectors[i].pass,
- test_vectors[i].passlen,
- test_vectors[i].salt,
- test_vectors[i].saltlen,
+ vector->pass,
+ vector->passlen,
+ vector->salt,
+ vector->saltlen,
res);
assert_se(rc == 0);
- assert_se(memcmp(test_vectors[i].expected, res, SHA256_DIGEST_SIZE) == 0);
+ assert_se(memcmp(vector->expected, res, SHA256_DIGEST_SIZE) == 0);
}
}
char *unit_serial_number, char *wwn,
char *wwn_vendor_extension, char *tgpt_group) {
int retval;
- unsigned id_ind, j;
unsigned char page_83[SCSI_INQ_BUFF_LEN];
/* also pick up the page 80 serial number */
* Search for a match in the prioritized id_search_list - since WWN ids
* come first we can pick up the WWN in check_fill_0x83_id().
*/
- for (id_ind = 0;
- id_ind < sizeof(id_search_list)/sizeof(id_search_list[0]);
- id_ind++) {
+ FOREACH_ELEMENT(search_value, id_search_list) {
/*
* Examine each descriptor returned. There is normally only
* one or a small number of descriptors.
*/
- for (j = 4; j <= ((unsigned)page_83[2] << 8) + (unsigned)page_83[3] + 3; j += page_83[j + 3] + 4) {
+ for (unsigned j = 4; j <= ((unsigned)page_83[2] << 8) + (unsigned)page_83[3] + 3; j += page_83[j + 3] + 4) {
retval = check_fill_0x83_id(dev_scsi, page_83 + j,
- id_search_list + id_ind,
+ search_value,
serial, serial_short, len,
wwn, wwn_vendor_extension,
tgpt_group);
i * BITS_PER_LONG, yes_no(found));
}
/* If there are no keys in the lower block, check the higher blocks */
- for (size_t block = 0; block < sizeof(high_key_blocks) / sizeof(struct range) && !found; block++)
+ for (size_t block = 0; block < ELEMENTSOF(high_key_blocks) && !found; block++)
for (unsigned i = high_key_blocks[block].start; i < high_key_blocks[block].end && !found; i++)
if (test_bit(i, bitmask_key)) {
log_device_debug(dev, "test_key: Found key %x in high block", i);