lkml.org 
[lkml]   [2013]   [Dec]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] mm/zswap.c: add BUG() for default case in zswap_writeback_entry()
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.

Seth

> }
>
> /* move it to the tail of the inactive list after end_writeback */
> --
> 1.7.7.6
>
> --
> 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>


\
 
 \ /
  Last update: 2013-12-09 17:41    [W:0.095 / U:0.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site