linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vadim Fedorenko <vfedorenko@novek.ru>
To: Jakub Kicinski <kuba@kernel.org>, davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org,
	shuah@kernel.org
Subject: Re: [PATCH net 1/2] selftests: tls: clean up uninitialized warnings
Date: Fri, 18 Jun 2021 23:02:42 +0100	[thread overview]
Message-ID: <b92c5196-2a8d-e2ea-2739-73f623d6af9b@novek.ru> (raw)
In-Reply-To: <20210618202504.1435179-1-kuba@kernel.org>

On 18.06.2021 21:25, Jakub Kicinski wrote:
> A bunch of tests uses uninitialized stack memory as random
> data to send. This is harmless but generates compiler warnings.
> Explicitly init the buffers with random data.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
>   tools/testing/selftests/net/tls.c | 20 ++++++++++++++++++++
>   1 file changed, 20 insertions(+)
> 
> diff --git a/tools/testing/selftests/net/tls.c b/tools/testing/selftests/net/tls.c
> index 426d07875a48..58fea6eb588d 100644
> --- a/tools/testing/selftests/net/tls.c
> +++ b/tools/testing/selftests/net/tls.c
> @@ -25,6 +25,18 @@
>   #define TLS_PAYLOAD_MAX_LEN 16384
>   #define SOL_TLS 282
>   
> +static void memrnd(void *s, size_t n)
> +{
> +	int *dword = s;
> +	char *byte;
> +
> +	for (; n >= 4; n -= 4)
> +		*dword++ = rand();
> +	byte = (void *)dword;
> +	while (n--)
> +		*byte++ = rand();
> +}
> +
>   FIXTURE(tls_basic)
>   {
>   	int fd, cfd;
> @@ -308,6 +320,8 @@ TEST_F(tls, recv_max)
>   	char recv_mem[TLS_PAYLOAD_MAX_LEN];
>   	char buf[TLS_PAYLOAD_MAX_LEN];
>   
> +	memrnd(buf, sizeof(buf));
> +
>   	EXPECT_GE(send(self->fd, buf, send_len, 0), 0);
>   	EXPECT_NE(recv(self->cfd, recv_mem, send_len, 0), -1);
>   	EXPECT_EQ(memcmp(buf, recv_mem, send_len), 0);
> @@ -588,6 +602,8 @@ TEST_F(tls, recvmsg_single_max)
>   	struct iovec vec;
>   	struct msghdr hdr;
>   
> +	memrnd(send_mem, sizeof(send_mem));
> +
>   	EXPECT_EQ(send(self->fd, send_mem, send_len, 0), send_len);
>   	vec.iov_base = (char *)recv_mem;
>   	vec.iov_len = TLS_PAYLOAD_MAX_LEN;
> @@ -610,6 +626,8 @@ TEST_F(tls, recvmsg_multiple)
>   	struct msghdr hdr;
>   	int i;
>   
> +	memrnd(buf, sizeof(buf));
> +
>   	EXPECT_EQ(send(self->fd, buf, send_len, 0), send_len);
>   	for (i = 0; i < msg_iovlen; i++) {
>   		iov_base[i] = (char *)malloc(iov_len);
> @@ -634,6 +652,8 @@ TEST_F(tls, single_send_multiple_recv)
>   	char send_mem[TLS_PAYLOAD_MAX_LEN * 2];
>   	char recv_mem[TLS_PAYLOAD_MAX_LEN * 2];
>   
> +	memrnd(send_mem, sizeof(send_mem));
> +
>   	EXPECT_GE(send(self->fd, send_mem, total_len, 0), 0);
>   	memset(recv_mem, 0, total_len);
>   
> 

Acked-by: Vadim Fedorenko <vfedorenko@novek.ru>


  parent reply	other threads:[~2021-06-18 22:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-18 20:25 [PATCH net 1/2] selftests: tls: clean up uninitialized warnings Jakub Kicinski
2021-06-18 20:25 ` [PATCH net 2/2] selftests: tls: fix chacha+bidir tests Jakub Kicinski
2021-06-18 22:03   ` Vadim Fedorenko
2021-06-18 22:02 ` Vadim Fedorenko [this message]
2021-06-21 19:20 ` [PATCH net 1/2] selftests: tls: clean up uninitialized warnings patchwork-bot+netdevbpf

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=b92c5196-2a8d-e2ea-2739-73f623d6af9b@novek.ru \
    --to=vfedorenko@novek.ru \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=shuah@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).