Changeset f4b1535 in mainline
- Timestamp:
- 2009-04-09T23:04:10Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6eb2e96
- Parents:
- 095003a8
- Location:
- kernel
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/arm32/src/arm32.c
r095003a8 rf4b1535 63 63 init.tasks[i].addr = bootinfo->tasks[i].addr; 64 64 init.tasks[i].size = bootinfo->tasks[i].size; 65 str_ ncpy(init.tasks[i].name, bootinfo->tasks[i].name,66 CONFIG_TASK_NAME_BUFLEN);65 str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN, 66 bootinfo->tasks[i].name); 67 67 } 68 68 } -
kernel/arch/ia64/src/ia64.c
r095003a8 rf4b1535 88 88 VRN_MASK; 89 89 init.tasks[i].size = bootinfo->taskmap.tasks[i].size; 90 str_ ncpy(init.tasks[i].name, bootinfo->taskmap.tasks[i].name,91 CONFIG_TASK_NAME_BUFLEN);90 str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN, 91 bootinfo->taskmap.tasks[i].name); 92 92 } 93 93 } -
kernel/arch/mips32/src/mips32.c
r095003a8 rf4b1535 92 92 init.tasks[i].addr = bootinfo->tasks[i].addr; 93 93 init.tasks[i].size = bootinfo->tasks[i].size; 94 str_ ncpy(init.tasks[i].name, bootinfo->tasks[i].name,95 CONFIG_TASK_NAME_BUFLEN);94 str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN, 95 bootinfo->tasks[i].name); 96 96 } 97 97 -
kernel/arch/ppc32/src/ppc32.c
r095003a8 rf4b1535 62 62 init.tasks[i].addr = PA2KA(bootinfo.taskmap.tasks[i].addr); 63 63 init.tasks[i].size = bootinfo.taskmap.tasks[i].size; 64 str_ ncpy(init.tasks[i].name, bootinfo.taskmap.tasks[i].name,65 CONFIG_TASK_NAME_BUFLEN);64 str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN, 65 bootinfo.taskmap.tasks[i].name); 66 66 } 67 67 } -
kernel/arch/sparc64/src/sparc64.c
r095003a8 rf4b1535 62 62 init.tasks[i].addr = (uintptr_t) bootinfo.taskmap.tasks[i].addr; 63 63 init.tasks[i].size = bootinfo.taskmap.tasks[i].size; 64 str_ ncpy(init.tasks[i].name, bootinfo.taskmap.tasks[i].name,65 CONFIG_TASK_NAME_BUFLEN);64 str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN, 65 bootinfo.taskmap.tasks[i].name); 66 66 } 67 67 -
kernel/genarch/src/multiboot/multiboot.c
r095003a8 rf4b1535 70 70 71 71 /* Copy the command. */ 72 str_ncpy(buf, s tart, min(sz, (size_t) (end - start) + 1));72 str_ncpy(buf, sz, start, (size_t) (end - start)); 73 73 } 74 74 -
kernel/generic/include/string.h
r095003a8 rf4b1535 87 87 extern int str_lcmp(const char *s1, const char *s2, count_t max_len); 88 88 89 extern void str_ncpy(char *dst, const char *src, size_t size); 89 extern void str_cpy(char *dest, size_t size, const char *src); 90 extern void str_ncpy(char *dest, size_t size, const char *src, size_t n); 90 91 extern void wstr_nstr(char *dst, const wchar_t *src, size_t size); 91 92 -
kernel/generic/src/console/kconsole.c
r095003a8 rf4b1535 215 215 while ((hint = cmdtab_search_one(name, &pos))) { 216 216 if ((found == 0) || (str_length(output) > str_length(hint))) 217 str_ ncpy(output, hint, MAX_CMDLINE);217 str_cpy(output, MAX_CMDLINE, hint); 218 218 219 219 pos = pos->next; … … 232 232 233 233 if (found > 0) 234 str_ ncpy(input, output, size);234 str_cpy(input, size, output); 235 235 236 236 return found; … … 439 439 if ((text[0] < '0') || (text[0] > '9')) { 440 440 char symname[MAX_SYMBOL_NAME]; 441 str_ncpy(symname, text, min(len + 1, MAX_SYMBOL_NAME));441 str_ncpy(symname, MAX_SYMBOL_NAME, text, len + 1); 442 442 443 443 uintptr_t symaddr; … … 581 581 case ARG_TYPE_STRING: 582 582 buf = (char *) cmd->argv[i].buffer; 583 str_ncpy(buf, cmd line + start,584 min((end - start) + 1, cmd->argv[i].len));583 str_ncpy(buf, cmd->argv[i].len, cmdline + start, 584 (end - start) + 1); 585 585 break; 586 586 case ARG_TYPE_INT: … … 593 593 if (cmdline[end - 1] == '"') { 594 594 buf = (char *) cmd->argv[i].buffer; 595 str_ncpy(buf, cmdline + start + 1, 596 min((end - start) - 1, cmd->argv[i].len)); 595 str_ncpy(buf, cmd->argv[i].len, 596 cmdline + start + 1, 597 (end - start) - 1); 597 598 cmd->argv[i].intval = (unative_t) buf; 598 599 cmd->argv[i].vartype = ARG_TYPE_STRING; -
kernel/generic/src/debug/symtab.c
r095003a8 rf4b1535 226 226 while ((hint = symtab_search_one(name, &pos))) { 227 227 if ((found == 0) || (str_length(output) > str_length(hint))) 228 str_ ncpy(output, hint, MAX_SYMBOL_NAME);228 str_cpy(output, MAX_SYMBOL_NAME, hint); 229 229 230 230 pos++; … … 242 242 243 243 if (found > 0) 244 str_ ncpy(input, output, size);244 str_cpy(input, size, output); 245 245 246 246 return found; -
kernel/generic/src/lib/string.c
r095003a8 rf4b1535 529 529 } 530 530 531 /** Copy NULL-terminated string. 532 * 533 * Copy source string @a src to destination buffer @a dst. 534 * No more than @a size bytes are written. NULL-terminator is always 535 * written after the last succesfully copied character (i.e. if the 536 * destination buffer is has at least 1 byte, it will be always 537 * NULL-terminated). 538 * 539 * @param src Source string. 531 /** Copy string. 532 * 533 * Copy source string @a src to destination buffer @a dest. 534 * No more than @a size bytes are written. If the size of the output buffer 535 * is at least one byte, the output string will always be well-formed, i.e. 536 * null-terminated and containing only complete characters. 537 * 540 538 * @param dst Destination buffer. 541 539 * @param count Size of the destination buffer. 542 * 543 */ 544 void str_ncpy(char *dst, const char *src, size_t size) 545 { 546 /* No space for the NULL-terminator in the buffer */ 540 * @param src Source string. 541 */ 542 void str_cpy(char *dest, size_t size, const char *src) 543 { 544 wchar_t ch; 545 size_t src_off; 546 size_t dest_off; 547 548 /* No space for the NULL-terminator in the buffer. */ 547 549 if (size == 0) 548 550 return; 549 551 552 src_off = 0; 553 dest_off = 0; 554 555 while ((ch = str_decode(src, &src_off, STR_NO_LIMIT)) != 0) { 556 if (chr_encode(ch, dest, &dest_off, size - 1) != EOK) 557 break; 558 } 559 560 dest[dest_off] = '\0'; 561 } 562 563 /** Copy size-limited substring. 564 * 565 * Copy source string @a src to destination buffer @a dest. 566 * No more than @a size bytes are written. If the size of the output buffer 567 * is at least one byte, the output string will always be well-formed, i.e. 568 * null-terminated and containing only complete characters. 569 * 570 * No more than @a n bytes are read from the input string, so it does not 571 * have to be null-terminated. 572 * 573 * @param dst Destination buffer. 574 * @param count Size of the destination buffer. 575 * @param src Source string. 576 */ 577 void str_ncpy(char *dest, size_t size, const char *src, size_t n) 578 { 550 579 wchar_t ch; 551 size_t str_off = 0; 552 size_t dst_off = 0; 553 554 while ((ch = str_decode(src, &str_off, STR_NO_LIMIT)) != 0) { 555 if (chr_encode(ch, dst, &dst_off, size) != EOK) 580 size_t src_off; 581 size_t dest_off; 582 583 /* No space for the null terminator in the buffer. */ 584 if (size == 0) 585 return; 586 587 src_off = 0; 588 dest_off = 0; 589 590 while ((ch = str_decode(src, &src_off, n)) != 0) { 591 if (chr_encode(ch, dest, &dest_off, size - 1) != EOK) 556 592 break; 557 593 } 558 559 if (dst_off >= size) 560 dst[size - 1] = 0; 561 else 562 dst[dst_off] = 0; 594 595 dest[dest_off] = '\0'; 563 596 } 564 597 -
kernel/generic/src/main/kinit.c
r095003a8 rf4b1535 191 191 192 192 ASSERT(TASK_NAME_BUFLEN >= INIT_PREFIX_LEN); 193 str_ ncpy(namebuf, INIT_PREFIX, TASK_NAME_BUFLEN);194 str_ ncpy(namebuf + INIT_PREFIX_LEN, name,195 TASK_NAME_BUFLEN - INIT_PREFIX_LEN );196 193 str_cpy(namebuf, TASK_NAME_BUFLEN, INIT_PREFIX); 194 str_cpy(namebuf + INIT_PREFIX_LEN, 195 TASK_NAME_BUFLEN - INIT_PREFIX_LEN, name); 196 197 197 int rc = program_create_from_image((void *) init.tasks[i].addr, 198 198 namebuf, &programs[i]); -
kernel/generic/src/proc/task.c
r095003a8 rf4b1535 274 274 return (unative_t) rc; 275 275 276 namebuf[name_len] = 0;277 str_ ncpy(TASK->name, namebuf, TASK_NAME_BUFLEN);276 namebuf[name_len] = '\0'; 277 str_cpy(TASK->name, TASK_NAME_BUFLEN, namebuf); 278 278 279 279 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.