Skip to content

Commit

Permalink
Minor formatting changes. Hope this didn't break anything on windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
kpu committed Sep 17, 2015
1 parent 4e3fca6 commit b982135
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
18 changes: 8 additions & 10 deletions util/exception.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,14 @@ OverflowException::OverflowException() throw() {}
OverflowException::~OverflowException() throw() {}

#if defined(_WIN32) || defined(_WIN64)
WindowsException::WindowsException(unsigned int last_error) throw() {
char error_msg[256] = "";
if (!FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, last_error, LANG_NEUTRAL, error_msg, sizeof(error_msg), NULL))
{
*this << "Windows error " << GetLastError() << " while formatting Windows error " << last_error << ". ";
}
else
{
*this << "Windows error " << last_error << ": " << error_msg;
}
WindowsException::WindowsException() throw() {
unsigned int last_error = GetLastError();
char error_msg[256] = "";
if (!FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, last_error, LANG_NEUTRAL, error_msg, sizeof(error_msg), NULL)) {
*this << "Windows error " << GetLastError() << " while formatting Windows error " << last_error << ". ";
} else {
*this << "Windows error " << last_error << ": " << error_msg;
}
}
WindowsException::~WindowsException() throw() {}
#endif
Expand Down
6 changes: 3 additions & 3 deletions util/exception.hh
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ inline std::size_t CheckOverflow(uint64_t value) {
#if defined(_WIN32) || defined(_WIN64)
/* Thrown for Windows specific operations. */
class WindowsException : public Exception {
public:
WindowsException(unsigned int last_error) throw();
~WindowsException() throw();
public:
WindowsException() throw();
~WindowsException() throw();
};
#endif

Expand Down
5 changes: 2 additions & 3 deletions util/file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ std::size_t PartialRead(int fd, void *to, std::size_t amount) {
{
DWORD last_error = GetLastError();
if (last_error != ERROR_NOT_ENOUGH_MEMORY || !ReadFile(file_handle, to, smaller_size, &ret, NULL)) {

UTIL_THROW_ARG(WindowsException, (last_error), "Windows error in ReadFile.");
UTIL_THROW(WindowsException, "Windows error in ReadFile.");
}
}
#else
Expand Down Expand Up @@ -241,7 +240,7 @@ void ErsatzPRead(int fd, void *to_void, std::size_t size, uint64_t off) {
memset(&overlapped, 0, sizeof(OVERLAPPED));
overlapped.Offset = static_cast<DWORD>(off);
overlapped.OffsetHigh = static_cast<DWORD>(off >> 32);
UTIL_THROW_IF(!ReadFile((HANDLE)_get_osfhandle(fd), to, reading, &ret, &overlapped), Exception, "ReadFile failed for offset " << off);
UTIL_THROW_IF(!ReadFile((HANDLE)_get_osfhandle(fd), to, reading, &ret, &overlapped), WindowsException, "ReadFile failed for offset " << off);
#else
ssize_t ret;
errno = 0;
Expand Down

0 comments on commit b982135

Please sign in to comment.