static void main_show_modes(int argc __unused, char** argv __unused,
struct s_hardware *hardware __unused)
{
- int i;
+ int i = 0;
more_printf("Available modes:\n");
- for (i = 0; i < MAX_MODES; i++)
+ while (list_modes[i]) {
more_printf("\t%s\n", list_modes[i]->name);
+ i++;
+ }
}
/**
&cpu_mode,
&pci_mode,
&vesa_mode,
+ NULL,
};
/*
**/
void set_mode(cli_mode_t mode, struct s_hardware* hardware)
{
- int i;
+ int i = 0;
switch (mode) {
case EXIT_MODE:
default:
/* Invalid mode */
more_printf("Unknown mode, please choose among:\n");
- for (i = 0; i < MAX_MODES; i++)
+ while (list_modes[i]) {
more_printf("\t%s\n", list_modes[i]->name);
+ i++;
+ }
}
find_cli_mode_descr(hdt_cli.mode, ¤t_mode);
{
int i = 0;
- for (i = 0; i < MAX_MODES; i++)
+ while (list_modes[i]) {
if (!strncmp(name, list_modes[i]->name,
sizeof(list_modes[i]->name)))
break;
+ i++;
+ }
- if (i == MAX_MODES)
+ if (!list_modes[i])
return INVALID_MODE;
else
return list_modes[i]->mode;
**/
void find_cli_mode_descr(cli_mode_t mode, struct cli_mode_descr **mode_found)
{
- int modes_iter = 0;
+ int i = 0;
- while (modes_iter < MAX_MODES &&
- list_modes[modes_iter]->mode != mode)
- modes_iter++;
+ while (list_modes[i] &&
+ list_modes[i]->mode != mode)
+ i++;
/* Shouldn't get here... */
- if (modes_iter == MAX_MODES)
+ if (!list_modes[i])
*mode_found = NULL;
else
- *mode_found = list_modes[modes_iter];
+ *mode_found = list_modes[i];
}
/**
**/
static void autocomplete_command(char *command)
{
- int j;
+ int j = 0;
struct cli_callback_descr* associated_module = NULL;
/* First take care of the two special commands: 'show' and 'set' */
* Then, go through the modes for the special case
* '<mode>' -> 'set mode <mode>'
*/
- for (j = 0; j < MAX_MODES; j++) {
+ while (list_modes[j]) {
if (strncmp(list_modes[j]->name, command, strlen(command)) == 0) {
more_printf("%s\n", list_modes[j]->name);
autocomplete_add_token_to_list(list_modes[j]->name);
}
+ j++;
}
/*