1
0
mirror of https://github.com/libuv/libuv synced 2025-03-28 21:13:16 +00:00

test, bench: replace strlen() with sizeof()

This commit is contained in:
Ben Noordhuis 2012-12-14 11:36:17 +01:00
parent 0a05b31a93
commit f5b6374948
3 changed files with 6 additions and 11 deletions

View File

@ -24,7 +24,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h> /* strlen */
/* Run the benchmark for this many ms */
#define TIME 5000
@ -103,8 +102,7 @@ static void pinger_write_ping(pinger_t* pinger) {
uv_write_t* req;
uv_buf_t buf;
buf.base = (char*)&PING;
buf.len = strlen(PING);
buf = uv_buf_init(PING, sizeof(PING) - 1);
req = malloc(sizeof *req);
if (uv_write(req, (uv_stream_t*) &pinger->tcp, &buf, 1, pinger_write_cb)) {

View File

@ -112,16 +112,16 @@ static int maybe_run_test(int argc, char **argv) {
}
if (strcmp(argv[1], "spawn_helper5") == 0) {
const char* out = "fourth stdio!\n\0";
const char out[] = "fourth stdio!\n";
#ifdef _WIN32
DWORD bytes;
WriteFile((HANDLE) _get_osfhandle(3), out, strlen(out), &bytes, NULL);
WriteFile((HANDLE) _get_osfhandle(3), out, sizeof(out) - 1, &bytes, NULL);
#else
{
ssize_t r;
do
r = write(3, out, strlen(out));
r = write(3, out, sizeof(out) - 1);
while (r == -1 && errno == EINTR);
fsync(3);

View File

@ -24,7 +24,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h> /* strlen */
static int completed_pingers = 0;
@ -77,11 +76,9 @@ static void pinger_write_ping(pinger_t* pinger) {
uv_write_t *req;
uv_buf_t buf;
buf.base = (char*)&PING;
buf.len = strlen(PING);
req = malloc(sizeof(uv_write_t));
buf = uv_buf_init(PING, sizeof(PING) - 1);
req = malloc(sizeof(*req));
if (uv_write(req, (uv_stream_t*)&pinger->stream.tcp, &buf, 1, pinger_after_write)) {
FATAL("uv_write failed");
}