Fix sparse build warning:
drivers/net/ethernet/amazon/ena/ena_netdev.c:2193:34: warning:
Using plain integer as NULL pointer
Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Wang Hai <[email protected]>
---
drivers/net/ethernet/amazon/ena/ena_netdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index 91be3ffa1c5c..11303a4b94be 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -2190,7 +2190,7 @@ static void ena_del_napi_in_range(struct ena_adapter *adapter,
static void ena_init_napi_in_range(struct ena_adapter *adapter,
int first_index, int count)
{
- struct ena_napi *napi = {0};
+ struct ena_napi *napi = NULL;
int i;
for (i = first_index; i < first_index + count; i++) {
--
2.17.1
On Sat, 2020-07-18 at 19:56 +0800, Wang Hai wrote:
> Fix sparse build warning:
>
> drivers/net/ethernet/amazon/ena/ena_netdev.c:2193:34: warning:
> Using plain integer as NULL pointer
Better to remove the initialization altogether and
move the declaration into the loop.
> diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
[]
> @@ -2190,7 +2190,7 @@ static void ena_del_napi_in_range(struct ena_adapter *adapter,
> static void ena_init_napi_in_range(struct ena_adapter *adapter,
> int first_index, int count)
> {
> - struct ena_napi *napi = {0};
> + struct ena_napi *napi = NULL;
> int i;
>
> for (i = first_index; i < first_index + count; i++) {
---
drivers/net/ethernet/amazon/ena/ena_netdev.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index 91be3ffa1c5c..470d8f38b824 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -2190,11 +2190,10 @@ static void ena_del_napi_in_range(struct ena_adapter *adapter,
static void ena_init_napi_in_range(struct ena_adapter *adapter,
int first_index, int count)
{
- struct ena_napi *napi = {0};
int i;
for (i = first_index; i < first_index + count; i++) {
- napi = &adapter->ena_napi[i];
+ struct ena_napi *napi = &adapter->ena_napi[i];
netif_napi_add(adapter->netdev,
&adapter->ena_napi[i].napi,
Joe Perches <[email protected]> writes:
> On Sat, 2020-07-18 at 19:56 +0800, Wang Hai wrote:
>> Fix sparse build warning:
>>
>> drivers/net/ethernet/amazon/ena/ena_netdev.c:2193:34: warning:
>> Using plain integer as NULL pointer
>
> Better to remove the initialization altogether and
> move the declaration into the loop.
>
>> diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c
>> b/drivers/net/ethernet/amazon/ena/ena_netdev.c
> []
>> @@ -2190,7 +2190,7 @@ static void ena_del_napi_in_range(struct
>> ena_adapter *adapter,
>> static void ena_init_napi_in_range(struct ena_adapter
>> *adapter,
>> int first_index, int count)
>> {
>> - struct ena_napi *napi = {0};
>> + struct ena_napi *napi = NULL;
>> int i;
>>
>> for (i = first_index; i < first_index + count; i++) {
>
> ---
> drivers/net/ethernet/amazon/ena/ena_netdev.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c
> b/drivers/net/ethernet/amazon/ena/ena_netdev.c
> index 91be3ffa1c5c..470d8f38b824 100644
> --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
> +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
> @@ -2190,11 +2190,10 @@ static void ena_del_napi_in_range(struct
> ena_adapter *adapter,
> static void ena_init_napi_in_range(struct ena_adapter *adapter,
> int first_index, int count)
> {
> - struct ena_napi *napi = {0};
> int i;
>
> for (i = first_index; i < first_index + count; i++) {
> - napi = &adapter->ena_napi[i];
> + struct ena_napi *napi = &adapter->ena_napi[i];
>
> netif_napi_add(adapter->netdev,
> &adapter->ena_napi[i].napi,
We prefer the second variant as it improves code readability imo.
Thank you both for the time you invested in it (:
Acked-by: Shay Agroskin <[email protected]>
?? 2020/7/18 23:06, Joe Perches ะด??:
> On Sat, 2020-07-18 at 19:56 +0800, Wang Hai wrote:
>> Fix sparse build warning:
>>
>> drivers/net/ethernet/amazon/ena/ena_netdev.c:2193:34: warning:
>> Using plain integer as NULL pointer
> Better to remove the initialization altogether and
> move the declaration into the loop.
Thanks for your advice. I'll send a v2 patch.