Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/console/kconsole.c

    raca4a04 rfeeac0d  
    5353#include <func.h>
    5454#include <str.h>
    55 #include <macros.h>
    5655#include <sysinfo/sysinfo.h>
    5756#include <ddi/device.h>
     
    119118         * Make sure the command is not already listed.
    120119         */
    121         list_foreach(cmd_list, cur) {
    122                 cmd_info_t *hlp = list_get_instance(cur, cmd_info_t, link);
    123                
     120        list_foreach(cmd_list, link, cmd_info_t, hlp) {
    124121                if (hlp == cmd) {
    125122                        /* The command is already there. */
     
    202199 *
    203200 */
    204 NO_TRACE static int cmdtab_compl(char *input, size_t size, indev_t * indev)
     201NO_TRACE static int cmdtab_compl(char *input, size_t size, indev_t *indev)
    205202{
    206203        const char *name = input;
    207204       
    208205        size_t found = 0;
    209         /* Maximum Match Length : Length of longest matching common substring in
    210            case more than one match is found */
     206       
     207        /*
     208         * Maximum Match Length: Length of longest matching common
     209         * substring in case more than one match is found.
     210         */
    211211        size_t max_match_len = size;
    212212        size_t max_match_len_tmp = size;
     
    229229        }
    230230       
    231         /* If possible completions are more than MAX_TAB_HINTS, ask user whether to display them or not. */
     231        /*
     232         * If the number of possible completions is more than MAX_TAB_HINTS,
     233         * ask the user whether to display them or not.
     234         */
    232235        if (found > MAX_TAB_HINTS) {
    233236                printf("\n");
    234                 continue_showing_hints = console_prompt_display_all_hints(indev, found);
     237                continue_showing_hints =
     238                    console_prompt_display_all_hints(indev, found);
    235239        }
    236240       
     
    240244                while (cmdtab_search_one(name, &pos)) {
    241245                        cmd_info_t *hlp = list_get_instance(pos, cmd_info_t, link);
    242 
     246                       
    243247                        if (continue_showing_hints) {
    244248                                printf("%s (%s)\n", hlp->name, hlp->description);
    245249                                --hints_to_show;
    246250                                ++total_hints_shown;
    247 
    248                                 if (hints_to_show == 0 && total_hints_shown != found) { /* Time to ask user to continue */
    249                                         continue_showing_hints = console_prompt_more_hints(indev, &hints_to_show);
     251                               
     252                                if ((hints_to_show == 0) && (total_hints_shown != found)) {
     253                                        /* Ask user to continue */
     254                                        continue_showing_hints =
     255                                            console_prompt_more_hints(indev, &hints_to_show);
    250256                                }
    251257                        }
    252 
     258                       
    253259                        pos = pos->next;
    254                         for(max_match_len_tmp = 0; output[max_match_len_tmp] == hlp->name[input_len + max_match_len_tmp]
    255                                         && max_match_len_tmp < max_match_len; ++max_match_len_tmp);
     260                       
     261                        for (max_match_len_tmp = 0;
     262                            (output[max_match_len_tmp] ==
     263                            hlp->name[input_len + max_match_len_tmp]) &&
     264                            (max_match_len_tmp < max_match_len); ++max_match_len_tmp);
     265                       
    256266                        max_match_len = max_match_len_tmp;
    257267                }
    258                 /* keep only the characters common in all completions */
     268               
     269                /* Keep only the characters common in all completions */
    259270                output[max_match_len] = 0;
    260271        }
     
    310321                                continue;
    311322                       
    312                         /* Find the beginning of the word
    313                            and copy it to tmp */
     323                        /*
     324                         * Find the beginning of the word
     325                         * and copy it to tmp
     326                         */
    314327                        size_t beg;
    315328                        for (beg = position - 1; (beg > 0) && (!isspace(current[beg]));
     
    333346                                continue;
    334347
    335                         /* We have hints, may be many. In case of more than one hint,
    336                            tmp will contain the common prefix. */
     348                        /*
     349                         * We have hints, possibly many. In case of more than one hint,
     350                         * tmp will contain the common prefix.
     351                         */
    337352                        size_t off = 0;
    338353                        size_t i = 0;
     
    340355                                if (!wstr_linsert(current, ch, position + i, MAX_CMDLINE))
    341356                                        break;
     357                               
    342358                                i++;
    343359                        }
     
    505521                /* It's a number - convert it */
    506522                uint64_t value;
    507                 int rc = str_uint64_t(text, NULL, 0, true, &value);
     523                char *end;
     524                int rc = str_uint64_t(text, &end, 0, false, &value);
     525                if (end != text + len)
     526                        rc = EINVAL;
    508527                switch (rc) {
    509528                case EINVAL:
    510                         printf("Invalid number.\n");
     529                        printf("Invalid number '%s'.\n", text);
    511530                        return false;
    512531                case EOVERFLOW:
    513                         printf("Integer overflow.\n");
     532                        printf("Integer overflow in '%s'.\n", text);
    514533                        return false;
    515534                case EOK:
     
    519538                        break;
    520539                default:
    521                         printf("Unknown error.\n");
     540                        printf("Unknown error parsing '%s'.\n", text);
    522541                        return false;
    523542                }
     
    591610        cmd_info_t *cmd = NULL;
    592611       
    593         list_foreach(cmd_list, cur) {
    594                 cmd_info_t *hlp = list_get_instance(cur, cmd_info_t, link);
     612        list_foreach(cmd_list, link, cmd_info_t, hlp) {
    595613                spinlock_lock(&hlp->lock);
    596614               
Note: See TracChangeset for help on using the changeset viewer.