2008-11-18 15:59:21

by Hannes Eder

[permalink] [raw]
Subject: [PATCH] sound: Fix warnings relating to ignored return value in snd_card_register

Do not ignore the return of 'device_create_file' in
'snd_card_register' and thereby fixing the following warnings:

sound/core/init.c: In function 'snd_card_register':
sound/core/init.c:640: warning: ignoring return value of
'device_create_file', declared with attribute warn_unused_result
sound/core/init.c:641: warning: ignoring return value of
'device_create_file', declared with attribute warn_unused_result

Signed-off-by: Hannes Eder <[email protected]>
---
sound/core/init.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/sound/core/init.c b/sound/core/init.c
index af1e407..814d834 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -637,8 +637,10 @@ int snd_card_register(struct snd_card *card)
#endif
#ifndef CONFIG_SYSFS_DEPRECATED
if (card->card_dev) {
- device_create_file(card->card_dev, &card_id_attrs);
- device_create_file(card->card_dev, &card_number_attrs);
+ if ((err = device_create_file(card->card_dev, &card_id_attrs)) < 0)
+ return err;
+ if ((err = device_create_file(card->card_dev, &card_number_attrs)) < 0)
+ return err;
}
#endif
return 0;


2008-11-18 16:14:54

by Takashi Iwai

[permalink] [raw]
Subject: Re: [PATCH] sound: Fix warnings relating to ignored return value in snd_card_register

At Tue, 18 Nov 2008 16:59:03 +0100,
Hannes Eder wrote:
>
> Do not ignore the return of 'device_create_file' in
> 'snd_card_register' and thereby fixing the following warnings:
>
> sound/core/init.c: In function 'snd_card_register':
> sound/core/init.c:640: warning: ignoring return value of
> 'device_create_file', declared with attribute warn_unused_result
> sound/core/init.c:641: warning: ignoring return value of
> 'device_create_file', declared with attribute warn_unused_result

The changes look good, but please run checkpatch.pl to your patch and
fix the coding style issues suggested there.


thanks,

Takashi

>
> Signed-off-by: Hannes Eder <[email protected]>
> ---
> sound/core/init.c | 6 ++++--
> 1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/sound/core/init.c b/sound/core/init.c
> index af1e407..814d834 100644
> --- a/sound/core/init.c
> +++ b/sound/core/init.c
> @@ -637,8 +637,10 @@ int snd_card_register(struct snd_card *card)
> #endif
> #ifndef CONFIG_SYSFS_DEPRECATED
> if (card->card_dev) {
> - device_create_file(card->card_dev, &card_id_attrs);
> - device_create_file(card->card_dev, &card_number_attrs);
> + if ((err = device_create_file(card->card_dev, &card_id_attrs)) < 0)
> + return err;
> + if ((err = device_create_file(card->card_dev, &card_number_attrs)) < 0)
> + return err;
> }
> #endif
> return 0;
>

2008-11-18 17:06:35

by Hannes Eder

[permalink] [raw]
Subject: Re: [PATCH] sound: Fix warnings relating to ignored return value in snd_card_register

Do not ignore the return of 'device_create_file' in
'snd_card_register' and thereby fixing the following warnings:

sound/core/init.c: In function 'snd_card_register':
sound/core/init.c:640: warning: ignoring return value of
'device_create_file', declared with attribute warn_unused_result
sound/core/init.c:641: warning: ignoring return value of
'device_create_file', declared with attribute warn_unused_result

Signed-off-by: Hannes Eder <[email protected]>
---

On Tue, Nov 18, 2008 at 11:14 AM, Takashi Iwai <[email protected]> wrote:
> The changes look good, but please run checkpatch.pl to your patch and
> fix the coding style issues suggested there.

I did not fix:

"WARNING: line over 80 characters" as they a hardly longer than 80
characters and there are lines longer than this in the same file.

"ERROR: do not use assignment in if condition" as this pattern seems
to be quite common.

Comments? Should I fix them?

sound/core/init.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/sound/core/init.c b/sound/core/init.c
index af1e407..814d834 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -637,8 +637,10 @@ int snd_card_register(struct snd_card *card)
#endif
#ifndef CONFIG_SYSFS_DEPRECATED
if (card->card_dev) {
- device_create_file(card->card_dev, &card_id_attrs);
- device_create_file(card->card_dev, &card_number_attrs);
+ if ((err = device_create_file(card->card_dev, &card_id_attrs)) < 0)
+ return err;
+ if ((err = device_create_file(card->card_dev, &card_number_attrs)) < 0)
+ return err;
}
#endif
return 0;

2008-11-18 17:12:39

by Richard Holden

[permalink] [raw]
Subject: Re: [PATCH] sound: Fix warnings relating to ignored return value in snd_card_register


On Nov 18, 2008, at 10:06 AM, Hannes Eder wrote:

> Do not ignore the return of 'device_create_file' in
> 'snd_card_register' and thereby fixing the following warnings:
>
> sound/core/init.c: In function 'snd_card_register':
> sound/core/init.c:640: warning: ignoring return value of
> 'device_create_file', declared with attribute warn_unused_result
> sound/core/init.c:641: warning: ignoring return value of
> 'device_create_file', declared with attribute warn_unused_result
>
> Signed-off-by: Hannes Eder <[email protected]>
> ---
>
> On Tue, Nov 18, 2008 at 11:14 AM, Takashi Iwai <[email protected]> wrote:
>> The changes look good, but please run checkpatch.pl to your patch and
>> fix the coding style issues suggested there.
>
> I did not fix:
>
> "WARNING: line over 80 characters" as they a hardly longer than 80
> characters and there are lines longer than this in the same file.
>
> "ERROR: do not use assignment in if condition" as this pattern seems
> to be quite common.
>
> Comments? Should I fix them?

I would definitely fix the ERROR, I have seen messages from Linus with
really bad comments about using that construct. Most maintainers also
won't want to take a patch where checkpatch reports an error. Also
fixing the ERROR should also fix the warning.

-Richard Holden

2008-11-18 17:12:54

by Takashi Iwai

[permalink] [raw]
Subject: Re: [PATCH] sound: Fix warnings relating to ignored return value in snd_card_register

At Tue, 18 Nov 2008 18:06:23 +0100,
Hannes Eder wrote:
>
> Do not ignore the return of 'device_create_file' in
> 'snd_card_register' and thereby fixing the following warnings:
>
> sound/core/init.c: In function 'snd_card_register':
> sound/core/init.c:640: warning: ignoring return value of
> 'device_create_file', declared with attribute warn_unused_result
> sound/core/init.c:641: warning: ignoring return value of
> 'device_create_file', declared with attribute warn_unused_result
>
> Signed-off-by: Hannes Eder <[email protected]>
> ---
>
> On Tue, Nov 18, 2008 at 11:14 AM, Takashi Iwai <[email protected]> wrote:
> > The changes look good, but please run checkpatch.pl to your patch and
> > fix the coding style issues suggested there.
>
> I did not fix:
>
> "WARNING: line over 80 characters" as they a hardly longer than 80
> characters and there are lines longer than this in the same file.

It's no excuse to add such lines again :)
(But, don't try to clean up the other lines -- mostly not worth, and
it'd just make the change history dirty.)

> "ERROR: do not use assignment in if condition" as this pattern seems
> to be quite common.

Note this is an ERROR.

> Comments? Should I fix them?

Yes.


thanks,

Takashi

2008-11-18 17:25:25

by Hannes Eder

[permalink] [raw]
Subject: Re: [PATCH] sound: Fix warnings relating to ignored return value in snd_card_register

Do not ignore the return of 'device_create_file' in
'snd_card_register' and thereby fixing the following warnings:

sound/core/init.c: In function 'snd_card_register':
sound/core/init.c:640: warning: ignoring return value of
'device_create_file', declared with attribute warn_unused_result
sound/core/init.c:641: warning: ignoring return value of
'device_create_file', declared with attribute warn_unused_result

Signed-off-by: Hannes Eder <[email protected]>
---
All warnings and errors reported by checkpatch.pl fixed.

Thank you for your feedback.

sound/core/init.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/sound/core/init.c b/sound/core/init.c
index af1e407..0d5520c 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -637,8 +637,12 @@ int snd_card_register(struct snd_card *card)
#endif
#ifndef CONFIG_SYSFS_DEPRECATED
if (card->card_dev) {
- device_create_file(card->card_dev, &card_id_attrs);
- device_create_file(card->card_dev, &card_number_attrs);
+ err = device_create_file(card->card_dev, &card_id_attrs);
+ if (err < 0)
+ return err;
+ err = device_create_file(card->card_dev, &card_number_attrs);
+ if (err < 0)
+ return err;
}
#endif
return 0;

2008-11-18 17:34:51

by Takashi Iwai

[permalink] [raw]
Subject: Re: [PATCH] sound: Fix warnings relating to ignored return value in snd_card_register

At Tue, 18 Nov 2008 12:25:06 -0500,
Hannes Eder wrote:
>
> Do not ignore the return of 'device_create_file' in
> 'snd_card_register' and thereby fixing the following warnings:
>
> sound/core/init.c: In function 'snd_card_register':
> sound/core/init.c:640: warning: ignoring return value of
> 'device_create_file', declared with attribute warn_unused_result
> sound/core/init.c:641: warning: ignoring return value of
> 'device_create_file', declared with attribute warn_unused_result
>
> Signed-off-by: Hannes Eder <[email protected]>
> ---
> All warnings and errors reported by checkpatch.pl fixed.

Thanks! Applied now.


Takashi