From 57e8a2ad93e3f27694b9ab0d9a56abd631e36562 Mon Sep 17 00:00:00 2001 From: Tom Zanussi Date: Wed, 25 Jan 2006 15:10:43 +0100 Subject: [PATCH] [PATCH] blktrace: Don't overwrite buf_size for the vbuffer Here's another patch to fix a problem I noticed - the code that sets the buffer size passed to setvbuf() uses the global buf_size variable and thus unintentionally sets that variable, which is used elsewhere later e.g. setting tip->fd_max_size in extract(). --- blktrace.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/blktrace.c b/blktrace.c index 2b35874..1abafcb 100644 --- a/blktrace.c +++ b/blktrace.c @@ -623,7 +623,7 @@ static int start_threads(struct device_information *dip) struct thread_information *tip; char op[64]; int j, pipeline = output_name && !strcmp(output_name, "-"); - int len, mode; + int len, mode, vbuf_size; for_each_tip(dip, tip, j) { tip->cpu = j; @@ -635,7 +635,7 @@ static int start_threads(struct device_information *dip) tip->ofile = fdopen(STDOUT_FILENO, "w"); tip->fd_lock = &stdout_mutex; mode = _IOLBF; - buf_size = 512; + vbuf_size = 512; } else { len = 0; @@ -651,7 +651,7 @@ static int start_threads(struct device_information *dip) } tip->ofile = fopen(op, "w"); mode = _IOFBF; - buf_size = OFILE_BUF; + vbuf_size = OFILE_BUF; } if (tip->ofile == NULL) { @@ -659,8 +659,8 @@ static int start_threads(struct device_information *dip) return 1; } - tip->ofile_buffer = malloc(buf_size); - if (setvbuf(tip->ofile, tip->ofile_buffer, mode, buf_size)) { + tip->ofile_buffer = malloc(vbuf_size); + if (setvbuf(tip->ofile, tip->ofile_buffer, mode, vbuf_size)) { perror("setvbuf"); close_thread(tip); return 1; -- 2.25.1