Changeset b60c582 in mainline for kernel/genarch/src/multiboot/multiboot.c
- Timestamp:
- 2009-04-03T08:02:30Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2398ee9
- Parents:
- 9be1d58
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/multiboot/multiboot.c
r9be1d58 rb60c582 42 42 /** Extract command name from the multiboot module command line. 43 43 * 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). 46 46 * @param cmd_line Input string (the command line). 47 47 * 48 48 */ 49 static void extract_command(char *buf, size_t n, const char *cmd_line)49 static void extract_command(char *buf, size_t sz, const char *cmd_line) 50 50 { 51 const char *start, *end, *cp;52 size_t max_len;53 54 51 /* Find the first space. */ 55 end = strchr(cmd_line, ' ');52 const char *end = str_chr(cmd_line, ' '); 56 53 if (end == NULL) 57 54 end = cmd_line + str_size(cmd_line); … … 61 58 * next character. Otherwise, place start at beginning of buffer. 62 59 */ 63 cp = end; 64 start = buf; 60 const char *cp = end; 61 const char *start = buf; 62 65 63 while (cp != start) { 66 64 if (*cp == '/') { … … 68 66 break; 69 67 } 70 --cp;68 cp--; 71 69 } 72 70 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)); 77 73 } 78 74 … … 88 84 { 89 85 uint32_t flags; 90 multiboot_mod_t *mods;91 uint32_t i;92 86 93 87 if (signature == MULTIBOOT_LOADER_MAGIC) … … 99 93 100 94 /* Copy module information. */ 101 95 uint32_t i; 102 96 if ((flags & MBINFO_FLAGS_MODS) != 0) { 103 97 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); 105 100 106 101 for (i = 0; i < init.cnt; i++) { … … 114 109 MULTIBOOT_PTR(mods[i].string)); 115 110 } else 116 init.tasks[i].name[0] = '\0';111 init.tasks[i].name[0] = 0; 117 112 } 118 113 } else … … 121 116 /* Copy memory map. */ 122 117 123 int32_t mmap_length;124 multiboot_mmap_t *mme;125 uint32_t size;126 127 118 if ((flags & MBINFO_FLAGS_MMAP) != 0) { 128 mmap_length = mi->mmap_length;129 m me = MULTIBOOT_PTR(mi->mmap_addr);119 int32_t mmap_length = mi->mmap_length; 120 multiboot_mmap_t *mme = MULTIBOOT_PTR(mi->mmap_addr); 130 121 e820counter = 0; 131 122 … … 135 126 136 127 /* Compute address of next structure. */ 137 size = sizeof(mme->size) + mme->size;128 uint32_t size = sizeof(mme->size) + mme->size; 138 129 mme = ((void *) mme) + size; 139 130 mmap_length -= size;
Note:
See TracChangeset
for help on using the changeset viewer.