[v11,15/16] eal: use standard ternary operator instead of GCC extension

Message ID 1691781658-32520-16-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series msvc integration changes |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Tyler Retzlaff Aug. 11, 2023, 7:20 p.m. UTC
  Use standard ternary operator instead of gcc extension. There is
no concern of side-effects for this evaluation so allow the code
to be portable.

While here update the condition to compare default_log_stream
directly against NULL.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/eal/common/eal_common_hexdump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Morten Brørup Sept. 25, 2023, 6:25 a.m. UTC | #1
> From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com]
> Sent: Friday, 11 August 2023 21.21
> 
> Use standard ternary operator instead of gcc extension. There is
> no concern of side-effects for this evaluation so allow the code
> to be portable.
> 
> While here update the condition to compare default_log_stream
> directly against NULL.
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
>  lib/eal/common/eal_common_hexdump.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/eal/common/eal_common_hexdump.c
> b/lib/eal/common/eal_common_hexdump.c
> index 63bbbdc..6fd6e21 100644
> --- a/lib/eal/common/eal_common_hexdump.c
> +++ b/lib/eal/common/eal_common_hexdump.c
> @@ -15,7 +15,7 @@
>  	char line[LINE_LEN];	/* space needed 8+16*3+3+16 == 75 */
> 
>  	fprintf(f, "%s at [%p], len=%u\n",
> -		title ? : "  Dump data", data, len);
> +		title != NULL ? title : "  Dump data", data, len);
>  	ofs = 0;
>  	while (ofs < len) {
>  		/* format the line in the buffer */
> --
> 1.8.3.1

Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
  

Patch

diff --git a/lib/eal/common/eal_common_hexdump.c b/lib/eal/common/eal_common_hexdump.c
index 63bbbdc..6fd6e21 100644
--- a/lib/eal/common/eal_common_hexdump.c
+++ b/lib/eal/common/eal_common_hexdump.c
@@ -15,7 +15,7 @@ 
 	char line[LINE_LEN];	/* space needed 8+16*3+3+16 == 75 */
 
 	fprintf(f, "%s at [%p], len=%u\n",
-		title ? : "  Dump data", data, len);
+		title != NULL ? title : "  Dump data", data, len);
 	ofs = 0;
 	while (ofs < len) {
 		/* format the line in the buffer */