summaryrefslogtreecommitdiff
path: root/store
diff options
context:
space:
mode:
authorCatalin Iacob <iacobcatalin@gmail.com>2012-03-14 23:35:49 +0100
committerStephan Bergmann <sbergman@redhat.com>2012-03-23 09:00:09 +0100
commit6776cb6f9cb91c3f86c4e66695eb7e9f4ffef715 (patch)
tree795d23b38e87e5372f877d26d0d57502e946e190 /store
parent547249832d5cde98c2973fd5eb31bd30cddb63b9 (diff)
Initialize m_hFile in FileMapping constructor.
GCC gives the following warning which breaks compilation when using --enable-werror: lockbyte.cxx: In function 'storeError store::FileLockBytes_createInstance(rtl::Reference<store::ILockBytes>&, rtl_uString*, storeAccessMode)': lockbyte.css:512:37: error: 'prephitmp.221' may be used uninitialized in this function [-Werror=uninitialized] lockbyte.cxx:906:1: note: 'prephitmp.221' was declared here It's not clear from GCC's message, but what it warns about is FileMapping::m_hFile. This is because of the following sequence: * xMapping.release() makes xMapping.m_value be a default constructed FileMapping * the xMapping local variable in store::FileLockBytes_createInstance gets destructed * ~ResourceHolder() calls ResourceHolder::reset * ResourceHolder::reset() calls FileMapping::UnmapFile::operator() passing m_value as rMapping * FileMapping::UnmapFile::operator() uses rMapping.m_hFile but rMapping is a default constructed FileMapping and therefore has m_hFile uninitialized Signed-off-by: Stephan Bergmann <sbergman@redhat.com>: To me, this looks more like a compiler error. Also note that ResourceHolder::reset only calls FileMapping::UnmapFile::operator() if tmp != value, which is not the case here, as both tmp and value are default- constructed. And FileMapping::operator!= is carefule not to use the potentially uninitialized m_hFile. But always intiializing m_hFile is probably not a bad idea, anyway. And if it helps a certain compiler, all the better.
Diffstat (limited to 'store')
-rw-r--r--store/source/lockbyte.cxx2
1 files changed, 1 insertions, 1 deletions
diff --git a/store/source/lockbyte.cxx b/store/source/lockbyte.cxx
index e28bffe48f9d..1a8bf81efd9e 100644
--- a/store/source/lockbyte.cxx
+++ b/store/source/lockbyte.cxx
@@ -478,7 +478,7 @@ struct FileMapping
sal_uInt32 m_nSize;
oslFileHandle m_hFile;
- FileMapping() : m_pAddr(0), m_nSize(0) {}
+ FileMapping() : m_pAddr(0), m_nSize(0), m_hFile() {}
bool operator != (FileMapping const & rhs) const
{