From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson To: passt-dev@passt.top Subject: Re: [PATCH 21/28] cppcheck: Suppress NULL pointer warning in tcp_sock_consume() Date: Thu, 29 Sep 2022 11:07:41 +1000 Message-ID: In-Reply-To: <20220928225837.190a0fed@elisabeth> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5565945228349436746==" --===============5565945228349436746== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On Wed, Sep 28, 2022 at 10:58:37PM +0200, Stefano Brivio wrote: > On Wed, 28 Sep 2022 14:33:32 +1000 > David Gibson wrote: > > > Recent versions of cppcheck give a warning due to the NULL buffer passed > > to recv() in tcp_sock_consume(). Since this apparently works, I assume > > it's actually valid, > > Yes, given that we use MSG_TRUNC to discard socket buffers, I thought > it's cleaner to avoid supplying a data buffer altogether. > > POSIX doesn't specify MSG_TRUNC, and whether the buffer can be NULL > isn't specified in Linux documentation, but it works reliably (the > kernel won't even look at it). Ah, interesting. I've update the comment and commit message with this detail. > This was actually the first step of a long-overdue plan: if you observe > this through perf(1), you'll see some overhead in the kernel, which > looks a bit more than a reasonable expectation for pure syscall > overhead. > > So, I planned to check if we can simplify the kernel path if no buffer > is passed. I'll track this somewhere next week. > > Even the day we add a vhost-user back-end, this overhead is still going > to be there, as that wouldn't change anything host-side. > > > but cppcheck doesn't know that recv() can take a NULL > > buffer. So, use a suppression to get rid of the error. > > valgrind didn't know either, by the way -- see the corresponding > suppression in test/valgrind.supp. > -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --===============5565945228349436746== Content-Type: application/pgp-signature Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="signature.asc" MIME-Version: 1.0 LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KCmlRSXpCQUVCQ0FBZEZpRUVvVUx4V3U0L1dz MGRCK1h0Z3lwWTRnRXdZU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