Skip to content
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
10 changes: 5 additions & 5 deletions src/coreclr/dlls/mscorpe/pewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ HRESULT CBlobFetcher::Write(FILE* file)
size_t dwWritten = 0;
if ((dwWritten = fwrite(m_pIndex[idx].GetRawDataStart(), 1, length, file)) <= 0)
{
return HRESULTFromErrno();
return HRESULTFromErr(ferror(file));
}
_ASSERTE(dwWritten == length);
}
Expand Down Expand Up @@ -1337,7 +1337,7 @@ HRESULT PEWriter::Open(_In_ LPCWSTR fileName)
int err = fopen_lp(&m_file, fileName, W("wb"));

if (err != 0)
hr = HRESULTFromErrno();
hr = HRESULTFromErr(err);

return hr;
}
Expand All @@ -1348,7 +1348,7 @@ HRESULT PEWriter::Seek(int offset)
if (fseek(m_file, offset, SEEK_SET) == 0)
return S_OK;
else
return HRESULTFromErrno();
return HRESULTFromErr(ferror(m_file));
}

HRESULT PEWriter::Write(const void *data, int size)
Expand All @@ -1375,7 +1375,7 @@ HRESULT PEWriter::Write(const void *data, int size)
_ASSERTE(dwWritten == (size_t)size);
}
else
hr = HRESULTFromErrno();
hr = HRESULTFromErr(ferror(m_file));
}

return hr;
Expand All @@ -1401,7 +1401,7 @@ HRESULT PEWriter::Close()
if (err == 0)
hr = S_OK;
else
hr = HRESULTFromErrno();
hr = HRESULTFromErr(err);

m_file = NULL;

Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/ilasm/asmman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ void AsmMan::EndAssembly()
if (err != 0)
{
MAKE_UTF8PTR_FROMWIDE(keySourceNameUtf8, ((Assembler*)m_pAssembler)->m_wzKeySourceName);
report->error("Failed to open key file '%s': 0x%08X\n",keySourceNameUtf8,err);
report->error("Failed to open key file '%s': 0x%08X\n",keySourceNameUtf8,HRESULTFromErr(err));
m_pCurAsmRef = NULL;
return;
}
Expand Down Expand Up @@ -438,9 +438,9 @@ void AsmMan::EndAssembly()
size_t dwBytesRead;

if ((dwBytesRead = fread(m_sStrongName.m_pbPublicKey, 1, m_sStrongName.m_cbPublicKey, fp)) < m_sStrongName.m_cbPublicKey) {
HRESULT hr = HRESULTFromErrno();
HRESULT hr = HRESULTFromErr(ferror(fp));
MAKE_UTF8PTR_FROMWIDE(keySourceNameUtf8, ((Assembler*)m_pAssembler)->m_wzKeySourceName);
report->error("Failed to read key file '%s': 0x%d\n",keySourceNameUtf8,hr);
report->error("Failed to read key file '%s': 0x%08X\n",keySourceNameUtf8,hr);
m_pCurAsmRef = NULL;
fclose(fp);
return;
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/minipal/Unix/dn-stdio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ int fsetpos_64(FILE* stream, int64_t pos)
#define ERROR_ALREADY_EXISTS 183L
#define ERROR_FILENAME_EXCED_RANGE 206L

HRESULT HRESULTFromErrno()
HRESULT HRESULTFromErr(int err)
{
// maps the common I/O errors
// based on FILEGetLastErrorFromErrno

int32_t win32Err;

switch(errno)
switch(err)
{
case 0:
win32Err = ERROR_SUCCESS;
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/minipal/Windows/dn-stdio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ int fsetpos_64(FILE* stream, int64_t pos)
return fsetpos(stream, &fpos);
}

HRESULT HRESULTFromErrno()
HRESULT HRESULTFromErr(int err)
{
// maps the common I/O errors
// based on FILEGetLastErrorFromErrno

// stdio functions aren't guaranteed to preserve GetLastError.
// errno should be used as source of truth.
// errno/ferror should be used as source of truth.

DWORD win32Err;

switch(errno)
switch(err)
{
case 0:
win32Err = ERROR_SUCCESS;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/minipal/dn-stdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ int u16_fopen_s(FILE** stream, const WCHAR* path, const WCHAR* mode);
int64_t fgetsize(FILE* stream);
int64_t ftell_64(FILE* stream);
int fsetpos_64(FILE* stream, int64_t pos);
HRESULT HRESULTFromErrno();
HRESULT HRESULTFromErr(int err);
Loading