Skip to contentSkip to conversation

tpm: fix a sparse error in tpm-sysfs.c

PATCH In review Stefan Berger 2 participants 5 messages Jan 31, 2017 – Feb 1, 2017 TPM device driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tpm: fix a sparse error in tpm-sysfs.c

drivers/char/tpm/tpm-sysfs.c:161:25: warning: expression using sizeof bool

Fixes c659af78eb7b ("tpm: Check size of response before accessing data")
---
 drivers/char/tpm/tpm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm.h +1 -1
index bff37be..6b4e7aa 100644
@@ -281,7 +281,7 @@ struct permanent_flags_t {
 typedef union {
 	struct	permanent_flags_t perm_flags;
 	struct	stclear_flags_t	stclear_flags;
-	bool	owned;
+	__u8	owned;
 	__be32	num_pcrs;
 	struct	tpm_version_t	tpm_version;
 	struct	tpm_version_1_2_t tpm_version_1_2;
Signature · 6 lines
2.4.3


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
#1 lore raw
Quoted 23 lines · Stefan Berger

drivers/char/tpm/tpm-sysfs.c:161:25: warning: expression using sizeof bool

Fixes c659af78eb7b ("tpm: Check size of response before accessing data")
---
 drivers/char/tpm/tpm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm.h +1 -1
index bff37be..6b4e7aa 100644
@@ -281,7 +281,7 @@ struct permanent_flags_t {
 typedef union {
 	struct	permanent_flags_t perm_flags;
 	struct	stclear_flags_t	stclear_flags;
-	bool	owned;
+	__u8	owned;
 	__be32	num_pcrs;
 	struct	tpm_version_t	tpm_version;
 	struct	tpm_version_1_2_t tpm_version_1_2;
Signature · 1 line
2.4.3

A better description would be:

The field owned has wrong sized type. This commit fixes the issue.

?

/Jarkko

#2 lore raw
Quoted 27 lines · Jarkko Sakkinen
Quoted 23 lines · Stefan Berger

drivers/char/tpm/tpm-sysfs.c:161:25: warning: expression using sizeof bool

Fixes c659af78eb7b ("tpm: Check size of response before accessing data")
---
 drivers/char/tpm/tpm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm.h +1 -1
index bff37be..6b4e7aa 100644
@@ -281,7 +281,7 @@ struct permanent_flags_t {
 typedef union {
 	struct	permanent_flags_t perm_flags;
 	struct	stclear_flags_t	stclear_flags;
-	bool	owned;
+	__u8	owned;
 	__be32	num_pcrs;
 	struct	tpm_version_t	tpm_version;
 	struct	tpm_version_1_2_t tpm_version_1_2;
Signature · 1 line
2.4.3

A better description would be:

Quoted 6 lines

The field owned has wrong sized type. This commit fixes the issue.

?

/Jarkko

And doesn't owned print invalid results on a big endian system i.e. 0x1000000? The commit message needs to be rewritten to capture the problem.

/Jarkko

#3 lore raw
Quoted 31 lines · Jarkko Sakkinen
Quoted 30 lines · Jarkko Sakkinen
Quoted 23 lines · Stefan Berger

drivers/char/tpm/tpm-sysfs.c:161:25: warning: expression using sizeof bool

Fixes c659af78eb7b ("tpm: Check size of response before accessing data")
---
 drivers/char/tpm/tpm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm.h +1 -1
index bff37be..6b4e7aa 100644
@@ -281,7 +281,7 @@ struct permanent_flags_t {
 typedef union {
 	struct	permanent_flags_t perm_flags;
 	struct	stclear_flags_t	stclear_flags;
-	bool	owned;
+	__u8	owned;
 	__be32	num_pcrs;
 	struct	tpm_version_t	tpm_version;
 	struct	tpm_version_1_2_t tpm_version_1_2;
Signature · 1 line
2.4.3

A better description would be:

The field owned has wrong sized type. This commit fixes the issue.

Quoted 7 lines
Quoted 3 lines

?

/Jarkko

And doesn't owned print invalid results on a big endian system i.e. 0x1000000? The commit message needs to be rewritten to capture the problem.

Please ignore this, the conversion is done in tpm_getcap(). I'll update the commit message.

/Jarkko

#4 lore raw
Quoted 34 lines · Jarkko Sakkinen
Quoted 33 lines · Jarkko Sakkinen
Quoted 32 lines · Jarkko Sakkinen
Quoted 23 lines · Stefan Berger

drivers/char/tpm/tpm-sysfs.c:161:25: warning: expression using sizeof bool

Fixes c659af78eb7b ("tpm: Check size of response before accessing data")
---
 drivers/char/tpm/tpm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm.h +1 -1
index bff37be..6b4e7aa 100644
@@ -281,7 +281,7 @@ struct permanent_flags_t {
 typedef union {
 	struct	permanent_flags_t perm_flags;
 	struct	stclear_flags_t	stclear_flags;
-	bool	owned;
+	__u8	owned;
 	__be32	num_pcrs;
 	struct	tpm_version_t	tpm_version;
 	struct	tpm_version_1_2_t tpm_version_1_2;
Signature · 1 line
2.4.3

A better description would be:

The field owned has wrong sized type. This commit fixes the issue.

?

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

/Jarkko

And doesn't owned print invalid results on a big endian system i.e. 0x1000000? The commit message needs to be rewritten to capture the problem.

Please ignore this, the conversion is done in tpm_getcap(). I'll update the commit message.

Now I'm really tripping :( tpm_getcap() does not do any sort of conversion. _Bool in gcc is one byte. Sorry about this. This is purely a type error. The size is correct.

/Jarkko