Skip to content

Commit 9a7b154

Browse files
pschafhalterpcmoritz
authored andcommitted
Replace UT string in redis tests (#1211)
* Replace UT arg formatting with vsnprintf * Fix bug with va_list usage
1 parent 009f59d commit 9a7b154

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/common/test/redis_tests.cc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,20 @@ const char *test_value = "bar";
2121
std::vector<int> connections;
2222

2323
void write_formatted_log_message(int socket_fd, const char *format, ...) {
24-
UT_string *cmd;
2524
va_list ap;
2625

27-
utstring_new(cmd);
26+
/* Get cmd size */
2827
va_start(ap, format);
29-
utstring_printf_va(cmd, format, ap);
28+
size_t cmd_size = vsnprintf(nullptr, 0, format, ap) + 1;
3029
va_end(ap);
3130

32-
write_log_message(socket_fd, utstring_body(cmd));
33-
utstring_free(cmd);
31+
/* Print va to cmd */
32+
char cmd[cmd_size];
33+
va_start(ap, format);
34+
vsnprintf(cmd, cmd_size, format, ap);
35+
va_end(ap);
36+
37+
write_log_message(socket_fd, cmd);
3438
}
3539

3640
int async_redis_socket_test_callback_called = 0;

0 commit comments

Comments
 (0)