Fix some coverity and cppcheck issues

This commit is contained in:
heckflosse
2017-06-18 18:40:40 +02:00
parent ae67344f16
commit 8aff354df9
14 changed files with 30 additions and 27 deletions

View File

@@ -52,7 +52,6 @@ namespace
// Opens a file for binary writing and request exclusive lock (cases were you need "wb" mode plus locking)
FILE* g_fopen_withBinaryAndLock(const Glib::ustring& fname)
{
FILE* f = nullptr;
#ifdef WIN32
@@ -61,6 +60,7 @@ FILE* g_fopen_withBinaryAndLock(const Glib::ustring& fname)
std::unique_ptr<wchar_t, GFreeFunc> wfname (reinterpret_cast<wchar_t*>(g_utf8_to_utf16 (fname.c_str (), -1, NULL, NULL, NULL)), g_free);
HANDLE hFile = CreateFileW ( wfname.get (), GENERIC_READ | GENERIC_WRITE, 0 /* no sharing allowed */, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
FILE* f = nullptr;
if (hFile != INVALID_HANDLE_VALUE) {
f = _fdopen (_open_osfhandle ((intptr_t)hFile, 0), "wb");
@@ -68,7 +68,7 @@ FILE* g_fopen_withBinaryAndLock(const Glib::ustring& fname)
#else
f = ::g_fopen (fname.c_str (), "wb");
FILE* f = ::g_fopen (fname.c_str (), "wb");
#endif