Two files log.c and lib/output_buffer.c have dependency on each other,
i.e. log.c is using buf_output_add() in lib/output_buffer.c, while
lib/output_buffer.c is using log_info_buf() in log.c.
This commit removes this dependency from lib/output_buffer.c by
dropping log_info_buf() call from a library function buf_output_flush(),
and then as a result rename buf_output_flush() to buf_output_clear()
since it's no longer flusing anything. log_info_buf() is now called
independently by __show_run_stats() which was the only caller of
buf_output_flush().
log_info_buf() returning 0 on !len is necessary to keep this commit
without making functional difference. dprint()/log_info() basically
never pass NULL or "" to log_info_buf(), but __show_run_stats() would
pass NULL with length 0 for unused output modes which then needs to
be avoided as a special case.
Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
#include <stdlib.h>
#include "output_buffer.h"
#include <stdlib.h>
#include "output_buffer.h"
#include "../minmax.h"
#define BUF_INC 1024
#include "../minmax.h"
#define BUF_INC 1024
-size_t buf_output_flush(struct buf_output *out)
+void buf_output_clear(struct buf_output *out)
- ret = log_info_buf(out->buf, out->buflen);
memset(out->buf, 0, out->max_buflen);
out->buflen = 0;
}
memset(out->buf, 0, out->max_buflen);
out->buflen = 0;
}
void buf_output_init(struct buf_output *out);
void buf_output_free(struct buf_output *out);
size_t buf_output_add(struct buf_output *out, const char *buf, size_t len);
void buf_output_init(struct buf_output *out);
void buf_output_free(struct buf_output *out);
size_t buf_output_add(struct buf_output *out, const char *buf, size_t len);
-size_t buf_output_flush(struct buf_output *out);
+void buf_output_clear(struct buf_output *out);
size_t log_info_buf(const char *buf, size_t len)
{
size_t log_info_buf(const char *buf, size_t len)
{
+ /*
+ * buf could be NULL (not just "").
+ */
+ if (!buf)
+ return 0;
+
if (is_backend) {
size_t ret = fio_server_text_output(FIO_LOG_INFO, buf, len);
if (ret != -1)
if (is_backend) {
size_t ret = fio_server_text_output(FIO_LOG_INFO, buf, len);
if (ret != -1)
}
for (i = 0; i < FIO_OUTPUT_NR; i++) {
}
for (i = 0; i < FIO_OUTPUT_NR; i++) {
- buf_output_flush(&output[i]);
- buf_output_free(&output[i]);
+ struct buf_output *out = &output[i];
+ log_info_buf(out->buf, out->buflen);
+ buf_output_clear(out);
+ buf_output_free(out);