2021-03-27 12:17:50

by Zheng Zengkai

[permalink] [raw]
Subject: [PATCH] afs: fix no return statement in function returning non-void

Add missing return to fix following compilation issue:

fs/afs/dir.c: In function ‘afs_dir_set_page_dirty’:
fs/afs/dir.c:51:1: error: no return statement in function
returning non-void [-Werror=return-type]

Fixes: f3ddee8dc4e2 ("afs: Fix directory handling")
Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Zheng Zengkai <[email protected]>
---
fs/afs/dir.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 17548c1faf02..1795a05b7cb7 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -48,6 +48,7 @@ static void afs_dir_invalidatepage(struct page *page, unsigned int offset,
static int afs_dir_set_page_dirty(struct page *page)
{
BUG(); /* This should never happen. */
+ return 0;
}

const struct file_operations afs_dir_file_operations = {
--
2.20.1


2021-03-31 02:34:31

by Zheng Zengkai

[permalink] [raw]
Subject: Re: [PATCH] afs: fix no return statement in function returning non-void

Hi David and Reviewers,

> Add missing return to fix following compilation issue:
>
> fs/afs/dir.c: In function ‘afs_dir_set_page_dirty’:
> fs/afs/dir.c:51:1: error: no return statement in function
> returning non-void [-Werror=return-type]
>
> Fixes: f3ddee8dc4e2 ("afs: Fix directory handling")
> Reported-by: Hulk Robot <[email protected]>
> Signed-off-by: Zheng Zengkai <[email protected]>
> ---
> fs/afs/dir.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/afs/dir.c b/fs/afs/dir.c
> index 17548c1faf02..1795a05b7cb7 100644
> --- a/fs/afs/dir.c
> +++ b/fs/afs/dir.c
> @@ -48,6 +48,7 @@ static void afs_dir_invalidatepage(struct page *page, unsigned int offset,
> static int afs_dir_set_page_dirty(struct page *page)
> {
> BUG(); /* This should never happen. */
> + return 0;
> }
>
> const struct file_operations afs_dir_file_operations = {

Is there anyone who can take a look?  ;-)

Thanks!

2021-04-08 14:09:14

by David Howells

[permalink] [raw]
Subject: Re: [PATCH] afs: fix no return statement in function returning non-void

Zheng Zengkai <[email protected]> wrote:

> static int afs_dir_set_page_dirty(struct page *page)
> {
> BUG(); /* This should never happen. */
> + return 0;
> }

That shouldn't be necessary. BUG() should be marked as 'no return' to the
compiler. What arch and compiler are you using?

David

2021-04-19 22:34:08

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH] afs: fix no return statement in function returning non-void

On 4/8/21 7:06 AM, David Howells wrote:
> Zheng Zengkai <[email protected]> wrote:
>
>> static int afs_dir_set_page_dirty(struct page *page)
>> {
>> BUG(); /* This should never happen. */
>> + return 0;
>> }
>
> That shouldn't be necessary. BUG() should be marked as 'no return' to the
> compiler. What arch and compiler are you using?

How do mark a #define BUG() as __noreturn?

Several arch-es use #define for BUG() instead of using a function.

--
~Randy

2021-05-27 19:53:10

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH] afs: fix no return statement in function returning non-void

On 4/19/21 3:31 PM, Randy Dunlap wrote:
> On 4/8/21 7:06 AM, David Howells wrote:
>> Zheng Zengkai <[email protected]> wrote:
>>
>>> static int afs_dir_set_page_dirty(struct page *page)
>>> {
>>> BUG(); /* This should never happen. */
>>> + return 0;
>>> }
>>
>> That shouldn't be necessary. BUG() should be marked as 'no return' to the
>> compiler. What arch and compiler are you using?
>
> How do mark a #define BUG() as __noreturn?
>
> Several arch-es use #define for BUG() instead of using a function.

Hi David,

So you are counting of BUG() being a function and not a macro?

Doesn't seem like a good idea.

--
~Randy