2010-12-06 14:01:41

by Marek Belisko

[permalink] [raw]
Subject: [PATCH] arm: ecard: Fix compilation warning.

Fix following compilation warning:
arch/arm/kernel/ecard.c:1066: warning: ignoring return value of
'device_register', declared with attribute warn_unused_result

Signed-off-by: Marek Belisko <[email protected]>
---
arch/arm/kernel/ecard.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/kernel/ecard.c b/arch/arm/kernel/ecard.c
index eed2f79..da882b1 100644
--- a/arch/arm/kernel/ecard.c
+++ b/arch/arm/kernel/ecard.c
@@ -1063,8 +1063,10 @@ ecard_probe(int slot, card_type_t type)
*ecp = ec;
slot_to_expcard[slot] = ec;

- device_register(&ec->dev);
-
+ rc = device_register(&ec->dev);
+ if (rc)
+ goto nodev;
+
return 0;

nodev:
--
1.7.1


2010-12-06 14:05:23

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [PATCH] arm: ecard: Fix compilation warning.

On Mon, Dec 06, 2010 at 03:04:03PM +0100, Marek Belisko wrote:
> Fix following compilation warning:
> arch/arm/kernel/ecard.c:1066: warning: ignoring return value of
> 'device_register', declared with attribute warn_unused_result
>
> Signed-off-by: Marek Belisko <[email protected]>
> ---
> arch/arm/kernel/ecard.c | 6 ++++--
> 1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/kernel/ecard.c b/arch/arm/kernel/ecard.c
> index eed2f79..da882b1 100644
> --- a/arch/arm/kernel/ecard.c
> +++ b/arch/arm/kernel/ecard.c
> @@ -1063,8 +1063,10 @@ ecard_probe(int slot, card_type_t type)
> *ecp = ec;
> slot_to_expcard[slot] = ec;
>
> - device_register(&ec->dev);
> -
> + rc = device_register(&ec->dev);
> + if (rc)
> + goto nodev;
> +
> return 0;

No. It is important that cards which are actually there remain present
even if device_register fails. In other words, we _really_ don't care
what device_register() returns.

2010-12-06 19:11:19

by Belisko Marek

[permalink] [raw]
Subject: Re: [PATCH] arm: ecard: Fix compilation warning.

On Mon, Dec 6, 2010 at 3:05 PM, Russell King - ARM Linux
<[email protected]> wrote:
> On Mon, Dec 06, 2010 at 03:04:03PM +0100, Marek Belisko wrote:
>> Fix following compilation warning:
>> arch/arm/kernel/ecard.c:1066: warning: ignoring return value of
>> 'device_register', declared with attribute warn_unused_result
>>
>> Signed-off-by: Marek Belisko <[email protected]>
>> ---
>>  arch/arm/kernel/ecard.c |    6 ++++--
>>  1 files changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/arm/kernel/ecard.c b/arch/arm/kernel/ecard.c
>> index eed2f79..da882b1 100644
>> --- a/arch/arm/kernel/ecard.c
>> +++ b/arch/arm/kernel/ecard.c
>> @@ -1063,8 +1063,10 @@ ecard_probe(int slot, card_type_t type)
>>       *ecp = ec;
>>       slot_to_expcard[slot] = ec;
>>
>> -     device_register(&ec->dev);
>> -
>> +     rc = device_register(&ec->dev);
>> +     if (rc)
>> +             goto nodev;
>> +
>>       return 0;
>
> No.  It is important that cards which are actually there remain present
> even if device_register fails.  In other words, we _really_ don't care
> what device_register() returns.
OK understand but anyway to stop compiler bark following could be OK and
maybe other people saw error and try to send same patch so keep them informed.

diff --git a/arch/arm/kernel/ecard.c b/arch/arm/kernel/ecard.c
index eed2f79..d3dcb1a 100644
--- a/arch/arm/kernel/ecard.c
+++ b/arch/arm/kernel/ecard.c
@@ -1062,8 +1062,12 @@ ecard_probe(int slot, card_type_t type)

*ecp = ec;
slot_to_expcard[slot] = ec;
-
- device_register(&ec->dev);
+ /*
+ * Return value not checked. It is important that cards
+ * which are actually there remain present even if
+ * device_register fails.
+ */
+ rc = device_register(&ec->dev);

return 0;

>

thanks,

marek

--
as simple and primitive as possible
-------------------------------------------------
Marek Belisko - OPEN-NANDRA
Freelance Developer

Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
icq: 290551086
web: http://open-nandra.com