linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hartmut Knaack <knaack.h@gmx.de>
To: Daniel Baluta <daniel.baluta@intel.com>
Cc: "linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald <pmeerw@pmeerw.net>,
	Roberta Dobrescu <roberta.dobrescu@gmail.com>,
	Irina Tirdea <irina.tirdea@intel.com>
Subject: Re: [PATCH v2 1/3] tools:iio:iio_event_monitor: check if event is fully read
Date: Sat, 13 Jun 2015 10:36:45 +0200	[thread overview]
Message-ID: <557BEB9D.2000800@gmx.de> (raw)
In-Reply-To: <CAEnQRZALJLbyQ9e5_JVr5xi+kH+pEGfPDGisay+C=b0n9XJM8A@mail.gmail.com>

Daniel Baluta schrieb am 10.06.2015 um 22:16:
> On Wed, Jun 10, 2015 at 10:51 PM, Hartmut Knaack <knaack.h@gmx.de> wrote:
>> Check that the read event is of the expected size.
>>
>> Signed-off-by: Hartmut Knaack <knaack.h@gmx.de>
>> ---
>>  tools/iio/iio_event_monitor.c | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c
>> index 016760e..2559fba 100644
>> --- a/tools/iio/iio_event_monitor.c
>> +++ b/tools/iio/iio_event_monitor.c
>> @@ -299,6 +299,12 @@ int main(int argc, char **argv)
>>                         }
>>                 }
>>
>> +               if (ret != sizeof(event)) {
>> +                       printf("Reading event failed!\n");
>> +                       ret = -EIO;
>> +                       break;
>> +               }
>> +
> 
> For a test program this should be good enough, not sure if it does make sense
> to read until we get all data.

Not sure, if I get your intention here. But as Jonathan suggested, something
went seriously wrong, if the sizes don't match here. Reading further, until
the desired size is reached could result in receiving the missing data, or
getting already partial data from the next event. I would leave it as is for
now and see if anyone ever gets this error. Then we can still dig deeper.

> 
> Also, we should print the error at stderr.
> 

I basically agree on this one, but since the majority of the error messages
in this file are currently just printed to stdout, I would prefer to take it
as is (for consistency) and have a follow-up patch to send all error messages
to stderr. 

Thanks for your input.
Hartmut

>>                 print_event(&event);
>>         }
> 
> thanks,
> Daniel.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


  reply	other threads:[~2015-06-13  8:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-10 19:51 [PATCH v2 0/3] iio-tools out-of-staging cleanup Hartmut Knaack
2015-06-10 19:51 ` [PATCH v2 1/3] tools:iio:iio_event_monitor: check if event is fully read Hartmut Knaack
2015-06-10 20:16   ` Daniel Baluta
2015-06-13  8:36     ` Hartmut Knaack [this message]
2015-06-13  8:46       ` Daniel Baluta
2015-06-13 10:00         ` Hartmut Knaack
2015-06-13 11:11           ` Cristina Georgiana Opriceana
2015-06-21 15:21   ` Jonathan Cameron
2015-06-10 19:51 ` [PATCH v2 2/3] tools:iio: adjust coding style Hartmut Knaack
2015-06-13 17:53   ` Jonathan Cameron
2015-06-10 19:51 ` [PATCH v2 3/3] tools:iio: rename variables Hartmut Knaack

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=557BEB9D.2000800@gmx.de \
    --to=knaack.h@gmx.de \
    --cc=daniel.baluta@intel.com \
    --cc=irina.tirdea@intel.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    --cc=roberta.dobrescu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).