Author: dim
Date: Sat Feb  1 17:02:26 2020
New Revision: 357367
URL: https://svnweb.freebsd.org/changeset/base/357367

Log:
  Fix new clang 10.0.0 warnings about converting the result of shift
  operations to a boolean in tpm(4):
  
    sys/dev/tpm/tpm_crb.c:301:32: error: converting the result of '<<' to a 
boolean; did you mean '(1 << (0)) != 0'? [-Werror,-Wint-in-bool-context]
          WR4(sc, TPM_CRB_CTRL_CANCEL, !TPM_CRB_CTRL_CANCEL_CMD);
                                        ^
    sys/dev/tpm/tpm_crb.c:73:34: note: expanded from macro 
'TPM_CRB_CTRL_CANCEL_CMD'
    #define TPM_CRB_CTRL_CANCEL_CMD         BIT(0)
                                          ^
    sys/dev/tpm/tpm20.h:60:19: note: expanded from macro 'BIT'
    #define BIT(x) (1 << (x))
                    ^
  
  In this case, the intent was to clear the zeroth bit, and leave the rest
  unaffected.  Therefore, the ~ operator should be used instead.
  
  Noticed by:   cem
  MFC after:    3 days

Modified:
  head/sys/dev/tpm/tpm_crb.c

Modified: head/sys/dev/tpm/tpm_crb.c
==============================================================================
--- head/sys/dev/tpm/tpm_crb.c  Sat Feb  1 16:57:04 2020        (r357366)
+++ head/sys/dev/tpm/tpm_crb.c  Sat Feb  1 17:02:26 2020        (r357367)
@@ -298,7 +298,7 @@ tpmcrb_cancel_cmd(struct tpm_sc *sc)
                return (false);
        }
 
-       WR4(sc, TPM_CRB_CTRL_CANCEL, !TPM_CRB_CTRL_CANCEL_CMD);
+       WR4(sc, TPM_CRB_CTRL_CANCEL, ~TPM_CRB_CTRL_CANCEL_CMD);
        return (true);
 }
 
@@ -330,7 +330,7 @@ tpmcrb_transmit(struct tpm_sc *sc, size_t length)
                return (EIO);
        }
        /* Clear cancellation bit */
-       WR4(sc, TPM_CRB_CTRL_CANCEL, !TPM_CRB_CTRL_CANCEL_CMD);
+       WR4(sc, TPM_CRB_CTRL_CANCEL, ~TPM_CRB_CTRL_CANCEL_CMD);
 
        /* Switch device to idle state if necessary */
        if (!(RD4(sc, TPM_CRB_CTRL_STS) & TPM_CRB_CTRL_STS_IDLE_BIT)) {
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to