From: Jens Axboe Date: Mon, 20 Feb 2006 08:30:53 +0000 (+0100) Subject: [PATCH] blktrace: be a little more conservative on 'ready' subbuf bytes X-Git-Tag: blktrace-0.99.1~29 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=1be42f3d3db5576ab892c769cadf488d3562017c;p=blktrace.git [PATCH] blktrace: be a little more conservative on 'ready' subbuf bytes --- diff --git a/blktrace.c b/blktrace.c index aea8625..9c4dd19 100644 --- a/blktrace.c +++ b/blktrace.c @@ -558,7 +558,7 @@ static int get_subbuf_sendfile(struct thread_information *tip, { struct tip_subbuf *ts; struct stat sb; - unsigned int ready; + unsigned int ready, this_size; int err; if (fstat(tip->fd, &sb) < 0) { @@ -570,13 +570,17 @@ static int get_subbuf_sendfile(struct thread_information *tip, if (!ready) return 0; + this_size = buf_size; while (ready) { + if (this_size > ready) + this_size = ready; + ts = malloc(sizeof(*ts)); ts->max_len = maxlen; ts->buf = NULL; - ts->len = buf_size; + ts->len = this_size; ts->max_len = ts->len; ts->offset = tip->ofile_offset; tip->ofile_offset += ts->len; @@ -585,7 +589,7 @@ static int get_subbuf_sendfile(struct thread_information *tip, if (err) return err; - ready -= buf_size; + ready -= this_size; } return 0; @@ -1002,6 +1006,7 @@ static int tip_open_output(struct device_information *dip, tip->ofile_stdout = 0; tip->ofile_mmap = 0; vbuf_size = 0; + mode = 0; /* gcc 4.x issues a bogus warning */ } else if (pipeline) { tip->ofile = fdopen(STDOUT_FILENO, "w"); tip->ofile_stdout = 1;