* [PATCH] swapfile.c: Initialize a variable.
@ 2011-10-06 4:41 Il Han
2011-10-24 15:06 ` Michal Hocko
0 siblings, 1 reply; 2+ messages in thread
From: Il Han @ 2011-10-06 4:41 UTC (permalink / raw)
To: linux-mm; +Cc: Il Han
Initialize the variable to remove the following warning.
mm/swapfile.c:2028: warning: 'span' may be used uninitialized in this function
Initialize it.
Signed-off-by: Il Han <corone.il.han@gmail.com>
---
mm/swapfile.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 17bc224..d5ca685 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2016,7 +2016,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
int error;
union swap_header *swap_header;
int nr_extents;
- sector_t span;
+ sector_t span = 0;
unsigned long maxpages;
unsigned char *swap_map = NULL;
struct page *page = NULL;
--
1.7.4.1
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] swapfile.c: Initialize a variable.
2011-10-06 4:41 [PATCH] swapfile.c: Initialize a variable Il Han
@ 2011-10-24 15:06 ` Michal Hocko
0 siblings, 0 replies; 2+ messages in thread
From: Michal Hocko @ 2011-10-24 15:06 UTC (permalink / raw)
To: Il Han; +Cc: linux-mm
On Thu 06-10-11 13:41:14, Il Han wrote:
> Initialize the variable to remove the following warning.
>
> mm/swapfile.c:2028: warning: 'span' may be used uninitialized in this function
>
> Initialize it.
It looks that the warning is bogus because span is always initialized
if nr_extents >=0. Check out setup_swap_map_and_extents and
setup_swap_extents (for S_ISBLK it is trivial and for S_ISREG we are
setting the value after we jump out of the loop and all error cases go
either to out directly or through bad_bmap labels).
It should be much better to use uninitialized_var instead if we just
want to shut up compiler.
>
> Signed-off-by: Il Han <corone.il.han@gmail.com>
> ---
> mm/swapfile.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/mm/swapfile.c b/mm/swapfile.c
> index 17bc224..d5ca685 100644
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -2016,7 +2016,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
> int error;
> union swap_header *swap_header;
> int nr_extents;
> - sector_t span;
> + sector_t span = 0;
> unsigned long maxpages;
> unsigned char *swap_map = NULL;
> struct page *page = NULL;
> --
> 1.7.4.1
>
> --
> 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/ .
> Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
--
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9
Czech Republic
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-10-24 15:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-06 4:41 [PATCH] swapfile.c: Initialize a variable Il Han
2011-10-24 15:06 ` Michal Hocko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).