tpm: fix a sparse error in tpm-interface.c
PATCH 1/1 tpm: fix a sparse error in tpm-interface.c
drivers/char/tpm//tpm-interface.c:492:42: warning: bad assignment (-=) to restricted __be32
--- drivers/char/tpm/tpm-interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm-interface.c +1 -1
@@ -489,7 +489,7 @@ ssize_t tpm_getcap(struct tpm_chip *chip, u32 subcap_id, cap_t *cap, tpm_cmd.params.getcap_in.cap =cpu_to_be32 (subcap_id);/*subcap field not necessary */ tpm_cmd.params.getcap_in.subcap_size =cpu_to_be32 (0 ); - tpm_cmd.header.in.length -=cpu_to_be32 (sizeof (__be32)); + tpm_cmd.header.in.length =cpu_to_be32 (18 ); }else {if (subcap_id ==TPM_CAP_FLAG_PERM || subcap_id ==TPM_CAP_FLAG_VOL )
Signature · 6 lines
2.9.3 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot
Quoted 24 lines · Jarkko Sakkinen
drivers/char/tpm//tpm-interface.c:492:42: warning: bad assignment ( -=)
to restricted__be32Fixes 0883743825e3 ("TPM: sysfs functions consolidation")--- drivers/char/tpm/tpm-interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/char/tpm/tpm renamed from drivers/char/tpm/tpm-interface.c +0
-1-interface.cindex 423938e..746bc54 100644
drivers/char/tpm/tpm-interface.c +0
-1@@ -489,7 +489,7 @@ ssize_t tpm_getcap(struct tpm_chip *chip, u32 subcap_id, cap_t *cap, tpm_cmd.params.getcap_in.cap =cpu_to_be32 (subcap_id);/*subcap field not necessary */ tpm_cmd.params.getcap_in.subcap_size =cpu_to_be32 (0 ); - tpm_cmd.header.in.length -=cpu_to_be32(sizeof(__be32));
drivers/char/tpm/tpm-interface.c ssize_t tpm_getcap(struct tpm_chip *chip, u32 subcap_id, cap_t *cap, · line 492
Quoted 1 line
drivers/char/tpm/tpm-interface.c +1
-0+ tpm_cmd.header.in.length =cpu_to_be32 (18 );
using bare numbers here without comment isn't really best practice.
What about setting header.in.length in both legs of the if() to either
tpm_cmd.header.in.length = cpu_to_be32(HEADER_SIZE + sizeof(struct tpm_getcap_params_in))
or
/* setting subcap_size to zero allows us to elimnate the subcap field */
tpm_cmd.header.in.length = cpu_to_be32(HEADER_SIZE + sizeof(struct tpm_getcap_params_in) - sizeof(tpm_cmd.params.getcap_in.subcap))
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot
Quoted 30 lines · James Bottomley
Quoted 24 lines · Jarkko Sakkinen
drivers/char/tpm//tpm-interface.c:492:42: warning: bad assignment ( -=)
to restricted__be32Fixes 0883743825e3 ("TPM: sysfs functions consolidation")--- drivers/char/tpm/tpm-interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/char/tpm/tpm renamed from drivers/char/tpm/tpm-interface.c +0
-1-interface.cindex 423938e..746bc54 100644
drivers/char/tpm/tpm-interface.c +0
-1@@ -489,7 +489,7 @@ ssize_t tpm_getcap(struct tpm_chip *chip, u32 subcap_id, cap_t *cap, tpm_cmd.params.getcap_in.cap =cpu_to_be32 (subcap_id);/*subcap field not necessary */ tpm_cmd.params.getcap_in.subcap_size =cpu_to_be32 (0 ); - tpm_cmd.header.in.length -=cpu_to_be32(sizeof(__be32));
drivers/char/tpm/tpm-interface.c ssize_t tpm_getcap(struct tpm_chip *chip, u32 subcap_id, cap_t *cap, · line 492
Quoted 1 line
drivers/char/tpm/tpm-interface.c +1
-0+ tpm_cmd.header.in.length =cpu_to_be32 (18 );using bare numbers here without comment isn't really best practice.
What about setting header.in.length in both legs of theif()to either
Quoted 6 lines
tpm_cmd.header.in.length =
cpu_to_be32(HEADER_SIZE + sizeof(struct tpm_getcap_params_in))or
/* setting
subcap_sizeto zero allows us to elimnate the subcap field */
tpm_cmd.header.in.length =cpu_to_be32(HEADER_SIZE + sizeof(struct tpm_getcap_params_in) - sizeof(tpm_cmd.params.getcap_in.subcap))
Yeah, also the commit message should be updated rather than referring to the static checking tool. I'll update the commit along the lines you proposed...
/Jarkko
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot