while (!exit) {
EFI_STATUS err;
UINT64 key;
- UINTN i;
+ UINTN j;
- i = len - first;
- if (i >= x_max-1)
- i = x_max-1;
- CopyMem(print, line + first, i * sizeof(CHAR16));
- while (clear > 0 && i < x_max-1) {
+ j = len - first;
+ if (j >= x_max-1)
+ j = x_max-1;
+ CopyMem(print, line + first, j * sizeof(CHAR16));
+ while (clear > 0 && j < x_max-1) {
clear--;
- print[i++] = ' ';
+ print[j++] = ' ';
}
- print[i] = '\0';
+ print[j] = '\0';
uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 0, y_pos);
uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, print);
case KEYPRESS(EFI_ALT_PRESSED, 0, 'd'):
/* kill-word */
clear = 0;
- for (i = first + cursor; i < len && line[i] == ' '; i++)
+
+ UINTN k;
+ for (k = first + cursor; k < len && line[k] == ' '; k++)
clear++;
- for (; i < len && line[i] != ' '; i++)
+ for (; k < len && line[k] != ' '; k++)
clear++;
- for (i = first + cursor; i + clear < len; i++)
+ for (UINTN i = first + cursor; i + clear < len; i++)
line[i] = line[i + clear];
len -= clear;
line[len] = '\0';
}
uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, cursor, y_pos);
- for (i = first + cursor; i + clear < len; i++)
+ for (UINTN i = first + cursor; i + clear < len; i++)
line[i] = line[i + clear];
len -= clear;
line[len] = '\0';
continue;
if (first + cursor == len)
continue;
- for (i = first + cursor; i < len; i++)
+ for (UINTN i = first + cursor; i < len; i++)
line[i] = line[i+1];
clear = 1;
len--;
continue;
if (first == 0 && cursor == 0)
continue;
- for (i = first + cursor-1; i < len; i++)
+ for (UINTN i = first + cursor-1; i < len; i++)
line[i] = line[i+1];
clear = 1;
len--;
case KEYPRESS(0, 0, 0x80) ... KEYPRESS(0, 0, 0xffff):
if (len+1 == size)
continue;
- for (i = len; i > first + cursor; i--)
+ for (UINTN i = len; i > first + cursor; i--)
line[i] = line[i-1];
line[first + cursor] = KEYCHAR(key);
len++;
}
static UINTN entry_lookup_key(Config *config, UINTN start, CHAR16 key) {
- UINTN i;
-
if (key == 0)
return -1;
/* select entry by number key */
if (key >= '1' && key <= '9') {
- i = key - '0';
+ UINTN i = key - '0';
if (i > config->entry_count)
i = config->entry_count;
return i-1;
}
/* find matching key in config entries */
- for (i = start; i < config->entry_count; i++)
+ for (UINTN i = start; i < config->entry_count; i++)
if (config->entries[i]->key == key)
return i;
- for (i = 0; i < start; i++)
+ for (UINTN i = 0; i < start; i++)
if (config->entries[i]->key == key)
return i;
static VOID print_status(Config *config, CHAR16 *loaded_image_path) {
UINT64 key;
- UINTN i;
+ UINTN timeout;
_cleanup_freepool_ CHAR8 *modevar = NULL, *indvar = NULL;
_cleanup_freepool_ CHAR16 *partstr = NULL, *defaultstr = NULL;
UINTN x, y, size;
Print(L"entry EFI var idx: %d\n", config->idx_default_efivar);
Print(L"\n");
- if (efivar_get_int(LOADER_GUID, L"LoaderConfigTimeout", &i) == EFI_SUCCESS)
- Print(L"LoaderConfigTimeout: %u\n", i);
+ if (efivar_get_int(LOADER_GUID, L"LoaderConfigTimeout", &timeout) == EFI_SUCCESS)
+ Print(L"LoaderConfigTimeout: %u\n", timeout);
if (config->entry_oneshot)
Print(L"LoaderEntryOneShot: %s\n", config->entry_oneshot);
Print(L"\n--- press key ---\n\n");
console_key_read(&key, TRUE);
- for (i = 0; i < config->entry_count; i++) {
+ for (UINTN i = 0; i < config->entry_count; i++) {
ConfigEntry *entry;
if (key == KEYPRESS(0, SCAN_ESC, 0) || key == KEYPRESS(0, 0, 'q'))
UINTN idx_last;
BOOLEAN refresh;
BOOLEAN highlight;
- UINTN i;
UINTN line_width;
CHAR16 **lines;
UINTN x_start;
/* length of the longest entry */
line_width = 5;
- for (i = 0; i < config->entry_count; i++) {
+ for (UINTN i = 0; i < config->entry_count; i++) {
UINTN entry_len;
entry_len = StrLen(config->entries[i]->title_show);
/* menu entries title lines */
lines = AllocatePool(sizeof(CHAR16 *) * config->entry_count);
- for (i = 0; i < config->entry_count; i++) {
- UINTN j, k;
+ for (UINTN i = 0; i < config->entry_count; i++) {
+ UINTN j;
lines[i] = AllocatePool(((x_max+1) * sizeof(CHAR16)));
for (j = 0; j < x_start; j++)
lines[i][j] = ' ';
- for (k = 0; config->entries[i]->title_show[k] != '\0' && j < x_max; j++, k++)
+ for (UINTN k = 0; config->entries[i]->title_show[k] != '\0' && j < x_max; j++, k++)
lines[i][j] = config->entries[i]->title_show[k];
for (; j < x_max; j++)
status = NULL;
clearline = AllocatePool((x_max+1) * sizeof(CHAR16));
- for (i = 0; i < x_max; i++)
+ for (UINTN i = 0; i < x_max; i++)
clearline[i] = ' ';
- clearline[i] = 0;
+ clearline[x_max] = 0;
while (!exit) {
UINT64 key;
if (refresh) {
- for (i = 0; i < config->entry_count; i++) {
+ for (UINTN i = 0; i < config->entry_count; i++) {
if (i < idx_first || i > idx_last)
continue;
uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, 0, y_start + i - idx_first);
*chosen_entry = config->entries[idx_highlight];
- for (i = 0; i < config->entry_count; i++)
+ for (UINTN i = 0; i < config->entry_count; i++)
FreePool(lines[i]);
FreePool(lines);
FreePool(clearline);
}
static VOID config_sort_entries(Config *config) {
- UINTN i;
-
- for (i = 1; i < config->entry_count; i++) {
+ for (UINTN i = 1; i < config->entry_count; i++) {
BOOLEAN more;
- UINTN k;
more = FALSE;
- for (k = 0; k < config->entry_count - i; k++) {
+ for (UINTN k = 0; k < config->entry_count - i; k++) {
ConfigEntry *entry;
if (config_entry_compare(config->entries[k], config->entries[k+1]) <= 0)
}
static INTN config_entry_find(Config *config, CHAR16 *id) {
- UINTN i;
-
- for (i = 0; i < config->entry_count; i++)
+ for (UINTN i = 0; i < config->entry_count; i++)
if (StrCmp(config->entries[i]->id, id) == 0)
return (INTN) i;
static BOOLEAN find_nonunique(ConfigEntry **entries, UINTN entry_count) {
BOOLEAN non_unique = FALSE;
- UINTN i, k;
- for (i = 0; i < entry_count; i++)
+ for (UINTN i = 0; i < entry_count; i++)
entries[i]->non_unique = FALSE;
- for (i = 0; i < entry_count; i++)
- for (k = 0; k < entry_count; k++) {
+ for (UINTN i = 0; i < entry_count; i++)
+ for (UINTN k = 0; k < entry_count; k++) {
if (i == k)
continue;
if (StrCmp(entries[i]->title_show, entries[k]->title_show) != 0)
/* generate a unique title, avoiding non-distinguishable menu entries */
static VOID config_title_generate(Config *config) {
- UINTN i;
-
/* set title */
- for (i = 0; i < config->entry_count; i++) {
+ for (UINTN i = 0; i < config->entry_count; i++) {
CHAR16 *title;
FreePool(config->entries[i]->title_show);
return;
/* add version to non-unique titles */
- for (i = 0; i < config->entry_count; i++) {
+ for (UINTN i = 0; i < config->entry_count; i++) {
CHAR16 *s;
if (!config->entries[i]->non_unique)
return;
/* add machine-id to non-unique titles */
- for (i = 0; i < config->entry_count; i++) {
+ for (UINTN i = 0; i < config->entry_count; i++) {
CHAR16 *s;
_cleanup_freepool_ CHAR16 *m = NULL;
return;
/* add file name to non-unique titles */
- for (i = 0; i < config->entry_count; i++) {
+ for (UINTN i = 0; i < config->entry_count; i++) {
CHAR16 *s;
if (!config->entries[i]->non_unique)
/* look for systemd-boot magic string */
err = file_read(root_dir, loader, 0, 100*1024, &content, &len);
if (!EFI_ERROR(err)) {
- CHAR8 *start = content;
- CHAR8 *last = content + len - sizeof(magic) - 1;
-
- for (; start <= last; start++)
+ for (CHAR8 *start = content; start <= content + len - sizeof(magic) - 1; start++)
if (start[0] == magic[0] && CompareMem(start, magic, sizeof(magic) - 1) == 0)
return FALSE;
}
err = LibLocateHandle(ByProtocol, &FileSystemProtocol, NULL, &handle_count, &handles);
if (!EFI_ERROR(err)) {
- UINTN i;
-
- for (i = 0; i < handle_count; i++) {
+ for (UINTN i = 0; i < handle_count; i++) {
EFI_FILE *root;
BOOLEAN found;
Config *config,
EFI_HANDLE *device) {
- EFI_DEVICE_PATH *partition_path, *node, *disk_path, *copy;
+ EFI_DEVICE_PATH *partition_path, *disk_path, *copy;
UINT32 found_partition_number = (UINT32) -1;
UINT64 found_partition_start = (UINT64) -1;
UINT64 found_partition_size = (UINT64) -1;
if (!partition_path)
return;
- for (node = partition_path; !IsDevicePathEnd(node); node = NextDevicePathNode(node)) {
+ for (EFI_DEVICE_PATH *node = partition_path; !IsDevicePathEnd(node); node = NextDevicePathNode(node)) {
EFI_HANDLE disk_handle;
EFI_BLOCK_IO *block_io;
EFI_DEVICE_PATH *p;
- UINTN nr;
/* First, Let's look for the SCSI/SATA/USB/… device path node, i.e. one above the media
* devices */
continue;
/* Try both copies of the GPT header, in case one is corrupted */
- for (nr = 0; nr < 2; nr++) {
+ for (UINTN nr = 0; nr < 2; nr++) {
_cleanup_freepool_ EFI_PARTITION_ENTRY* entries = NULL;
union {
EFI_PARTITION_TABLE_HEADER gpt_header;
} gpt_header_buffer;
const EFI_PARTITION_TABLE_HEADER *h = &gpt_header_buffer.gpt_header;
UINT64 where;
- UINTN i, sz;
+ UINTN sz;
UINT32 c;
if (nr == 0)
if (c != h->PartitionEntryArrayCRC32)
continue;
- for (i = 0; i < h->NumberOfPartitionEntries; i++) {
+ for (UINTN i = 0; i < h->NumberOfPartitionEntries; i++) {
EFI_PARTITION_ENTRY *entry;
entry = (EFI_PARTITION_ENTRY*) ((UINT8*) entries + h->SizeOfPartitionEntry * i);
copy = DuplicateDevicePath(partition_path);
/* Patch in the data we found */
- for (node = copy; !IsDevicePathEnd(node); node = NextDevicePathNode(node)) {
+ for (EFI_DEVICE_PATH *node = copy; !IsDevicePathEnd(node); node = NextDevicePathNode(node)) {
HARDDRIVE_DEVICE_PATH *hd;
if (DevicePathType(node) != MEDIA_DEVICE_PATH)
}
static VOID config_free(Config *config) {
- UINTN i;
-
- for (i = 0; i < config->entry_count; i++)
+ for (UINTN i = 0; i < config->entry_count; i++)
config_entry_free(config->entries[i]);
FreePool(config->entries);
FreePool(config->entry_default_pattern);
static VOID config_write_entries_to_variable(Config *config) {
_cleanup_freepool_ CHAR16 *buffer = NULL;
- UINTN i, sz = 0;
+ UINTN sz = 0;
CHAR16 *p;
- for (i = 0; i < config->entry_count; i++)
+ for (UINTN i = 0; i < config->entry_count; i++)
sz += StrLen(config->entries[i]->id) + 1;
p = buffer = AllocatePool(sz * sizeof(CHAR16));
- for (i = 0; i < config->entry_count; i++) {
+ for (UINTN i = 0; i < config->entry_count; i++) {
UINTN l;
l = StrLen(config->entries[i]->id) + 1;