git: ae76550171b9 - stable/13 - tty_info: Avoid warning by using logical instead of bitwise operators

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Fri, 11 Feb 2022 16:51:40 UTC
The branch stable/13 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=ae76550171b9b3f9aa322b741c59f1ae5f540a87

commit ae76550171b9b3f9aa322b741c59f1ae5f540a87
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2022-02-06 17:41:20 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2022-02-11 16:43:03 +0000

    tty_info: Avoid warning by using logical instead of bitwise operators
    
    Since TD_IS_RUNNING() and TS_ON_RUNQ() are defined as logical
    expressions involving '==', clang 14 warns about them being checked with
    a bitwise operator instead of a logical one:
    
    ```
    sys/kern/tty_info.c:124:9: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
            runa = TD_IS_RUNNING(td) | TD_ON_RUNQ(td);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                     ||
    sys/sys/proc.h:562:27: note: expanded from macro 'TD_IS_RUNNING'
                                    ^
    sys/kern/tty_info.c:124:9: note: cast one or both operands to int to silence this warning
    sys/sys/proc.h:562:27: note: expanded from macro 'TD_IS_RUNNING'
                                    ^
    sys/kern/tty_info.c:129:9: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
            runb = TD_IS_RUNNING(td2) | TD_ON_RUNQ(td2);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                      ||
    sys/sys/proc.h:562:27: note: expanded from macro 'TD_IS_RUNNING'
                                    ^
    sys/kern/tty_info.c:129:9: note: cast one or both operands to int to silence this warning
    sys/sys/proc.h:562:27: note: expanded from macro 'TD_IS_RUNNING'
                                    ^
    ```
    
    Fix this by using logical operators instead. No functional change
    intended.
    
    Reviewed by:    cem, emaste, kevans, markj
    MFC after:      3 days
    Differential Revision: https://reviews.freebsd.org/D34186
    
    (cherry picked from commit 7d8a4eb943a907a92dd400432c3c3adcbd93dad9)
---
 sys/kern/tty_info.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/kern/tty_info.c b/sys/kern/tty_info.c
index 4cf8be19ebda..60675557e4ed 100644
--- a/sys/kern/tty_info.c
+++ b/sys/kern/tty_info.c
@@ -121,12 +121,12 @@ thread_compare(struct thread *td, struct thread *td2)
 	 * Fetch running stats, pctcpu usage, and interruptable flag.
 	 */
 	thread_lock(td);
-	runa = TD_IS_RUNNING(td) | TD_ON_RUNQ(td);
+	runa = TD_IS_RUNNING(td) || TD_ON_RUNQ(td);
 	slpa = td->td_flags & TDF_SINTR;
 	esta = sched_pctcpu(td);
 	thread_unlock(td);
 	thread_lock(td2);
-	runb = TD_IS_RUNNING(td2) | TD_ON_RUNQ(td2);
+	runb = TD_IS_RUNNING(td2) || TD_ON_RUNQ(td2);
 	estb = sched_pctcpu(td2);
 	slpb = td2->td_flags & TDF_SINTR;
 	thread_unlock(td2);