aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2016-12-12 19:42:28 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-12-12 21:55:07 -0500
commit23f919d4ad0eb325595f10f55be4301b2965d6d6 (patch)
treeec43970f3c76f8ae91776e5accce1aff2f9fe828
parent6afcf8ef0ca0a69d014f8edb613d94821f0ae700 (diff)
shmem: avoid maybe-uninitialized warning
After enabling -Wmaybe-uninitialized warnings, we get a false-postive warning for shmem: mm/shmem.c: In function `shmem_getpage_gfp': include/linux/spinlock.h:332:21: error: `info' may be used uninitialized in this function [-Werror=maybe-uninitialized] This can be easily avoided, since the correct 'info' pointer is known at the time we first enter the function, so we can simply move the initialization up. Moving it before the first label avoids the warning and lets us remove two later initializations. Note that the function is so hard to read that it not only confuses the compiler, but also most readers and without this patch it could\ easily break if one of the 'goto's changed. Link: https://www.spinics.net/lists/kernel/msg2368133.html Link: http://lkml.kernel.org/r/20161024205725.786455-1-arnd@arndb.de Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Michal Hocko <mhocko@suse.com> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Hugh Dickins <hughd@google.com> Cc: Andreas Gruenbacher <agruenba@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/shmem.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/mm/shmem.c b/mm/shmem.c
index 9d32e1cb9f38..ba0d7644ee20 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1539,7 +1539,7 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index,
1539 struct mm_struct *fault_mm, int *fault_type) 1539 struct mm_struct *fault_mm, int *fault_type)
1540{ 1540{
1541 struct address_space *mapping = inode->i_mapping; 1541 struct address_space *mapping = inode->i_mapping;
1542 struct shmem_inode_info *info; 1542 struct shmem_inode_info *info = SHMEM_I(inode);
1543 struct shmem_sb_info *sbinfo; 1543 struct shmem_sb_info *sbinfo;
1544 struct mm_struct *charge_mm; 1544 struct mm_struct *charge_mm;
1545 struct mem_cgroup *memcg; 1545 struct mem_cgroup *memcg;
@@ -1589,7 +1589,6 @@ repeat:
1589 * Fast cache lookup did not find it: 1589 * Fast cache lookup did not find it:
1590 * bring it back from swap or allocate. 1590 * bring it back from swap or allocate.
1591 */ 1591 */
1592 info = SHMEM_I(inode);
1593 sbinfo = SHMEM_SB(inode->i_sb); 1592 sbinfo = SHMEM_SB(inode->i_sb);
1594 charge_mm = fault_mm ? : current->mm; 1593 charge_mm = fault_mm ? : current->mm;
1595 1594
@@ -1837,7 +1836,6 @@ unlock:
1837 put_page(page); 1836 put_page(page);
1838 } 1837 }
1839 if (error == -ENOSPC && !once++) { 1838 if (error == -ENOSPC && !once++) {
1840 info = SHMEM_I(inode);
1841 spin_lock_irq(&info->lock); 1839 spin_lock_irq(&info->lock);
1842 shmem_recalc_inode(inode); 1840 shmem_recalc_inode(inode);
1843 spin_unlock_irq(&info->lock); 1841 spin_unlock_irq(&info->lock);