lib/output_buffer: harden buf_output_free() and kill buf_output_clear()
authorJens Axboe <axboe@fb.com>
Wed, 24 May 2017 16:21:27 +0000 (10:21 -0600)
committerJens Axboe <axboe@fb.com>
Wed, 24 May 2017 16:21:27 +0000 (10:21 -0600)
The clear is superfluous. Kill the caller and the function.

Ensure that we leave the output buffer in a sane state, once
buf_output_free() has been called on it.

Signed-off-by: Jens Axboe <axboe@fb.com>
lib/output_buffer.c
lib/output_buffer.h
stat.c

index 313536dea97aa4f5277fb7634c0116bb5fcae1d7..f6c304bdf02efdfa6c229bfefdc6043002b72893 100644 (file)
@@ -17,6 +17,7 @@ void buf_output_init(struct buf_output *out)
 void buf_output_free(struct buf_output *out)
 {
        free(out->buf);
 void buf_output_free(struct buf_output *out)
 {
        free(out->buf);
+       buf_output_init(out);
 }
 
 size_t buf_output_add(struct buf_output *out, const char *buf, size_t len)
 }
 
 size_t buf_output_add(struct buf_output *out, const char *buf, size_t len)
@@ -39,11 +40,3 @@ size_t buf_output_add(struct buf_output *out, const char *buf, size_t len)
        out->buflen += len;
        return len;
 }
        out->buflen += len;
        return len;
 }
-
-void buf_output_clear(struct buf_output *out)
-{
-       if (out->buflen) {
-               memset(out->buf, 0, out->max_buflen);
-               out->buflen = 0;
-       }
-}
index 15ee00566e7f6784c347b0c997f91a71134f5963..a235af20739ecdc0a3c554a522f10946f8ba45ed 100644 (file)
@@ -12,6 +12,5 @@ struct buf_output {
 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);
-void buf_output_clear(struct buf_output *out);
 
 #endif
 
 #endif
diff --git a/stat.c b/stat.c
index 1f124a8c0b65d40d080638e3aa2a7a4089f061df..e433c6d3858fb454c336df58966a48d68b089cfb 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -1826,8 +1826,8 @@ void __show_run_stats(void)
 
        for (i = 0; i < FIO_OUTPUT_NR; i++) {
                struct buf_output *out = &output[i];
 
        for (i = 0; i < FIO_OUTPUT_NR; i++) {
                struct buf_output *out = &output[i];
+
                log_info_buf(out->buf, out->buflen);
                log_info_buf(out->buf, out->buflen);
-               buf_output_clear(out);
                buf_output_free(out);
        }
 
                buf_output_free(out);
        }