* block/curl: should we be checking curl_easy_setopt() for errors?
@ 2021-08-30 15:34 Peter Maydell
2021-08-31 8:44 ` Daniel P. Berrangé
0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2021-08-30 15:34 UTC (permalink / raw)
To: QEMU Developers, Qemu-block
Coverity complains (CID 1460331, 1459482, 1459336, 1458895)
that we call curl_easy_setopt(), which can return an error value,
but we never check the return value.
Is it correct? Looking at the libcurl documentation, the function
does return an error status, and there's nothing that says it's
ok to ignore (e.g. that it's guaranteed that the library will
safely accumulate any errors and return them when you make the
subsequent curl_easy_perform() call). On the other hand, neither
the libcurl manpage example nor the handful of example programs
at https://curl.se/libcurl/c/example.html ever seem to check the
return value from curl_easy_setopt()...
thanks
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: block/curl: should we be checking curl_easy_setopt() for errors?
2021-08-30 15:34 block/curl: should we be checking curl_easy_setopt() for errors? Peter Maydell
@ 2021-08-31 8:44 ` Daniel P. Berrangé
2021-08-31 9:56 ` Peter Maydell
0 siblings, 1 reply; 3+ messages in thread
From: Daniel P. Berrangé @ 2021-08-31 8:44 UTC (permalink / raw)
To: Peter Maydell; +Cc: QEMU Developers, Qemu-block
On Mon, Aug 30, 2021 at 04:34:56PM +0100, Peter Maydell wrote:
> Coverity complains (CID 1460331, 1459482, 1459336, 1458895)
> that we call curl_easy_setopt(), which can return an error value,
> but we never check the return value.
>
> Is it correct? Looking at the libcurl documentation, the function
> does return an error status, and there's nothing that says it's
> ok to ignore (e.g. that it's guaranteed that the library will
> safely accumulate any errors and return them when you make the
> subsequent curl_easy_perform() call). On the other hand, neither
> the libcurl manpage example nor the handful of example programs
> at https://curl.se/libcurl/c/example.html ever seem to check the
> return value from curl_easy_setopt()...
Options that accept a string can return CURLE_OUT_OF_MEMORY from
curl_easy_setopt.Most other failures seem to be reporting caller
errors such as forgotten arguments, or too long strings.
Does look like we ought to check return status though for at
least some of the options, and if you check it for some then
coverity will also complain if you don't check it for all.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: block/curl: should we be checking curl_easy_setopt() for errors?
2021-08-31 8:44 ` Daniel P. Berrangé
@ 2021-08-31 9:56 ` Peter Maydell
0 siblings, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2021-08-31 9:56 UTC (permalink / raw)
To: Daniel P. Berrangé; +Cc: QEMU Developers, Qemu-block
On Tue, 31 Aug 2021 at 09:44, Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> On Mon, Aug 30, 2021 at 04:34:56PM +0100, Peter Maydell wrote:
> > Coverity complains (CID 1460331, 1459482, 1459336, 1458895)
> > that we call curl_easy_setopt(), which can return an error value,
> > but we never check the return value.
> >
> > Is it correct? Looking at the libcurl documentation, the function
> > does return an error status, and there's nothing that says it's
> > ok to ignore (e.g. that it's guaranteed that the library will
> > safely accumulate any errors and return them when you make the
> > subsequent curl_easy_perform() call). On the other hand, neither
> > the libcurl manpage example nor the handful of example programs
> > at https://curl.se/libcurl/c/example.html ever seem to check the
> > return value from curl_easy_setopt()...
>
> Options that accept a string can return CURLE_OUT_OF_MEMORY from
> curl_easy_setopt.Most other failures seem to be reporting caller
> errors such as forgotten arguments, or too long strings.
>
> Does look like we ought to check return status though for at
> least some of the options, and if you check it for some then
> coverity will also complain if you don't check it for all.
Coverity complains about them all regardless -- I think that the scan
servers have been updated with models for some of these common
software libraries, and it now "knows" that the function has
an error-return that must be checked.
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-08-31 9:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-30 15:34 block/curl: should we be checking curl_easy_setopt() for errors? Peter Maydell
2021-08-31 8:44 ` Daniel P. Berrangé
2021-08-31 9:56 ` Peter Maydell
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.