From 435db18eb2ac3dd380ede38f66ee3fbb79923e64 Mon Sep 17 00:00:00 2001 From: BlackEagle Date: Sat, 3 Jun 2017 10:34:59 +0200 Subject: [PATCH 1/4] remove some mingw gcc warnings in diskfile Signed-off-by: BlackEagle --- src/diskfile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diskfile.cpp b/src/diskfile.cpp index 50ece580..33adc9a1 100644 --- a/src/diskfile.cpp +++ b/src/diskfile.cpp @@ -43,7 +43,7 @@ static char THIS_FILE[]=__FILE__; DiskFile::DiskFile(void) { - filename; + filename = ""; filesize = 0; offset = 0; @@ -297,7 +297,7 @@ string DiskFile::GetCanonicalPathname(string filename) char *filepart; // Resolve a relative path to a full path - int length = ::GetFullPathName(filename.c_str(), sizeof(fullname), fullname, &filepart); + unsigned int length = ::GetFullPathName(filename.c_str(), sizeof(fullname), fullname, &filepart); if (length <= 0 || sizeof(fullname) < length) return filename; From 6841274d92e91b4f4d41a16c17386fa2b870e8e6 Mon Sep 17 00:00:00 2001 From: BlackEagle Date: Sat, 3 Jun 2017 10:32:51 +0200 Subject: [PATCH 2/4] make sure u32 definition is consistent Signed-off-by: BlackEagle --- src/par2cmdline.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/par2cmdline.h b/src/par2cmdline.h index 12c96ecd..119e490f 100644 --- a/src/par2cmdline.h +++ b/src/par2cmdline.h @@ -52,8 +52,8 @@ typedef unsigned char u8; typedef signed char i8; typedef unsigned short u16; typedef signed short i16; -typedef unsigned long u32; -typedef signed long i32; +typedef unsigned int u32; +typedef signed int i32; typedef unsigned __int64 u64; typedef signed __int64 i64; From 9669e4c8e37033c7e8de58420c35fb26e663fac7 Mon Sep 17 00:00:00 2001 From: BlackEagle Date: Sat, 3 Jun 2017 10:40:51 +0200 Subject: [PATCH 3/4] DWORD is long unsigned int so change format to %lu Signed-off-by: BlackEagle --- src/diskfile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/diskfile.cpp b/src/diskfile.cpp index 33adc9a1..0c0707a1 100644 --- a/src/diskfile.cpp +++ b/src/diskfile.cpp @@ -1073,7 +1073,7 @@ string DiskFile::ErrorMessage(DWORD error) else { char message[40]; - snprintf(message, sizeof(message), "Unknown error code (%d)", error); + snprintf(message, sizeof(message), "Unknown error code (%lu)", error); result = message; } From 1713190de7af346c29496a080815835071d3b17f Mon Sep 17 00:00:00 2001 From: BlackEagle Date: Sat, 3 Jun 2017 10:52:14 +0200 Subject: [PATCH 4/4] first get pointer then get low and high offset, 'fixes' gcc -Wstrict-aliasing warning Signed-off-by: BlackEagle --- src/diskfile.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/diskfile.cpp b/src/diskfile.cpp index 0c0707a1..4832aa7a 100644 --- a/src/diskfile.cpp +++ b/src/diskfile.cpp @@ -112,8 +112,9 @@ bool DiskFile::Create(string _filename, u64 _filesize) if (filesize > 0) { // Seek to the end of the file - LONG lowoffset = ((LONG*)&filesize)[0]; - LONG highoffset = ((LONG*)&filesize)[1]; + LONG* ptrfilesize = (LONG*)&filesize; + LONG lowoffset = ptrfilesize[0]; + LONG highoffset = ptrfilesize[1]; if (INVALID_SET_FILE_POINTER == SetFilePointer(hFile, lowoffset, &highoffset, FILE_BEGIN)) { @@ -157,8 +158,9 @@ bool DiskFile::Write(u64 _offset, const void *buffer, size_t length) if (offset != _offset) { - LONG lowoffset = ((LONG*)&_offset)[0]; - LONG highoffset = ((LONG*)&_offset)[1]; + LONG* ptrfilesize = (LONG*)&filesize; + LONG lowoffset = ptrfilesize[0]; + LONG highoffset = ptrfilesize[1]; // Seek to the required offset if (INVALID_SET_FILE_POINTER == SetFilePointer(hFile, lowoffset, &highoffset, FILE_BEGIN)) @@ -242,8 +244,9 @@ bool DiskFile::Read(u64 _offset, void *buffer, size_t length) if (offset != _offset) { - LONG lowoffset = ((LONG*)&_offset)[0]; - LONG highoffset = ((LONG*)&_offset)[1]; + LONG* ptrfilesize = (LONG*)&filesize; + LONG lowoffset = ptrfilesize[0]; + LONG highoffset = ptrfilesize[1]; // Seek to the required offset if (INVALID_SET_FILE_POINTER == SetFilePointer(hFile, lowoffset, &highoffset, FILE_BEGIN))