[RFC] Remove redundant clause in condition

Dmitry V. Levin ldv at strace.io
Thu Jan 25 07:52:57 UTC 2024


Hi,

On Thu, Jan 25, 2024 at 12:54:46PM +0530, Sahil Siddiq wrote:
> output_separately is redundant in the third expression
> as it's already evaluated in the second expression.
> 
> * src/strace.c (init): Remove redundancy in condition.
> 
> Signed-off-by: Sahil Siddiq <icegambit91 at gmail.com>
> ---
> Hi,
> 
> I was going through strace's source and I came across this
> boolean.
> 
> 	print_pid_pfx = outfname && !output_separately &&
> 		((followfork && !output_separately) || nprocs > 1);
> 
> Since "output_separately" will be evaluated in the second
> expression, I haven't understood why it's being rechecked
> in the third expression with "followfork".
> 
> I thought I would send in a patch as well if this change
> is valid.
> 
> Thanks,
> Sahil
> 
>  src/strace.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/strace.c b/src/strace.c
> index 9aa0eda11..d025a32c2 100644
> --- a/src/strace.c
> +++ b/src/strace.c
> @@ -3021,7 +3021,7 @@ init(int argc, char *argv[])
>  	 * -p PID1,PID2: yes (there are already more than one pid)
>  	 */
>  	print_pid_pfx = outfname && !output_separately &&
> -		((followfork && !output_separately) || nprocs > 1);
> +		(followfork || nprocs > 1);

Good catch.
I think the following "Complements" tag could be added to the commit message:

Complements: v5.6~169 "strace: add a long option aliases for -f and -ff"


-- 
ldv


More information about the Strace-devel mailing list