Remove calls to sprintf and strcpy in libuv

Not that there was anything wrong with them, but less build output
is better build output.
This commit is contained in:
Steven Dee 2014-01-26 21:34:22 -08:00
parent 15efb24d68
commit 5f873240a1
2 changed files with 7 additions and 4 deletions

View File

@ -141,7 +141,7 @@ static uv_err_t inet_ntop6(const unsigned char *src, char *dst, size_t size) {
tp += strlen(tp);
break;
}
tp += sprintf(tp, "%x", words[i]);
tp += snprintf(tp, tmp + sizeof tmp - tp, "%x", words[i]);
}
/* Was it a trailing run of 0x00's? */
if (best.base != -1 && (best.base + best.len) == ARRAY_SIZE(words))
@ -154,7 +154,7 @@ static uv_err_t inet_ntop6(const unsigned char *src, char *dst, size_t size) {
if ((size_t)(tp - tmp) > size) {
return uv_enospc_;
}
strcpy(dst, tmp);
uv_strlcpy(dst, tmp, size);
return uv_ok_;
}

View File

@ -175,6 +175,7 @@ int uv_fs_event_init(uv_loop_t* loop,
struct watcher_list* w;
int events;
int wd;
size_t pathsz;
if (init_inotify(loop)) return -1;
@ -195,12 +196,14 @@ int uv_fs_event_init(uv_loop_t* loop,
if (w)
goto no_insert;
w = malloc(sizeof(*w) + strlen(path) + 1);
pathsz = strlen(path) + 1;
w = malloc(sizeof(*w) + pathsz);
if (w == NULL)
return uv__set_sys_error(loop, ENOMEM);
w->wd = wd;
w->path = strcpy((char*)(w + 1), path);
uv_strlcpy((char*)(w + 1), path, pathsz);
w->path = (char*)(w + 1);
ngx_queue_init(&w->watchers);
RB_INSERT(watcher_root, CAST(&loop->inotify_watchers), w);