Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: fix level 1 msvc warnings #1295

Merged
merged 1 commit into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libco/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#endif

#if defined(_MSC_VER)
#pragma section(".text", execute, read)
#pragma section(".text")
#define section(name) __declspec(allocate(".text"))
#elif defined(__APPLE__)
#define section(name) __attribute__((section("__TEXT,__" #name)))
Expand Down
7 changes: 4 additions & 3 deletions nall/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ endif
# global compiler flags
ifeq ($(cl),true)
flags.c = -nologo -W0 -Fd$(object.path)/ -TC -std:c11
flags.cpp = -nologo -W0 -Fd$(object.path)/ -TP -std:c++17 -EHsc
options = -nologo $(if $(findstring clang,$(compiler)),-fuse-ld=lld) -link
flags.c = -TC -std:c11
flags.cpp = -TP -std:c++17 -EHsc
flags += -nologo -W1 -Fd$(object.path)/
options += -nologo $(if $(findstring clang,$(compiler)),-fuse-ld=lld) -link
else
flags.c = -x c -std=c11
flags.cpp = -x c++ -std=c++17
Expand Down
4 changes: 2 additions & 2 deletions nall/file-buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,10 @@ struct file_buffer {

auto bufferSynchronize() -> void {
if(!fileHandle) return;
if(bufferOffset == (fileOffset & ~(buffer.size() - 1))) return;
if(bufferOffset == (fileOffset & ~u64(buffer.size() - 1))) return;

bufferFlush();
bufferOffset = fileOffset & ~(buffer.size() - 1);
bufferOffset = fileOffset & ~u64(buffer.size() - 1);
fseek(fileHandle, bufferOffset, SEEK_SET);
u64 length = bufferOffset + buffer.size() <= fileSize ? buffer.size() : fileSize & buffer.size() - 1;
if(length) (void)fread(buffer.data(), 1, length, fileHandle);
Expand Down
17 changes: 10 additions & 7 deletions nall/file-map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,17 @@ NALL_HEADER_INLINE auto file_map::open(const string& filename, u32 mode_) -> boo

_file = CreateFileW(utf16_t(filename), desiredAccess, FILE_SHARE_READ, nullptr,
creationDisposition, FILE_ATTRIBUTE_NORMAL, nullptr);
if(_file == INVALID_HANDLE_VALUE) return false;
if(_file == INVALID_HANDLE_VALUE) {
_file = nullptr;
return false;
}

_size = GetFileSize(_file, nullptr);

_map = CreateFileMapping(_file, nullptr, protection, 0, _size, nullptr);
if(_map == INVALID_HANDLE_VALUE) {
if(_map == nullptr) {
CloseHandle(_file);
_file = INVALID_HANDLE_VALUE;
_file = nullptr;
return false;
}

Expand All @@ -62,14 +65,14 @@ NALL_HEADER_INLINE auto file_map::close() -> void {
_data = nullptr;
}

if(_map != INVALID_HANDLE_VALUE) {
if(_map != nullptr) {
CloseHandle(_map);
_map = INVALID_HANDLE_VALUE;
_map = nullptr;
}

if(_file != INVALID_HANDLE_VALUE) {
if(_file != nullptr) {
CloseHandle(_file);
_file = INVALID_HANDLE_VALUE;
_file = nullptr;
}

_open = false;
Expand Down
8 changes: 4 additions & 4 deletions nall/file-map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ struct file_map {

#if defined(API_WINDOWS)

HANDLE _file = INVALID_HANDLE_VALUE;
HANDLE _map = INVALID_HANDLE_VALUE;
HANDLE _file = nullptr;
HANDLE _map = nullptr;

public:
auto operator=(file_map&& source) -> file_map& {
Expand All @@ -67,8 +67,8 @@ struct file_map {
source._open = false;
source._data = nullptr;
source._size = 0;
source._file = INVALID_HANDLE_VALUE;
source._map = INVALID_HANDLE_VALUE;
source._file = nullptr;
source._map = nullptr;

return *this;
}
Expand Down
2 changes: 2 additions & 0 deletions nall/intrinsics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ namespace nall {
static constexpr bool GCC = 0;
static constexpr bool Microsoft = 1;
};
#pragma warning(disable:4804) //unsafe use of type 'bool' in operation
#pragma warning(disable:4805) //unsafe mix of type 'bool' and type 'type' in operation
#pragma warning(disable:4996) //libc "deprecation" warnings
#else
#error "unable to detect compiler"
Expand Down
4 changes: 0 additions & 4 deletions nall/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ namespace Math {
#define MSG_NOSIGNAL 0
#define PATH_MAX 260

#if !defined(INVALID_HANDLE_VALUE)
#define INVALID_HANDLE_VALUE ((HANDLE)-1)
#endif

typedef void* HANDLE;

inline auto access(const char* path, int amode) -> int { return _waccess(nall::utf16_t(path), amode); }
Expand Down
Loading