* [PATCH 0/3] staging: rtl8723au: fix/clean up two functions
@ 2015-06-30 21:52 Michel von Czettritz
2015-06-30 21:53 ` [PATCH 1/3] staging: rtl8723au: adjust function param, u8* to u32* Michel von Czettritz
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Michel von Czettritz @ 2015-06-30 21:52 UTC (permalink / raw)
To: gregkh; +Cc: Jes.Sorensen, Larry.Finger, devel, linux-wireless
Initialy fixing a sparse warning, resulted in 3 small patches cleaning
rtl8723a_set_rssi_cmd an rtl8723a_set_raid_cmd up a bit.
Both functions now avoid implicit casts, return actual values, and
rtl8723a_set_rssi_cmd cannot write in unallocated memory any more.
Michel von Czettritz (3):
staging: rtl8723au: adjust function param, u8* to u32*
staging: rtl8723au: fix "incorrect type in assignment"
staging: rtl8723au: function no longer discards return value
drivers/staging/rtl8723au/hal/odm.c | 2 +-
drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 18 ++++++++----------
drivers/staging/rtl8723au/include/rtl8723a_cmd.h | 2 +-
3 files changed, 10 insertions(+), 12 deletions(-)
--
2.4.5
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/3] staging: rtl8723au: adjust function param, u8* to u32*
2015-06-30 21:52 [PATCH 0/3] staging: rtl8723au: fix/clean up two functions Michel von Czettritz
@ 2015-06-30 21:53 ` Michel von Czettritz
2015-06-30 21:54 ` [PATCH 2/3] staging: rtl8723au: fix "incorrect type in assignment" Michel von Czettritz
2015-06-30 21:54 ` [PATCH 3/3] staging: rtl8723au: function no longer discards return value Michel von Czettritz
2 siblings, 0 replies; 14+ messages in thread
From: Michel von Czettritz @ 2015-06-30 21:53 UTC (permalink / raw)
To: gregkh; +Cc: Jes.Sorensen, Larry.Finger, devel, linux-wireless
If u8 *param, in the function rtl8723a_set_rssi_cmd, is only 3 Byte long
the 4th Byte of cpu_to_le32 will be written in unallocated memory.
Change the function variable to u32*, so the problem can not
occur.
rtl8723a_set_rssi_cmd currently is only called in hal/odm.c and is
called with u32* as param. rtl8723a_set_rssi_cmd is never used as a
function pointer, nor does it seem to conform to any API.
Signed-off-by: Michel von Czettritz <michel.von.czettritz@gmail.com>
---
drivers/staging/rtl8723au/hal/odm.c | 2 +-
drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 6 +++---
drivers/staging/rtl8723au/include/rtl8723a_cmd.h | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/rtl8723au/hal/odm.c b/drivers/staging/rtl8723au/hal/odm.c
index f354f5e..5cbf8b6 100644
--- a/drivers/staging/rtl8723au/hal/odm.c
+++ b/drivers/staging/rtl8723au/hal/odm.c
@@ -1274,7 +1274,7 @@ static void odm_RSSIMonitorCheck(struct dm_odm_t *pDM_Odm)
for (i = 0; i < sta_cnt; i++) {
if (PWDB_rssi[i] != (0))
- rtl8723a_set_rssi_cmd(Adapter, (u8 *)&PWDB_rssi[i]);
+ rtl8723a_set_rssi_cmd(Adapter, &PWDB_rssi[i]);
}
pdmpriv->EntryMaxUndecoratedSmoothedPWDB = MaxDB;
diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
index 9733aa6..1003365 100644
--- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
+++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
@@ -113,11 +113,11 @@ exit:
return ret;
}
-int rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u8 *param)
+int rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u32 *param)
{
- *((u32 *)param) = cpu_to_le32(*((u32 *)param));
+ *((u32 *)param) = cpu_to_le32(*(param));
- FillH2CCmd(padapter, RSSI_SETTING_EID, 3, param);
+ FillH2CCmd(padapter, RSSI_SETTING_EID, 3, (u8 *)param);
return _SUCCESS;
}
diff --git a/drivers/staging/rtl8723au/include/rtl8723a_cmd.h b/drivers/staging/rtl8723au/include/rtl8723a_cmd.h
index 014c02e..e39e38a 100644
--- a/drivers/staging/rtl8723au/include/rtl8723a_cmd.h
+++ b/drivers/staging/rtl8723au/include/rtl8723a_cmd.h
@@ -149,7 +149,7 @@ void rtl8723a_set_BTCoex_AP_mode_FwRsvdPkt_cmd(struct rtw_adapter *padapter);
#else
#define rtl8723a_set_BTCoex_AP_mode_FwRsvdPkt_cmd(padapter) do {} while(0)
#endif
-int rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u8 *param);
+int rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u32 *param);
int rtl8723a_set_raid_cmd(struct rtw_adapter *padapter, u32 mask, u8 arg);
void rtl8723a_add_rateatid(struct rtw_adapter *padapter, u32 bitmap, u8 arg, u8 rssi_level);
--
2.4.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/3] staging: rtl8723au: fix "incorrect type in assignment"
2015-06-30 21:52 [PATCH 0/3] staging: rtl8723au: fix/clean up two functions Michel von Czettritz
2015-06-30 21:53 ` [PATCH 1/3] staging: rtl8723au: adjust function param, u8* to u32* Michel von Czettritz
@ 2015-06-30 21:54 ` Michel von Czettritz
2015-07-01 7:06 ` Sudip Mukherjee
` (2 more replies)
2015-06-30 21:54 ` [PATCH 3/3] staging: rtl8723au: function no longer discards return value Michel von Czettritz
2 siblings, 3 replies; 14+ messages in thread
From: Michel von Czettritz @ 2015-06-30 21:54 UTC (permalink / raw)
To: gregkh; +Cc: Jes.Sorensen, Larry.Finger, devel, linux-wireless
Writing the output of cpu_to_le32 to an u32 or *(u32*) is an implicit
cast and results in an sparse warning.
Since param and mask won't be changed, the implicit cast can be avoided
by creating local variables.
Signed-off-by: Michel von Czettritz <michel.von.czettritz@gmail.com>
---
drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
index 1003365..a5e6726 100644
--- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
+++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
@@ -115,9 +115,10 @@ exit:
int rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u32 *param)
{
- *((u32 *)param) = cpu_to_le32(*(param));
+ __le32 param_le;
+ param_le = cpu_to_le32(*(param));
- FillH2CCmd(padapter, RSSI_SETTING_EID, 3, (u8 *)param);
+ FillH2CCmd(padapter, RSSI_SETTING_EID, 3, (u8 *)¶m_le);
return _SUCCESS;
}
@@ -125,10 +126,11 @@ int rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u32 *param)
int rtl8723a_set_raid_cmd(struct rtw_adapter *padapter, u32 mask, u8 arg)
{
u8 buf[5];
+ __le32 mask_le;
memset(buf, 0, 5);
- mask = cpu_to_le32(mask);
- memcpy(buf, &mask, 4);
+ mask_le = cpu_to_le32(mask);
+ memcpy(buf, &mask_le, 4);
buf[4] = arg;
FillH2CCmd(padapter, MACID_CONFIG_EID, 5, buf);
--
2.4.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 3/3] staging: rtl8723au: function no longer discards return value
2015-06-30 21:52 [PATCH 0/3] staging: rtl8723au: fix/clean up two functions Michel von Czettritz
2015-06-30 21:53 ` [PATCH 1/3] staging: rtl8723au: adjust function param, u8* to u32* Michel von Czettritz
2015-06-30 21:54 ` [PATCH 2/3] staging: rtl8723au: fix "incorrect type in assignment" Michel von Czettritz
@ 2015-06-30 21:54 ` Michel von Czettritz
2015-07-01 7:12 ` Sudip Mukherjee
2 siblings, 1 reply; 14+ messages in thread
From: Michel von Czettritz @ 2015-06-30 21:54 UTC (permalink / raw)
To: gregkh; +Cc: Jes.Sorensen, Larry.Finger, devel, linux-wireless
The return value of FillH2CCmd in rtl8723a_set_rssi_cmd and
rtl8723a_set_raid_cmd is never checked. Both functions always return
_SUCCESS.
Both functions now return the return value of FillH2CCmd.
Signed-off-by: Michel von Czettritz <michel.von.czettritz@gmail.com>
---
drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
index a5e6726..72924a78 100644
--- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
+++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
@@ -118,9 +118,7 @@ int rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u32 *param)
__le32 param_le;
param_le = cpu_to_le32(*(param));
- FillH2CCmd(padapter, RSSI_SETTING_EID, 3, (u8 *)¶m_le);
-
- return _SUCCESS;
+ return FillH2CCmd(padapter, RSSI_SETTING_EID, 3, (u8 *)¶m_le);
}
int rtl8723a_set_raid_cmd(struct rtw_adapter *padapter, u32 mask, u8 arg)
@@ -133,9 +131,7 @@ int rtl8723a_set_raid_cmd(struct rtw_adapter *padapter, u32 mask, u8 arg)
memcpy(buf, &mask_le, 4);
buf[4] = arg;
- FillH2CCmd(padapter, MACID_CONFIG_EID, 5, buf);
-
- return _SUCCESS;
+ return FillH2CCmd(padapter, MACID_CONFIG_EID, 5, buf);
}
/* bitmap[0:27] = tx_rate_bitmap */
--
2.4.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 2/3] staging: rtl8723au: fix "incorrect type in assignment"
2015-06-30 21:54 ` [PATCH 2/3] staging: rtl8723au: fix "incorrect type in assignment" Michel von Czettritz
@ 2015-07-01 7:06 ` Sudip Mukherjee
2015-07-01 7:56 ` Dan Carpenter
2015-07-01 20:31 ` Jes Sorensen
2 siblings, 0 replies; 14+ messages in thread
From: Sudip Mukherjee @ 2015-07-01 7:06 UTC (permalink / raw)
To: Michel von Czettritz
Cc: gregkh, devel, Jes.Sorensen, linux-wireless, Larry.Finger
On Tue, Jun 30, 2015 at 11:54:02PM +0200, Michel von Czettritz wrote:
> Writing the output of cpu_to_le32 to an u32 or *(u32*) is an implicit
> cast and results in an sparse warning.
>
> Since param and mask won't be changed, the implicit cast can be avoided
> by creating local variables.
>
> Signed-off-by: Michel von Czettritz <michel.von.czettritz@gmail.com>
> ---
> drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
> index 1003365..a5e6726 100644
> --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
> +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
> @@ -115,9 +115,10 @@ exit:
>
> int rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u32 *param)
> {
> - *((u32 *)param) = cpu_to_le32(*(param));
> + __le32 param_le;
checkpatch warns about "Missing a blank line after declarations"
regards
sudip
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/3] staging: rtl8723au: function no longer discards return value
2015-06-30 21:54 ` [PATCH 3/3] staging: rtl8723au: function no longer discards return value Michel von Czettritz
@ 2015-07-01 7:12 ` Sudip Mukherjee
2015-07-01 7:50 ` Dan Carpenter
0 siblings, 1 reply; 14+ messages in thread
From: Sudip Mukherjee @ 2015-07-01 7:12 UTC (permalink / raw)
To: Michel von Czettritz
Cc: gregkh, devel, Jes.Sorensen, linux-wireless, Larry.Finger
On Tue, Jun 30, 2015 at 11:54:59PM +0200, Michel von Czettritz wrote:
> The return value of FillH2CCmd in rtl8723a_set_rssi_cmd and
> rtl8723a_set_raid_cmd is never checked. Both functions always return
> _SUCCESS.
>
> Both functions now return the return value of FillH2CCmd.
If they are never checked then why do we need to return some value?
why not make them void?
regards
sudip
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/3] staging: rtl8723au: function no longer discards return value
2015-07-01 7:12 ` Sudip Mukherjee
@ 2015-07-01 7:50 ` Dan Carpenter
2015-07-01 8:08 ` Sudip Mukherjee
0 siblings, 1 reply; 14+ messages in thread
From: Dan Carpenter @ 2015-07-01 7:50 UTC (permalink / raw)
To: Sudip Mukherjee
Cc: Michel von Czettritz, devel, gregkh, Larry.Finger, linux-wireless,
Jes.Sorensen
On Wed, Jul 01, 2015 at 12:42:24PM +0530, Sudip Mukherjee wrote:
> On Tue, Jun 30, 2015 at 11:54:59PM +0200, Michel von Czettritz wrote:
> > The return value of FillH2CCmd in rtl8723a_set_rssi_cmd and
> > rtl8723a_set_raid_cmd is never checked. Both functions always return
> > _SUCCESS.
> >
> > Both functions now return the return value of FillH2CCmd.
> If they are never checked then why do we need to return some value?
> why not make them void?
They probably *should* be checked eventually?
regards,
dan carpenter
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/3] staging: rtl8723au: fix "incorrect type in assignment"
2015-06-30 21:54 ` [PATCH 2/3] staging: rtl8723au: fix "incorrect type in assignment" Michel von Czettritz
2015-07-01 7:06 ` Sudip Mukherjee
@ 2015-07-01 7:56 ` Dan Carpenter
2015-07-01 20:34 ` Jes Sorensen
2015-07-01 20:31 ` Jes Sorensen
2 siblings, 1 reply; 14+ messages in thread
From: Dan Carpenter @ 2015-07-01 7:56 UTC (permalink / raw)
To: Michel von Czettritz
Cc: gregkh, devel, Jes.Sorensen, linux-wireless, Larry.Finger
On Tue, Jun 30, 2015 at 11:54:02PM +0200, Michel von Czettritz wrote:
> Writing the output of cpu_to_le32 to an u32 or *(u32*) is an implicit
> cast and results in an sparse warning.
>
> Since param and mask won't be changed, the implicit cast can be avoided
> by creating local variables.
>
> Signed-off-by: Michel von Czettritz <michel.von.czettritz@gmail.com>
> ---
> drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
> index 1003365..a5e6726 100644
> --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
> +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
> @@ -115,9 +115,10 @@ exit:
>
> int rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u32 *param)
> {
> - *((u32 *)param) = cpu_to_le32(*(param));
> + __le32 param_le;
> + param_le = cpu_to_le32(*(param));
We shouldn't be passing param as a pointer anyway. It should just be
u32 cmd.
__le32 cmd_le = cpu_to_le32(cmd);
FillH2CCmd(padapter, RSSI_SETTING_EID, 3, (u8 *)&cmd_le);
Fold it together with patch 1.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/3] staging: rtl8723au: function no longer discards return value
2015-07-01 7:50 ` Dan Carpenter
@ 2015-07-01 8:08 ` Sudip Mukherjee
2015-07-01 16:50 ` Michel von Czettritz
0 siblings, 1 reply; 14+ messages in thread
From: Sudip Mukherjee @ 2015-07-01 8:08 UTC (permalink / raw)
To: Dan Carpenter
Cc: Michel von Czettritz, devel, gregkh, Larry.Finger, linux-wireless,
Jes.Sorensen
On Wed, Jul 01, 2015 at 10:50:42AM +0300, Dan Carpenter wrote:
> On Wed, Jul 01, 2015 at 12:42:24PM +0530, Sudip Mukherjee wrote:
> > On Tue, Jun 30, 2015 at 11:54:59PM +0200, Michel von Czettritz wrote:
> > > The return value of FillH2CCmd in rtl8723a_set_rssi_cmd and
> > > rtl8723a_set_raid_cmd is never checked. Both functions always return
> > > _SUCCESS.
> > >
> > > Both functions now return the return value of FillH2CCmd.
> > If they are never checked then why do we need to return some value?
> > why not make them void?
>
> They probably *should* be checked eventually?
yes, they should check the sucess/failure of the commands. If that plan
is there to check the values afterwards then the patch is correct.
regards
sudip
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/3] staging: rtl8723au: function no longer discards return value
2015-07-01 8:08 ` Sudip Mukherjee
@ 2015-07-01 16:50 ` Michel von Czettritz
0 siblings, 0 replies; 14+ messages in thread
From: Michel von Czettritz @ 2015-07-01 16:50 UTC (permalink / raw)
To: Sudip Mukherjee, Dan Carpenter
Cc: devel, gregkh, Larry.Finger, linux-wireless, Jes.Sorensen
On 07/01/2015 10:08 AM, Sudip Mukherjee wrote:
> On Wed, Jul 01, 2015 at 10:50:42AM +0300, Dan Carpenter wrote:
>> On Wed, Jul 01, 2015 at 12:42:24PM +0530, Sudip Mukherjee wrote:
>>> On Tue, Jun 30, 2015 at 11:54:59PM +0200, Michel von Czettritz wrote:
>>>> The return value of FillH2CCmd in rtl8723a_set_rssi_cmd and
>>>> rtl8723a_set_raid_cmd is never checked. Both functions always return
>>>> _SUCCESS.
>>>>
>>>> Both functions now return the return value of FillH2CCmd.
>>> If they are never checked then why do we need to return some value?
>>> why not make them void?
>>
>> They probably *should* be checked eventually?
> yes, they should check the sucess/failure of the commands. If that plan
> is there to check the values afterwards then the patch is correct.
Both functions are currently only called by void functions, which don't check on the return values of the functions.
Nonetheless I think rtl8723a_set_rssi_cmd and rtl8723a_set_raid_cmd should return correct values and another patch should take on the calling void functions error handling.
As I'm not fully familiar with the inner workings of the driver, I'd leave the error handling for somebody else to implement, or would take it on later.
regards Michel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/3] staging: rtl8723au: fix "incorrect type in assignment"
2015-06-30 21:54 ` [PATCH 2/3] staging: rtl8723au: fix "incorrect type in assignment" Michel von Czettritz
2015-07-01 7:06 ` Sudip Mukherjee
2015-07-01 7:56 ` Dan Carpenter
@ 2015-07-01 20:31 ` Jes Sorensen
2015-07-01 23:36 ` Michel von Czettritz
2 siblings, 1 reply; 14+ messages in thread
From: Jes Sorensen @ 2015-07-01 20:31 UTC (permalink / raw)
To: Michel von Czettritz; +Cc: gregkh, Larry.Finger, devel, linux-wireless
Michel von Czettritz <michel.von.czettritz@gmail.com> writes:
> Writing the output of cpu_to_le32 to an u32 or *(u32*) is an implicit
> cast and results in an sparse warning.
>
> Since param and mask won't be changed, the implicit cast can be avoided
> by creating local variables.
>
> Signed-off-by: Michel von Czettritz <michel.von.czettritz@gmail.com>
> ---
> drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
> index 1003365..a5e6726 100644
> --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
> +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
> @@ -115,9 +115,10 @@ exit:
>
> int rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u32 *param)
> {
> - *((u32 *)param) = cpu_to_le32(*(param));
> + __le32 param_le;
> + param_le = cpu_to_le32(*(param));
>
> - FillH2CCmd(padapter, RSSI_SETTING_EID, 3, (u8 *)param);
> + FillH2CCmd(padapter, RSSI_SETTING_EID, 3, (u8 *)¶m_le);
>
> return _SUCCESS;
> }
> @@ -125,10 +126,11 @@ int rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u32 *param)
> int rtl8723a_set_raid_cmd(struct rtw_adapter *padapter, u32 mask, u8 arg)
> {
> u8 buf[5];
> + __le32 mask_le;
>
> memset(buf, 0, 5);
> - mask = cpu_to_le32(mask);
> - memcpy(buf, &mask, 4);
> + mask_le = cpu_to_le32(mask);
> + memcpy(buf, &mask_le, 4);
cpu_to_le32() + memcpy() is ugly - put_unaligned_le32() would make more
sense.
Jes
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/3] staging: rtl8723au: fix "incorrect type in assignment"
2015-07-01 7:56 ` Dan Carpenter
@ 2015-07-01 20:34 ` Jes Sorensen
0 siblings, 0 replies; 14+ messages in thread
From: Jes Sorensen @ 2015-07-01 20:34 UTC (permalink / raw)
To: Dan Carpenter
Cc: Michel von Czettritz, gregkh, devel, linux-wireless, Larry.Finger
Dan Carpenter <dan.carpenter@oracle.com> writes:
> On Tue, Jun 30, 2015 at 11:54:02PM +0200, Michel von Czettritz wrote:
>> Writing the output of cpu_to_le32 to an u32 or *(u32*) is an implicit
>> cast and results in an sparse warning.
>>
>> Since param and mask won't be changed, the implicit cast can be avoided
>> by creating local variables.
>>
>> Signed-off-by: Michel von Czettritz <michel.von.czettritz@gmail.com>
>> ---
>> drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 10 ++++++----
>> 1 file changed, 6 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
>> b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
>> index 1003365..a5e6726 100644
>> --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
>> +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
>> @@ -115,9 +115,10 @@ exit:
>>
>> int rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u32 *param)
>> {
>> - *((u32 *)param) = cpu_to_le32(*(param));
>> + __le32 param_le;
>> + param_le = cpu_to_le32(*(param));
>
> We shouldn't be passing param as a pointer anyway. It should just be
> u32 cmd.
>
> __le32 cmd_le = cpu_to_le32(cmd);
>
> FillH2CCmd(padapter, RSSI_SETTING_EID, 3, (u8 *)&cmd_le);
>
> Fold it together with patch 1.
I agree, this would be cleaner.
Jes
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/3] staging: rtl8723au: fix "incorrect type in assignment"
2015-07-01 20:31 ` Jes Sorensen
@ 2015-07-01 23:36 ` Michel von Czettritz
2015-07-02 2:00 ` Jes Sorensen
0 siblings, 1 reply; 14+ messages in thread
From: Michel von Czettritz @ 2015-07-01 23:36 UTC (permalink / raw)
To: Jes Sorensen; +Cc: gregkh, Larry.Finger, devel, linux-wireless
On 07/01/2015 10:31 PM, Jes Sorensen wrote:
> Michel von Czettritz <michel.von.czettritz@gmail.com> writes:
>> Writing the output of cpu_to_le32 to an u32 or *(u32*) is an implicit
>> cast and results in an sparse warning.
>>
>> Since param and mask won't be changed, the implicit cast can be avoided
>> by creating local variables.
>>
>> Signed-off-by: Michel von Czettritz <michel.von.czettritz@gmail.com>
>> ---
>> drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 10 ++++++----
>> 1 file changed, 6 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
>> index 1003365..a5e6726 100644
>> --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
>> +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
>> @@ -115,9 +115,10 @@ exit:
>>
>> int rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u32 *param)
>> {
>> - *((u32 *)param) = cpu_to_le32(*(param));
>> + __le32 param_le;
>> + param_le = cpu_to_le32(*(param));
>>
>> - FillH2CCmd(padapter, RSSI_SETTING_EID, 3, (u8 *)param);
>> + FillH2CCmd(padapter, RSSI_SETTING_EID, 3, (u8 *)¶m_le);
>>
>> return _SUCCESS;
>> }
>> @@ -125,10 +126,11 @@ int rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u32 *param)
>> int rtl8723a_set_raid_cmd(struct rtw_adapter *padapter, u32 mask, u8 arg)
>> {
>> u8 buf[5];
>> + __le32 mask_le;
>>
>> memset(buf, 0, 5);
>> - mask = cpu_to_le32(mask);
>> - memcpy(buf, &mask, 4);
>> + mask_le = cpu_to_le32(mask);
>> + memcpy(buf, &mask_le, 4);
>
> cpu_to_le32() + memcpy() is ugly - put_unaligned_le32() would make more
> sense.
>
> Jes
I'm not sure if the fold, changing u32* to u32, and changing this, is a bit much.
Should this be a second patch? Or maybe a patch for each function?
Regards Michel
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/3] staging: rtl8723au: fix "incorrect type in assignment"
2015-07-01 23:36 ` Michel von Czettritz
@ 2015-07-02 2:00 ` Jes Sorensen
0 siblings, 0 replies; 14+ messages in thread
From: Jes Sorensen @ 2015-07-02 2:00 UTC (permalink / raw)
To: Michel von Czettritz; +Cc: gregkh, Larry.Finger, devel, linux-wireless
Michel von Czettritz <michel.von.czettritz@gmail.com> writes:
> On 07/01/2015 10:31 PM, Jes Sorensen wrote:
>> Michel von Czettritz <michel.von.czettritz@gmail.com> writes:
>>> Writing the output of cpu_to_le32 to an u32 or *(u32*) is an implicit
>>> cast and results in an sparse warning.
>>>
>>> Since param and mask won't be changed, the implicit cast can be avoided
>>> by creating local variables.
>>>
>>> Signed-off-by: Michel von Czettritz <michel.von.czettritz@gmail.com>
>>> ---
>>> drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 10 ++++++----
>>> 1 file changed, 6 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
>>> index 1003365..a5e6726 100644
>>> --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
>>> +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
>>> @@ -115,9 +115,10 @@ exit:
>>>
>>> int rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u32 *param)
>>> {
>>> - *((u32 *)param) = cpu_to_le32(*(param));
>>> + __le32 param_le;
>>> + param_le = cpu_to_le32(*(param));
>>>
>>> - FillH2CCmd(padapter, RSSI_SETTING_EID, 3, (u8 *)param);
>>> + FillH2CCmd(padapter, RSSI_SETTING_EID, 3, (u8 *)¶m_le);
>>>
>>> return _SUCCESS;
>>> }
>>> @@ -125,10 +126,11 @@ int rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u32 *param)
>>> int rtl8723a_set_raid_cmd(struct rtw_adapter *padapter, u32 mask, u8 arg)
>>> {
>>> u8 buf[5];
>>> + __le32 mask_le;
>>>
>>> memset(buf, 0, 5);
>>> - mask = cpu_to_le32(mask);
>>> - memcpy(buf, &mask, 4);
>>> + mask_le = cpu_to_le32(mask);
>>> + memcpy(buf, &mask_le, 4);
>>
>> cpu_to_le32() + memcpy() is ugly - put_unaligned_le32() would make more
>> sense.
>>
>> Jes
> I'm not sure if the fold, changing u32* to u32, and changing this, is
> a bit much.
> Should this be a second patch? Or maybe a patch for each function?
I would change the u32 * in one patch and the conversion and memcpy in
another.
Cheers,
Jes
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2015-07-02 2:00 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-30 21:52 [PATCH 0/3] staging: rtl8723au: fix/clean up two functions Michel von Czettritz
2015-06-30 21:53 ` [PATCH 1/3] staging: rtl8723au: adjust function param, u8* to u32* Michel von Czettritz
2015-06-30 21:54 ` [PATCH 2/3] staging: rtl8723au: fix "incorrect type in assignment" Michel von Czettritz
2015-07-01 7:06 ` Sudip Mukherjee
2015-07-01 7:56 ` Dan Carpenter
2015-07-01 20:34 ` Jes Sorensen
2015-07-01 20:31 ` Jes Sorensen
2015-07-01 23:36 ` Michel von Czettritz
2015-07-02 2:00 ` Jes Sorensen
2015-06-30 21:54 ` [PATCH 3/3] staging: rtl8723au: function no longer discards return value Michel von Czettritz
2015-07-01 7:12 ` Sudip Mukherjee
2015-07-01 7:50 ` Dan Carpenter
2015-07-01 8:08 ` Sudip Mukherjee
2015-07-01 16:50 ` Michel von Czettritz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).