Linux IIO development
 help / color / mirror / Atom feed
From: Marco Chen <marcochen.dev@gmail.com>
To: David Kahurani <k.kahurani@gmail.com>
Cc: "Arnav Kapoor" <kapoorarnav43@gmail.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Hartmut Knaack" <knaack.h@gmx.de>,
	"Linus Walleij" <linusw@kernel.org>,
	linux-iio@vger.kernel.org,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	linux-kernel-mentees@lists.linux.dev
Subject: Re: [PATCH 0/2] tools: iio: iio_generic_buffer: fix exit status
Date: Sat, 28 Nov 2026 13:44:37 -0500	[thread overview]
Message-ID: <awsbrFOr2w8VF9Ml@xiaolong> (raw)
In-Reply-To: <CAAZOf24WuvdmyvpAhZsxafTiscSnjvW8Rt0fZjK9QHkfK8PN9Q@mail.gmail.com>

On Fri, Nov 27, 2026 at 02:59:37PM +0300, David Kahurani wrote:
> On Fri, Nov 27, 2026, 14:39 Arnav Kapoor <kapoorarnav43@gmail.com> wrote:
> 
> > The reason you get that far as non-root, though, is that
> > enable_disable_all_channels() ignores failed writes: it stores the
> > write_sysfs_int() result in ret, only prints a message, and always
> > returns 0 (the ret = -ENOENT at the top is never used either). So the
> > "Failed to enable all channels" check in main() can't fire for a write
> > failure. Returning the error from there, as a separate patch, would
> > make the non-root case fail earlier with -EACCES. Your 2/2 is still
> > useful as a safety net.
> >
> 
> Not sure about this... But, in a write and possibly read attempt a return
> code of zero means no operation was performed. That end of file(EOF), zero
> bytes written, zero bytes read etc

Thank you Arnav for the review, and thank you David for bringing up your
point on the return code of zero.

For this series though, I did not change how write_sysfs_int() reports
its return value. The value this series changes is only the process's
exit status, where 0 indicates success. That is a different convention 
from the number of bytes written from the return code of a read or write
attempt.

Returning the write error from enable_disable_all_channels(), as Arnav
suggested, would be a good solution to make the non-root case fail
earlier with -EACCES. But, as Arnav said, I think that would belong in a
separate patch.

Thank you both, again.

Marco

      parent reply	other threads:[~2026-11-28 18:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27  8:57 [PATCH 0/2] tools: iio: iio_generic_buffer: fix exit status Marco Chen
2026-11-27  8:57 ` [PATCH 1/2] tools: iio: iio_generic_buffer: return 0 on success Marco Chen
2026-11-27  8:57 ` [PATCH 2/2] tools: iio: iio_generic_buffer: return error if no channels can be enabled Marco Chen
2026-11-27 11:36 ` [PATCH 0/2] tools: iio: iio_generic_buffer: fix exit status Arnav Kapoor
     [not found]   ` <CAAZOf24WuvdmyvpAhZsxafTiscSnjvW8Rt0fZjK9QHkfK8PN9Q@mail.gmail.com>
2026-11-28 18:44     ` Marco Chen [this message]

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=awsbrFOr2w8VF9Ml@xiaolong \
    --to=marcochen.dev@gmail.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=k.kahurani@gmail.com \
    --cc=kapoorarnav43@gmail.com \
    --cc=knaack.h@gmx.de \
    --cc=linusw@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel-mentees@lists.linux.dev \
    --cc=nuno.sa@analog.com \
    --cc=skhan@linuxfoundation.org \
    /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