Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Feb 2020 17:02:26 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r357367 - head/sys/dev/tpm
Message-ID:  <202002011702.011H2Qho026529@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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)) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002011702.011H2Qho026529>