Ignore:
Timestamp:
2009-04-03T08:02:30Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2398ee9
Parents:
9be1d58
Message:

update for string changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/multiboot/multiboot.c

    r9be1d58 rb60c582  
    4242/** Extract command name from the multiboot module command line.
    4343 *
    44  * @param buf      Destination buffer (will always null-terminate).
    45  * @param n        Size of destination buffer.
     44 * @param buf      Destination buffer (will always NULL-terminate).
     45 * @param sz       Size of destination buffer (in bytes).
    4646 * @param cmd_line Input string (the command line).
    4747 *
    4848 */
    49 static void extract_command(char *buf, size_t n, const char *cmd_line)
     49static void extract_command(char *buf, size_t sz, const char *cmd_line)
    5050{
    51         const char *start, *end, *cp;
    52         size_t max_len;
    53        
    5451        /* Find the first space. */
    55         end = strchr(cmd_line, ' ');
     52        const char *end = str_chr(cmd_line, ' ');
    5653        if (end == NULL)
    5754                end = cmd_line + str_size(cmd_line);
     
    6158         * next character. Otherwise, place start at beginning of buffer.
    6259         */
    63         cp = end;
    64         start = buf;
     60        const char *cp = end;
     61        const char *start = buf;
     62       
    6563        while (cp != start) {
    6664                if (*cp == '/') {
     
    6866                        break;
    6967                }
    70                 --cp;
     68                cp--;
    7169        }
    7270       
    73         /* Copy the command and null-terminate the string. */
    74         max_len = min(n - 1, (size_t) (end - start));
    75         strncpy(buf, start, max_len + 1);
    76         buf[max_len] = '\0';
     71        /* Copy the command. */
     72        str_ncpy(buf, start, min(sz, (size_t) (end - start) + 1));
    7773}
    7874
     
    8884{
    8985        uint32_t flags;
    90         multiboot_mod_t *mods;
    91         uint32_t i;
    9286       
    9387        if (signature == MULTIBOOT_LOADER_MAGIC)
     
    9993       
    10094        /* Copy module information. */
    101        
     95        uint32_t i;
    10296        if ((flags & MBINFO_FLAGS_MODS) != 0) {
    10397                init.cnt = min(mi->mods_count, CONFIG_INIT_TASKS);
    104                 mods = (multiboot_mod_t *) MULTIBOOT_PTR(mi->mods_addr);
     98                multiboot_mod_t *mods
     99                    = (multiboot_mod_t *) MULTIBOOT_PTR(mi->mods_addr);
    105100               
    106101                for (i = 0; i < init.cnt; i++) {
     
    114109                                    MULTIBOOT_PTR(mods[i].string));
    115110                        } else
    116                                 init.tasks[i].name[0] = '\0';
     111                                init.tasks[i].name[0] = 0;
    117112                }
    118113        } else
     
    121116        /* Copy memory map. */
    122117       
    123         int32_t mmap_length;
    124         multiboot_mmap_t *mme;
    125         uint32_t size;
    126        
    127118        if ((flags & MBINFO_FLAGS_MMAP) != 0) {
    128                 mmap_length = mi->mmap_length;
    129                 mme = MULTIBOOT_PTR(mi->mmap_addr);
     119                int32_t mmap_length = mi->mmap_length;
     120                multiboot_mmap_t *mme = MULTIBOOT_PTR(mi->mmap_addr);
    130121                e820counter = 0;
    131122               
     
    135126                       
    136127                        /* Compute address of next structure. */
    137                         size = sizeof(mme->size) + mme->size;
     128                        uint32_t size = sizeof(mme->size) + mme->size;
    138129                        mme = ((void *) mme) + size;
    139130                        mmap_length -= size;
Note: See TracChangeset for help on using the changeset viewer.