Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751138AbdFUN3S (ORCPT ); Wed, 21 Jun 2017 09:29:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:37494 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750859AbdFUN3R (ORCPT ); Wed, 21 Jun 2017 09:29:17 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0913B239D0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Wed, 21 Jun 2017 09:29:14 -0400 From: Steven Rostedt To: Michael Sartain Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 4/6] Fix read / write data offsets in read / write loops Message-ID: <20170621092914.3f653151@gandalf.local.home> In-Reply-To: <207b0ce25f6b26cad5497bdd5e3c42ce4d9c1b50.1497486273.git.mikesart@fastmail.com> References: <207b0ce25f6b26cad5497bdd5e3c42ce4d9c1b50.1497486273.git.mikesart@fastmail.com> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1462 Lines: 46 On Wed, 14 Jun 2017 18:27:59 -0600 Michael Sartain wrote: > The tot variable in __do_write and do_read is incremented with the amount read > / written, but subsequent times through the loop the calls continue to use the > original data pointer. > > Signed-off-by: Michael Sartain > --- > trace-cmd-local.h | 2 +- > trace-input.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/trace-cmd-local.h b/trace-cmd-local.h > index 8595a8a..b8ab35b 100644 > --- a/trace-cmd-local.h > +++ b/trace-cmd-local.h > @@ -31,7 +31,7 @@ static ssize_t __do_write(int fd, const void *data, size_t size) > ssize_t w; > > do { > - w = TEMP_FAILURE_RETRY(write(fd, data, size - tot)); > + w = TEMP_FAILURE_RETRY(write(fd, data + tot, size - tot)); Good catch. I'm going to modify this to remove the TEMP_FAILURE_RETRY() though. I'll hopefully get this pushed out later today, and we could add the write_intr() and friends later. -- Steve > tot += w; > > if (!w) > diff --git a/trace-input.c b/trace-input.c > index 251d32b..8395917 100644 > --- a/trace-input.c > +++ b/trace-input.c > @@ -202,7 +202,7 @@ static ssize_t do_read(struct tracecmd_input *handle, void *data, size_t size) > ssize_t r; > > do { > - r = TEMP_FAILURE_RETRY(read(handle->fd, data, size - tot)); > + r = TEMP_FAILURE_RETRY(read(handle->fd, data + tot, size - tot)); > tot += r; > > if (!r)