staging: wimax/i2400m: fix some byte order issues found by sparse
PATCH 1/1 staging: wimax/i2400m: fix some byte order issues found by sparse
Fix sparse byte-order warnings in the i2400m_bm_cmd_prepare() function:
wimax/i2400m/fw.c:194:36: warning: restricted __le32 degrades to integer wimax/i2400m/fw.c:195:34: warning: invalid assignment: +=wimax/i2400m/fw.c:195:34: left side has type unsigned intwimax/i2400m/fw.c:195:34: right side has type restricted __le32wimax/i2400m/fw.c:196:32: warning: restricted __le32 degrades to integer wimax/i2400m/fw.c:196:47: warning: restricted __le32 degrades to integer wimax/i2400m/fw.c:196:66: warning: restricted __le32 degrades to integer
--- drivers/staging/wimax/i2400m/fw.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/staging/wimax/i2400m/fw.c +9 -5
@@ -189,12 +189,16 @@ void i2400m_bm_cmd_prepare(struct i2400m_bootrom_header *cmd) {if (i2400m_brh_get_use_checksum (cmd)) {int i; -u32 checksum =0 ; +__le32 checksum =0 ;const u32 *checksum_ptr = (void *) cmd->payload; -for (i =0 ; i < cmd->data_size /4 ; i++) - checksum +=cpu_to_le32 (*checksum_ptr++); - checksum += cmd->command + cmd->target_addr + cmd->data_size; - cmd->block_checksum =cpu_to_le32 (checksum); +for (i =0 ; i <le32_to_cpu (cmd->data_size) /4 ; i++) +le32_add_cpu (&checksum, *checksum_ptr++); + +le32_add_cpu (&checksum,le32_to_cpu (cmd->command)); +le32_add_cpu (&checksum,le32_to_cpu (cmd->target_addr)); +le32_add_cpu (&checksum,le32_to_cpu (cmd->data_size)); + + cmd->block_checksum = checksum; } }EXPORT_SYMBOL_GPL (i2400m_bm_cmd_prepare);
Signature · 1 line
2.26.2
Greg KH
maintainerQuoted 21 lines · Anirudh Rayabharam
Fix sparse byte-order warnings in the
i2400m_bm_cmd_prepare()function:
wimax/i2400m/fw.c:194:36: warning: restricted__le32degrades to integerwimax/i2400m/fw.c:195:34: warning: invalid assignment: +=wimax/i2400m/fw.c:195:34: left side has type unsigned intwimax/i2400m/fw.c:195:34: right side has type restricted__le32wimax/i2400m/fw.c:196:32: warning: restricted__le32degrades to integerwimax/i2400m/fw.c:196:47: warning: restricted__le32degrades to integerwimax/i2400m/fw.c:196:66: warning: restricted__le32degrades to integerSigned-off-by Anirudh Rayabharam <[email protected]>--- drivers/staging/wimax/i2400m/fw.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)drivers/staging/wimax/i2400m/fw.c +0
-0
drivers/staging/wimax/i2400m/fw.c void i2400m_bm_cmd_prepare(struct i2400m_bootrom_header *cmd) · line 192
Quoted 5 lines
drivers/staging/wimax/i2400m/fw.c +1
-1@@ -189,12 +189,16 @@ void i2400m_bm_cmd_prepare(struct i2400m_bootrom_header *cmd) {if (i2400m_brh_get_use_checksum (cmd)) {int i; -u32 checksum =0 ; +__le32 checksum =0 ;
__le32 is only for when the data crosses the kernel/user boundry, just use le32 in the kernel for stuff like this.
drivers/staging/wimax/i2400m/fw.c void i2400m_bm_cmd_prepare(struct i2400m_bootrom_header *cmd) · line 193
Quoted 1 line
drivers/staging/wimax/i2400m/fw.c +0
-0const u32 *checksum_ptr = (void *) cmd->payload;
Add a blank line here, right?
thanks,
greg k-h
Quoted 17 lines · Greg KH
Quoted 16 lines · Anirudh Rayabharam
Fix sparse byte-order warnings in the
i2400m_bm_cmd_prepare()function:
wimax/i2400m/fw.c:194:36: warning: restricted__le32degrades to integerwimax/i2400m/fw.c:195:34: warning: invalid assignment: +=wimax/i2400m/fw.c:195:34: left side has type unsigned intwimax/i2400m/fw.c:195:34: right side has type restricted__le32wimax/i2400m/fw.c:196:32: warning: restricted__le32degrades to integerwimax/i2400m/fw.c:196:47: warning: restricted__le32degrades to integerwimax/i2400m/fw.c:196:66: warning: restricted__le32degrades to integerSigned-off-by Anirudh Rayabharam <[email protected]>--- drivers/staging/wimax/i2400m/fw.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
Quoted 14 lines
drivers/staging/wimax/i2400m/fw.c void i2400m_bm_cmd_prepare(struct i2400m_bootrom_header *cmd) · line 192
Quoted 10 lines
drivers/staging/wimax/i2400m/fw.c +1
-1@@ -189,12 +189,16 @@ void i2400m_bm_cmd_prepare(struct i2400m_bootrom_header *cmd) {if (i2400m_brh_get_use_checksum (cmd)) {int i; -u32 checksum =0 ; +__le32 checksum =0 ;
__le32is only for when the data crosses the kernel/user boundry, just use le32 in the kernel for stuff like this.
But that throws a compile error. Also, I don't see le32 defined in any common header. It is defined in fs/ntfs/types.h but that's not accessible here.
Quoted 3 lines
drivers/staging/wimax/i2400m/fw.c void i2400m_bm_cmd_prepare(struct i2400m_bootrom_header *cmd) · line 193
Quoted 1 line
drivers/staging/wimax/i2400m/fw.c +0
-0const u32 *checksum_ptr = (void *) cmd->payload;Add a blank line here, right?
It wasn't there before but makes sense. I'll send v2 with this change.
Thanks!
- Anirudh.
Greg KH
maintainerQuoted 32 lines · Anirudh Rayabharam
Quoted 17 lines · Greg KH
Quoted 16 lines · Anirudh Rayabharam
Fix sparse byte-order warnings in the
i2400m_bm_cmd_prepare()function:
wimax/i2400m/fw.c:194:36: warning: restricted__le32degrades to integerwimax/i2400m/fw.c:195:34: warning: invalid assignment: +=wimax/i2400m/fw.c:195:34: left side has type unsigned intwimax/i2400m/fw.c:195:34: right side has type restricted__le32wimax/i2400m/fw.c:196:32: warning: restricted__le32degrades to integerwimax/i2400m/fw.c:196:47: warning: restricted__le32degrades to integerwimax/i2400m/fw.c:196:66: warning: restricted__le32degrades to integerSigned-off-by Anirudh Rayabharam <[email protected]>--- drivers/staging/wimax/i2400m/fw.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)Quoted 14 lines
drivers/staging/wimax/i2400m/fw.c void i2400m_bm_cmd_prepare(struct i2400m_bootrom_header *cmd) · line 192
Quoted 10 lines
drivers/staging/wimax/i2400m/fw.c +1
-1@@ -189,12 +189,16 @@ void i2400m_bm_cmd_prepare(struct i2400m_bootrom_header *cmd) {if (i2400m_brh_get_use_checksum (cmd)) {int i; -u32 checksum =0 ; +__le32 checksum =0 ;
__le32is only for when the data crosses the kernel/user boundry, just use le32 in the kernel for stuff like this.
Quoted 1 line
But that throws a compile error.
What error?
Quoted 3 lines
Also, I don't see le32 defined
in any common header. It is defined infs/ntfs/types.hbut that's not accessible here.
Ah, my fault, you are right, nevermind.
Quoted 4 lines
Quoted 3 lines
drivers/staging/wimax/i2400m/fw.c void i2400m_bm_cmd_prepare(struct i2400m_bootrom_header *cmd) · line 193
Quoted 1 line
drivers/staging/wimax/i2400m/fw.c +0
-0const u32 *checksum_ptr = (void *) cmd->payload;Add a blank line here, right?
It wasn't there before but makes sense. I'll send v2 with this change.
Thanks.
greg k-h
Quoted 33 lines · Greg KH
Quoted 32 lines · Anirudh Rayabharam
Quoted 31 lines · Greg KH
Quoted 21 lines · Anirudh Rayabharam
Fix sparse byte-order warnings in the
i2400m_bm_cmd_prepare()function:
wimax/i2400m/fw.c:194:36: warning: restricted__le32degrades to integerwimax/i2400m/fw.c:195:34: warning: invalid assignment: +=wimax/i2400m/fw.c:195:34: left side has type unsigned intwimax/i2400m/fw.c:195:34: right side has type restricted__le32wimax/i2400m/fw.c:196:32: warning: restricted__le32degrades to integerwimax/i2400m/fw.c:196:47: warning: restricted__le32degrades to integerwimax/i2400m/fw.c:196:66: warning: restricted__le32degrades to integerSigned-off-by Anirudh Rayabharam <[email protected]>--- drivers/staging/wimax/i2400m/fw.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)drivers/staging/wimax/i2400m/fw.c +0
-0drivers/staging/wimax/i2400m/fw.c void i2400m_bm_cmd_prepare(struct i2400m_bootrom_header *cmd) · line 192
Quoted 5 lines
drivers/staging/wimax/i2400m/fw.c +1
-1@@ -189,12 +189,16 @@ void i2400m_bm_cmd_prepare(struct i2400m_bootrom_header *cmd) {if (i2400m_brh_get_use_checksum (cmd)) {int i; -u32 checksum =0 ; +__le32 checksum =0 ;
__le32is only for when the data crosses the kernel/user boundry, just use le32 in the kernel for stuff like this.
Quoted 3 lines
Quoted 1 line
But that throws a compile error.
What error?
drivers/staging/wimax/i2400m/fw.c:192:3: error: unknown type name ‘le32’; did you mean ‘__le32’?
- Anirudh