coverity 83663 remove random from test client

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2014-11-30 13:53:19 +08:00
parent 0c5f6709a8
commit cbd98ed1e4

View file

@ -137,6 +137,7 @@ callback_lws_mirror(struct libwebsocket_context *context,
LWS_SEND_BUFFER_POST_PADDING]; LWS_SEND_BUFFER_POST_PADDING];
int l = 0; int l = 0;
int n; int n;
unsigned int rands[4];
switch (reason) { switch (reason) {
@ -144,7 +145,8 @@ callback_lws_mirror(struct libwebsocket_context *context,
fprintf(stderr, "callback_lws_mirror: LWS_CALLBACK_CLIENT_ESTABLISHED\n"); fprintf(stderr, "callback_lws_mirror: LWS_CALLBACK_CLIENT_ESTABLISHED\n");
mirror_lifetime = 10 + (random() & 1023); libwebsockets_get_random(context, rands, sizeof(rands[0]));
mirror_lifetime = 10 + (rands[0] & 1023);
/* useful to test single connection stability */ /* useful to test single connection stability */
if (longlived) if (longlived)
mirror_lifetime += 50000; mirror_lifetime += 50000;
@ -178,13 +180,15 @@ callback_lws_mirror(struct libwebsocket_context *context,
case LWS_CALLBACK_CLIENT_WRITEABLE: case LWS_CALLBACK_CLIENT_WRITEABLE:
for (n = 0; n < 1; n++) for (n = 0; n < 1; n++) {
libwebsockets_get_random(context, rands, sizeof(rands));
l += sprintf((char *)&buf[LWS_SEND_BUFFER_PRE_PADDING + l], l += sprintf((char *)&buf[LWS_SEND_BUFFER_PRE_PADDING + l],
"c #%06X %d %d %d;", "c #%06X %d %d %d;",
(int)random() & 0xffffff, (int)rands[0] & 0xffffff,
(int)random() % 500, (int)rands[1] % 500,
(int)random() % 250, (int)rands[2] % 250,
(int)random() % 24); (int)rands[3] % 24);
}
n = libwebsocket_write(wsi, n = libwebsocket_write(wsi,
&buf[LWS_SEND_BUFFER_PRE_PADDING], l, opts | LWS_WRITE_TEXT); &buf[LWS_SEND_BUFFER_PRE_PADDING], l, opts | LWS_WRITE_TEXT);