From: Chen Gang <gang.chen.5i5j@gmail.com>
To: Seth Jennings <sjennings@variantweb.net>
Cc: Seth Jennings <sjenning@linux.vnet.ibm.com>,
linux-mm@kvack.org,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
James Hogan <james.hogan@imgtec.com>
Subject: Re: [PATCH] mm/zswap.c: add BUG() for default case in zswap_writeback_entry()
Date: Tue, 10 Dec 2013 10:16:19 +0800 [thread overview]
Message-ID: <52A67973.20904@gmail.com> (raw)
In-Reply-To: <20131209153626.GA3752@cerebellum.variantweb.net>
On 12/09/2013 11:36 PM, Seth Jennings wrote:
> On Mon, Dec 09, 2013 at 10:51:16AM +0800, Chen Gang wrote:
>> Recommend to add default case to avoid compiler's warning, although at
>> present, the original implementation is still correct.
>>
>> The related warning (with allmodconfig for metag):
>>
>> CC mm/zswap.o
>> mm/zswap.c: In function 'zswap_writeback_entry':
>> mm/zswap.c:537: warning: 'ret' may be used uninitialized in this function
>>
>>
>> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
>> ---
>> mm/zswap.c | 2 ++
>> 1 files changed, 2 insertions(+), 0 deletions(-)
>>
>> diff --git a/mm/zswap.c b/mm/zswap.c
>> index 5a63f78..bfd1807 100644
>> --- a/mm/zswap.c
>> +++ b/mm/zswap.c
>> @@ -585,6 +585,8 @@ static int zswap_writeback_entry(struct zbud_pool *pool, unsigned long handle)
>>
>> /* page is up to date */
>> SetPageUptodate(page);
>> + default:
>> + BUG();
>
> Typically, the way you want to address this is initialize ret to 0
> at declaration time if not every control path will set that value.
>
At least, your suggestion sounds reasonable.
But I am also aware that normally need content 'default' for 'switch',
so I choose this fix way.
And sorry, current patch is incorrect (need 'break' before 'default'),
so if no additional suggestions or discussions or completions, I
will/should send patch v2 for it.
Thanks.
--
Chen Gang
Open, share, and attitude like air, water and life which God blessed
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: Chen Gang <gang.chen.5i5j@gmail.com>
To: Seth Jennings <sjennings@variantweb.net>
Cc: Seth Jennings <sjenning@linux.vnet.ibm.com>,
linux-mm@kvack.org,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
James Hogan <james.hogan@imgtec.com>
Subject: Re: [PATCH] mm/zswap.c: add BUG() for default case in zswap_writeback_entry()
Date: Tue, 10 Dec 2013 10:16:19 +0800 [thread overview]
Message-ID: <52A67973.20904@gmail.com> (raw)
In-Reply-To: <20131209153626.GA3752@cerebellum.variantweb.net>
On 12/09/2013 11:36 PM, Seth Jennings wrote:
> On Mon, Dec 09, 2013 at 10:51:16AM +0800, Chen Gang wrote:
>> Recommend to add default case to avoid compiler's warning, although at
>> present, the original implementation is still correct.
>>
>> The related warning (with allmodconfig for metag):
>>
>> CC mm/zswap.o
>> mm/zswap.c: In function 'zswap_writeback_entry':
>> mm/zswap.c:537: warning: 'ret' may be used uninitialized in this function
>>
>>
>> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
>> ---
>> mm/zswap.c | 2 ++
>> 1 files changed, 2 insertions(+), 0 deletions(-)
>>
>> diff --git a/mm/zswap.c b/mm/zswap.c
>> index 5a63f78..bfd1807 100644
>> --- a/mm/zswap.c
>> +++ b/mm/zswap.c
>> @@ -585,6 +585,8 @@ static int zswap_writeback_entry(struct zbud_pool *pool, unsigned long handle)
>>
>> /* page is up to date */
>> SetPageUptodate(page);
>> + default:
>> + BUG();
>
> Typically, the way you want to address this is initialize ret to 0
> at declaration time if not every control path will set that value.
>
At least, your suggestion sounds reasonable.
But I am also aware that normally need content 'default' for 'switch',
so I choose this fix way.
And sorry, current patch is incorrect (need 'break' before 'default'),
so if no additional suggestions or discussions or completions, I
will/should send patch v2 for it.
Thanks.
--
Chen Gang
Open, share, and attitude like air, water and life which God blessed
next prev parent reply other threads:[~2013-12-10 2:14 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-09 2:51 [PATCH] mm/zswap.c: add BUG() for default case in zswap_writeback_entry() Chen Gang
2013-12-09 2:51 ` Chen Gang
2013-12-09 9:54 ` James Hogan
2013-12-09 9:54 ` James Hogan
2013-12-09 10:11 ` Chen Gang
2013-12-09 10:11 ` Chen Gang
2013-12-09 10:18 ` James Hogan
2013-12-09 10:18 ` James Hogan
2013-12-09 11:21 ` Chen Gang
2013-12-09 11:40 ` James Hogan
2013-12-09 11:40 ` James Hogan
2013-12-09 13:34 ` Chen Gang
2013-12-09 13:34 ` Chen Gang
2013-12-09 15:36 ` Seth Jennings
2013-12-09 15:36 ` Seth Jennings
2013-12-10 2:16 ` Chen Gang [this message]
2013-12-10 2:16 ` Chen Gang
2013-12-11 2:11 ` [PATCH v2] " Chen Gang
2013-12-11 2:11 ` Chen Gang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52A67973.20904@gmail.com \
--to=gang.chen.5i5j@gmail.com \
--cc=james.hogan@imgtec.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=sjenning@linux.vnet.ibm.com \
--cc=sjennings@variantweb.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.