Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1191161 > unrolled thread

[PATCH 2/2] tools: iio: print error message when buffer enable fails

Started byIrina Tirdea <irina.tirdea@intel.com>
First post2015-07-23 19:30 +0200
Last post2015-07-24 15:30 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/2] tools: iio: print error message when buffer enable fails Irina Tirdea <irina.tirdea@intel.com> - 2015-07-23 19:30 +0200
    Re: [PATCH 2/2] tools: iio: print error message when buffer  enable fails Hartmut Knaack <knaack.h@gmx.de> - 2015-07-24 01:20 +0200
      RE: [PATCH 2/2] tools: iio: print error message when buffer enable  fails "Tirdea, Irina" <irina.tirdea@intel.com> - 2015-07-24 15:30 +0200

#1191161 — [PATCH 2/2] tools: iio: print error message when buffer enable fails

FromIrina Tirdea <irina.tirdea@intel.com>
Date2015-07-23 19:30 +0200
Subject[PATCH 2/2] tools: iio: print error message when buffer enable fails
Message-ID<pPstI-4VP-15@gated-at.bofh.it>
Running generic_buffer without enabling any channel of the
sensor will fail without printing any error message.

Add an error message that indicates buffer enable failed.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
---
 tools/iio/generic_buffer.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c
index 32f389eb..936469c 100644
--- a/tools/iio/generic_buffer.c
+++ b/tools/iio/generic_buffer.c
@@ -364,8 +364,11 @@ int main(int argc, char **argv)
 
 	/* Enable the buffer */
 	ret = write_sysfs_int("enable", buf_dir_name, 1);
-	if (ret < 0)
+	if (ret < 0) {
+		fprintf(stderr,
+			"Failed to enable buffer: %s\n", strerror(errno));
 		goto error_free_buf_dir_name;
+	}
 
 	scan_size = size_from_channelarray(channels, num_channels);
 	data = malloc(scan_size * buf_len);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1191401 — Re: [PATCH 2/2] tools: iio: print error message when buffer enable fails

FromHartmut Knaack <knaack.h@gmx.de>
Date2015-07-24 01:20 +0200
SubjectRe: [PATCH 2/2] tools: iio: print error message when buffer enable fails
Message-ID<pPxWq-4F6-21@gated-at.bofh.it>
In reply to#1191161
Irina Tirdea schrieb am 23.07.2015 um 19:22:
> Running generic_buffer without enabling any channel of the
> sensor will fail without printing any error message.
> 
> Add an error message that indicates buffer enable failed.

Hi,
please make use of the error code stored in ret (with negative sign), as
in most cases the value of errno has already changed since the original
error has occurred.
Thanks,

Hartmut

> 
> Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
> ---
>  tools/iio/generic_buffer.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c
> index 32f389eb..936469c 100644
> --- a/tools/iio/generic_buffer.c
> +++ b/tools/iio/generic_buffer.c
> @@ -364,8 +364,11 @@ int main(int argc, char **argv)
>  
>  	/* Enable the buffer */
>  	ret = write_sysfs_int("enable", buf_dir_name, 1);
> -	if (ret < 0)
> +	if (ret < 0) {
> +		fprintf(stderr,
> +			"Failed to enable buffer: %s\n", strerror(errno));
>  		goto error_free_buf_dir_name;
> +	}
>  
>  	scan_size = size_from_channelarray(channels, num_channels);
>  	data = malloc(scan_size * buf_len);
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1191827 — RE: [PATCH 2/2] tools: iio: print error message when buffer enable fails

From"Tirdea, Irina" <irina.tirdea@intel.com>
Date2015-07-24 15:30 +0200
SubjectRE: [PATCH 2/2] tools: iio: print error message when buffer enable fails
Message-ID<pPLcZ-71j-3@gated-at.bofh.it>
In reply to#1191401

> -----Original Message-----
> From: Hartmut Knaack [mailto:knaack.h@gmx.de]
> Sent: 24 July, 2015 2:13
> To: Tirdea, Irina; Jonathan Cameron; linux-iio@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Subject: Re: [PATCH 2/2] tools: iio: print error message when buffer enable fails
> 
> Irina Tirdea schrieb am 23.07.2015 um 19:22:
> > Running generic_buffer without enabling any channel of the
> > sensor will fail without printing any error message.
> >
> > Add an error message that indicates buffer enable failed.
> 
> Hi,
> please make use of the error code stored in ret (with negative sign), as
> in most cases the value of errno has already changed since the original
> error has occurred.
> Thanks,
> 

Hi Hartmut,

Yes, you are right. Missed that. Will fix in v2.

Thanks,
Irina

> Hartmut
> 
> >
> > Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
> > ---
> >  tools/iio/generic_buffer.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c
> > index 32f389eb..936469c 100644
> > --- a/tools/iio/generic_buffer.c
> > +++ b/tools/iio/generic_buffer.c
> > @@ -364,8 +364,11 @@ int main(int argc, char **argv)
> >
> >  	/* Enable the buffer */
> >  	ret = write_sysfs_int("enable", buf_dir_name, 1);
> > -	if (ret < 0)
> > +	if (ret < 0) {
> > +		fprintf(stderr,
> > +			"Failed to enable buffer: %s\n", strerror(errno));
> >  		goto error_free_buf_dir_name;
> > +	}
> >
> >  	scan_size = size_from_channelarray(channels, num_channels);
> >  	data = malloc(scan_size * buf_len);
> >

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web