linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Catalin Petrescu <catalin.petrescu@gmail.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: linux-gpio@vger.kernel.org
Subject: Re: [PATCH] tools: Change asprintf return code check
Date: Tue, 13 Sep 2022 16:30:12 -0400	[thread overview]
Message-ID: <e6e721b3756db8b7a4bfe902af53e3377e681187.camel@gmail.com> (raw)
In-Reply-To: <CAMRc=Md47VUkZ47qoBpxSiHb6y5V2LsSkkO1ogvyY2KY4w4qyg@mail.gmail.com>

On Tue, 2022-09-13 at 16:47 +0200, Bartosz Golaszewski wrote:
> On Thu, Sep 8, 2022 at 4:03 PM Catalin Petrescu
> <catalin.petrescu@gmail.com> wrote:
> > 
> > Hi there,
> > 
> > I found a small error (IMHO) in libgpiod.
> > The issue is that asprintf may return -1 if it fails to allocate
> > memory, and if that happens, chip_open_by_number will pass a NULL
> > pointer to gpiod_chip_open.
> > 
> > I hope this helps.
> > 
> > Thanks,
> > 
> > Catalin.
> 
> Hey Catalin,
> 
> Please next time send the patch inline using git's send-email
> command.
> 
> You're right about the error code check but it should actually be ret
> < 0 as per asprintf's documentation.
> 
> Bart

Hi Bart,

I'll use git send-email next time. I was not aware of its existence.
And I still need to figure out how to pass the gmail SMTP
authentication.

You're right, when asprintf returns zero, technically, that's not an
error.
My thought was that if asprintf ever returns zero, that means that the
path is a zero-length string.
So, the next call to gpiod_chip_open(path) will likely fail. But I
guess, the right thing to do is to let gpiod_chip_open() deal with it.

Thanks,

Catalin.



  reply	other threads:[~2022-09-13 20:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-08 14:03 [PATCH] tools: Change asprintf return code check Catalin Petrescu
2022-09-13 14:47 ` Bartosz Golaszewski
2022-09-13 20:30   ` Catalin Petrescu [this message]
2022-09-14  9:11     ` Bartosz Golaszewski

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=e6e721b3756db8b7a4bfe902af53e3377e681187.camel@gmail.com \
    --to=catalin.petrescu@gmail.com \
    --cc=brgl@bgdev.pl \
    --cc=linux-gpio@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).