All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KEYS: trusted: fix type warnings in ntohl/nthos
@ 2019-12-17 11:09 Ben Dooks (Codethink)
  2019-12-17 14:35   ` Jarkko Sakkinen
  2019-12-18 22:06   ` Jarkko Sakkinen
  0 siblings, 2 replies; 5+ messages in thread
From: Ben Dooks (Codethink) @ 2019-12-17 11:09 UTC (permalink / raw)
  To: ben.dooks; +Cc: David Howells, Jarkko Sakkinen, keyrings, linux-kernel

The ntohl takes a __be32 and ntohs takes __be16, so cast to
those types before passing it to the byte swapping functions.

Note, would be32_to_cpu and be16_to_cpu be better here?

security/keys/trusted-keys/trusted_tpm1.c:201:19: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:201:19: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:201:19: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:201:19: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:201:19: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:201:19: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:202:15: warning: cast to restricted __be16
security/keys/trusted-keys/trusted_tpm1.c:202:15: warning: cast to restricted __be16
security/keys/trusted-keys/trusted_tpm1.c:202:15: warning: cast to restricted __be16
security/keys/trusted-keys/trusted_tpm1.c:202:15: warning: cast to restricted __be16
security/keys/trusted-keys/trusted_tpm1.c:289:19: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:289:19: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:289:19: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:289:19: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:289:19: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:289:19: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:290:15: warning: cast to restricted __be16
security/keys/trusted-keys/trusted_tpm1.c:290:15: warning: cast to restricted __be16
security/keys/trusted-keys/trusted_tpm1.c:290:15: warning: cast to restricted __be16
security/keys/trusted-keys/trusted_tpm1.c:290:15: warning: cast to restricted __be16
security/keys/trusted-keys/trusted_tpm1.c:418:21: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:418:21: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:418:21: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:418:21: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:418:21: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:418:21: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:442:19: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:442:19: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:442:19: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:442:19: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:442:19: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:442:19: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:549:24: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:549:24: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:549:24: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:549:24: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:549:24: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:549:24: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:550:23: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:550:23: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:550:23: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:550:23: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:550:23: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:550:23: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:602:17: warning: incorrect type in assignment (different base types)
security/keys/trusted-keys/trusted_tpm1.c:602:17:    expected unsigned int [usertype] ordinal
security/keys/trusted-keys/trusted_tpm1.c:602:17:    got restricted __be32 [usertype]
security/keys/trusted-keys/trusted_tpm1.c:638:20: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:638:20: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:638:20: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:638:20: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:638:20: warning: cast to restricted __be32
security/keys/trusted-keys/trusted_tpm1.c:638:20: warning: cast to restricted __be32

Signed-off-by: Ben Dooks (Codethink) <ben.dooks@codethink.co.uk>
---
Cc: David Howells <dhowells@redhat.com>
Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: keyrings@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 include/keys/trusted_tpm.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/keys/trusted_tpm.h b/include/keys/trusted_tpm.h
index a56d8e1298f2..e080967931d2 100644
--- a/include/keys/trusted_tpm.h
+++ b/include/keys/trusted_tpm.h
@@ -12,9 +12,9 @@
 #define TPM_RETURN_OFFSET		6
 #define TPM_DATA_OFFSET			10
 
-#define LOAD32(buffer, offset)	(ntohl(*(uint32_t *)&buffer[offset]))
+#define LOAD32(buffer, offset)	(ntohl(*(__be32 *)&buffer[offset]))
 #define LOAD32N(buffer, offset)	(*(uint32_t *)&buffer[offset])
-#define LOAD16(buffer, offset)	(ntohs(*(uint16_t *)&buffer[offset]))
+#define LOAD16(buffer, offset)	(ntohs(*(__be16 *)&buffer[offset]))
 
 struct osapsess {
 	uint32_t handle;
-- 
2.24.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] KEYS: trusted: fix type warnings in ntohl/nthos
  2019-12-17 11:09 [PATCH] KEYS: trusted: fix type warnings in ntohl/nthos Ben Dooks (Codethink)
@ 2019-12-17 14:35   ` Jarkko Sakkinen
  2019-12-18 22:06   ` Jarkko Sakkinen
  1 sibling, 0 replies; 5+ messages in thread
From: Jarkko Sakkinen @ 2019-12-17 14:35 UTC (permalink / raw)
  To: Ben Dooks (Codethink); +Cc: David Howells, keyrings, linux-kernel

On Tue, 2019-12-17 at 11:09 +0000, Ben Dooks (Codethink) wrote:
> The ntohl takes a __be32 and ntohs takes __be16, so cast to
> those types before passing it to the byte swapping functions.

Thanks!

> Note, would be32_to_cpu and be16_to_cpu be better here?

Yes, I think that should work too.

/Jarkko

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] KEYS: trusted: fix type warnings in ntohl/nthos
@ 2019-12-17 14:35   ` Jarkko Sakkinen
  0 siblings, 0 replies; 5+ messages in thread
From: Jarkko Sakkinen @ 2019-12-17 14:35 UTC (permalink / raw)
  To: Ben Dooks (Codethink); +Cc: David Howells, keyrings, linux-kernel

On Tue, 2019-12-17 at 11:09 +0000, Ben Dooks (Codethink) wrote:
> The ntohl takes a __be32 and ntohs takes __be16, so cast to
> those types before passing it to the byte swapping functions.

Thanks!

> Note, would be32_to_cpu and be16_to_cpu be better here?

Yes, I think that should work too.

/Jarkko


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] KEYS: trusted: fix type warnings in ntohl/nthos
  2019-12-17 11:09 [PATCH] KEYS: trusted: fix type warnings in ntohl/nthos Ben Dooks (Codethink)
@ 2019-12-18 22:06   ` Jarkko Sakkinen
  2019-12-18 22:06   ` Jarkko Sakkinen
  1 sibling, 0 replies; 5+ messages in thread
From: Jarkko Sakkinen @ 2019-12-18 22:06 UTC (permalink / raw)
  To: Ben Dooks (Codethink); +Cc: David Howells, keyrings, linux-kernel

On Tue, 2019-12-17 at 11:09 +0000, Ben Dooks (Codethink) wrote:
> The ntohl takes a __be32 and ntohs takes __be16, so cast to
> those types before passing it to the byte swapping functions.
> 
> Note, would be32_to_cpu and be16_to_cpu be better here?

Yes, can you refine this?

Also in commit message you could

"
E.g.

security/keys/trusted-keys/trusted_tpm1.c:201:19: warning: cast to restricted __be32
"

We get the idea from one line :-)

/Jarkko

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] KEYS: trusted: fix type warnings in ntohl/nthos
@ 2019-12-18 22:06   ` Jarkko Sakkinen
  0 siblings, 0 replies; 5+ messages in thread
From: Jarkko Sakkinen @ 2019-12-18 22:06 UTC (permalink / raw)
  To: Ben Dooks (Codethink); +Cc: David Howells, keyrings, linux-kernel

On Tue, 2019-12-17 at 11:09 +0000, Ben Dooks (Codethink) wrote:
> The ntohl takes a __be32 and ntohs takes __be16, so cast to
> those types before passing it to the byte swapping functions.
> 
> Note, would be32_to_cpu and be16_to_cpu be better here?

Yes, can you refine this?

Also in commit message you could

"
E.g.

security/keys/trusted-keys/trusted_tpm1.c:201:19: warning: cast to restricted __be32
"

We get the idea from one line :-)

/Jarkko


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-12-18 22:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-17 11:09 [PATCH] KEYS: trusted: fix type warnings in ntohl/nthos Ben Dooks (Codethink)
2019-12-17 14:35 ` Jarkko Sakkinen
2019-12-17 14:35   ` Jarkko Sakkinen
2019-12-18 22:06 ` Jarkko Sakkinen
2019-12-18 22:06   ` Jarkko Sakkinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.