public inbox for dtrace@lists.linux.dev
 help / color / mirror / Atom feed
From: Kris Van Hees <kris.van.hees@oracle.com>
To: Alan Maguire <alan.maguire@oracle.com>
Cc: dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: Re: [DTrace-devel] [PATCH v4 3/7] test/operators: extend ternary tests to cover inet_ntoa*()s
Date: Mon, 21 Jul 2025 15:59:29 -0400	[thread overview]
Message-ID: <aH6cIasiadAbfePV@oracle.com> (raw)
In-Reply-To: <20250709144700.20591-4-alan.maguire@oracle.com>

On Wed, Jul 09, 2025 at 03:46:56PM +0100, Alan Maguire via DTrace-devel wrote:
> inet_ntoa*() require temporary strings and ternary operators
> need temporaries for left and right; ensure ternary ops succeed
> with inet_ntoa*()s.
> 
> Suggested-by: Eugene Loh <eugene.loh@oracle.com>
> Signed-off-by: Alan Maguire <alan.maguire@oracle.com>

Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>

> ---
>  test/unittest/operators/tst.ternary.d | 20 +++++++++++++++++++-
>  test/unittest/operators/tst.ternary.r |  2 ++
>  2 files changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/test/unittest/operators/tst.ternary.d b/test/unittest/operators/tst.ternary.d
> index 9d47fcc2..aeced7ac 100644
> --- a/test/unittest/operators/tst.ternary.d
> +++ b/test/unittest/operators/tst.ternary.d
> @@ -8,7 +8,10 @@
>  /*
>   * ASSERTION:
>   *  Test the ternary operator.  Test left-hand side true, right-hand side true,
> - *  and multiple nested instances of the ternary operator.
> + *  and multiple nested instances of the ternary operator.  Since inet_ntoa*()
> + *  relies on temporary strings, and ternary operators need both left- and
> + *  right-side temporaries, test ternary inet_ntoa*() also.
> + *
>   *
>   * SECTION:  Types, Operators, and Expressions/Conditional Expressions
>   */
> @@ -18,10 +21,25 @@
>  BEGIN
>  {
>  	x = 0;
> +	y = 1;
>  	printf("x is %s\n", x == 0 ? "zero" : "one");
>  	x = 1;
>  	printf("x is %s\n", x == 0 ? "zero" : "one");
>  	x = 2;
>  	printf("x is %s\n", x == 0 ? "zero" : x == 1 ? "one" : "two");
> +	ipaddr = (ipaddr_t *)alloca(sizeof(ipaddr_t));
> +	ipaddr2 = (in6_addr_t *)alloca(sizeof(in6_addr_t));
> +	ipaddr2->in6_u.u6_addr32[0] = 0xffffffff;
> +	ipaddr2->in6_u.u6_addr32[1] = 0xffffffff;
> +	ipaddr2->in6_u.u6_addr32[2] = 0xffffffff;
> +	ipaddr2->in6_u.u6_addr32[3] = 0xffffffff;
> +	printf("ipaddr is %s\n", x > 1 ? inet_ntoa(ipaddr) :
> +				 x > 2 ? inet_ntoa(ipaddr) :
> +				 x > 3 ? inet_ntoa(ipaddr) :
> +				 inet_ntoa(ipaddr));
> +	printf("ipaddr2 is %s\n", x > 1 ? inet_ntoa6(ipaddr2) :
> +				  x > 2 ? inet_ntoa6(ipaddr2) :
> +				  x > 3 ? inet_ntoa6(ipaddr2) :
> +				  inet_ntoa6(ipaddr2));
>  	exit(0);
>  }
> diff --git a/test/unittest/operators/tst.ternary.r b/test/unittest/operators/tst.ternary.r
> index ec30800e..72201682 100644
> --- a/test/unittest/operators/tst.ternary.r
> +++ b/test/unittest/operators/tst.ternary.r
> @@ -1,4 +1,6 @@
>  x is zero
>  x is one
>  x is two
> +ipaddr is 0.0.0.0
> +ipaddr2 is ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
>  
> -- 
> 2.39.3
> 
> 
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel@oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel

  reply	other threads:[~2025-07-21 19:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-09 14:46 [PATCH v4 0/7] DTrace TCP provider Alan Maguire
2025-07-09 14:46 ` [PATCH v4 1/7] cg: move get_member() to dt_cg.c Alan Maguire
2025-07-09 16:28   ` [DTrace-devel] " Kris Van Hees
2025-07-09 16:47     ` Kris Van Hees
2025-07-09 19:47       ` Alan Maguire
2025-07-09 14:46 ` [PATCH v4 2/7] cg: bump number of TSLOTS to 6 Alan Maguire
2025-07-10  4:46   ` [DTrace-devel] " Kris Van Hees
2025-07-09 14:46 ` [PATCH v4 3/7] test/operators: extend ternary tests to cover inet_ntoa*()s Alan Maguire
2025-07-21 19:59   ` Kris Van Hees [this message]
2025-07-09 14:46 ` [PATCH v4 4/7] providers: move network-generic definitions to net.d Alan Maguire
2025-07-21 20:24   ` [DTrace-devel] " Kris Van Hees
2025-07-09 14:46 ` [PATCH v4 5/7] tcp: new provider Alan Maguire
2025-07-09 14:46 ` [PATCH v4 6/7] dlibs: sync ip.d, net.d and tcp.d Alan Maguire
2025-07-21 22:27   ` [DTrace-devel] " Kris Van Hees
2025-07-09 14:47 ` [PATCH v4 7/7] unittest/tcp: update test.x Alan Maguire
2025-07-21 22:36   ` [DTrace-devel] " Kris Van Hees

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=aH6cIasiadAbfePV@oracle.com \
    --to=kris.van.hees@oracle.com \
    --cc=alan.maguire@oracle.com \
    --cc=dtrace-devel@oss.oracle.com \
    --cc=dtrace@lists.linux.dev \
    /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