Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc94cfb3

Browse files
committed
Minor cleanup for win32stat.c.
Ensure that CloseHandle() can't clobber the errno we set forfailure exits, and make a couple of tweaks for pgindent.Juan José Santamaría FlechaDiscussion:https://postgr.es/m/CAC+AXB0g44SbvSpC86o_1HWh8TAU2pZrMRW6tJT-dkijotx5Qg@mail.gmail.com
1 parentfe27009 commitc94cfb3

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

‎src/port/win32stat.c

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,12 @@ typedef struct _FILE_STANDARD_INFORMATION
4040
#endif/* !defined(__MINGW32__) &&
4141
* !defined(__MINGW64__) */
4242

43-
typedefNTSTATUS(NTAPI*PFN_NTQUERYINFORMATIONFILE)
44-
(
45-
INHANDLEFileHandle,
46-
OUTPIO_STATUS_BLOCKIoStatusBlock,
47-
OUTPVOIDFileInformation,
48-
INULONGLength,
49-
INFILE_INFORMATION_CLASSFileInformationClass
50-
);
43+
typedefNTSTATUS (NTAPI*PFN_NTQUERYINFORMATIONFILE)
44+
(INHANDLEFileHandle,
45+
OUTPIO_STATUS_BLOCKIoStatusBlock,
46+
OUTPVOIDFileInformation,
47+
INULONGLength,
48+
INFILE_INFORMATION_CLASSFileInformationClass);
5149

5250
staticPFN_NTQUERYINFORMATIONFILE_NtQueryInformationFile=NULL;
5351

@@ -101,8 +99,8 @@ fileattr_to_unixmode(int attr)
10199
uxmode |= (unsigned short) ((attr&FILE_ATTRIBUTE_DIRECTORY) ?
102100
(_S_IFDIR) : (_S_IFREG));
103101

104-
uxmode |= (unsigned short) (attr&FILE_ATTRIBUTE_READONLY) ?
105-
(_S_IREAD) : (_S_IREAD |_S_IWRITE);
102+
uxmode |= (unsigned short) ((attr&FILE_ATTRIBUTE_READONLY) ?
103+
(_S_IREAD) : (_S_IREAD |_S_IWRITE));
106104

107105
/* there is no need to simulate _S_IEXEC using CMD's PATHEXT extensions */
108106
uxmode |=_S_IEXEC;
@@ -149,8 +147,8 @@ fileinfo_to_stat(HANDLE hFile, struct stat *buf)
149147
buf->st_mode=fileattr_to_unixmode(fiData.dwFileAttributes);
150148
buf->st_nlink=fiData.nNumberOfLinks;
151149

152-
buf->st_size= (((uint64)fiData.nFileSizeHigh) <<32) |
153-
(uint64)fiData.nFileSizeLow;
150+
buf->st_size= ((((uint64)fiData.nFileSizeHigh) <<32) |
151+
fiData.nFileSizeLowi);
154152

155153
return0;
156154
}
@@ -220,17 +218,21 @@ _pgstat64(const char *name, struct stat *buf)
220218
LoadNtdll();
221219
if (ntdll==NULL)
222220
{
223-
_dosmaperr(GetLastError());
221+
DWORDerr=GetLastError();
222+
224223
CloseHandle(hFile);
224+
_dosmaperr(err);
225225
return-1;
226226
}
227227

228228
_NtQueryInformationFile= (PFN_NTQUERYINFORMATIONFILE)
229229
GetProcAddress(ntdll,"NtQueryInformationFile");
230230
if (_NtQueryInformationFile==NULL)
231231
{
232-
_dosmaperr(GetLastError());
232+
DWORDerr=GetLastError();
233+
233234
CloseHandle(hFile);
235+
_dosmaperr(err);
234236
return-1;
235237
}
236238
}
@@ -239,16 +241,20 @@ _pgstat64(const char *name, struct stat *buf)
239241
sizeof(standardInfo),
240242
FileStandardInformation)))
241243
{
242-
_dosmaperr(GetLastError());
244+
DWORDerr=GetLastError();
245+
243246
CloseHandle(hFile);
247+
_dosmaperr(err);
244248
return-1;
245249
}
246250
#else
247251
if (!GetFileInformationByHandleEx(hFile,FileStandardInfo,&standardInfo,
248252
sizeof(standardInfo)))
249253
{
250-
_dosmaperr(GetLastError());
254+
DWORDerr=GetLastError();
255+
251256
CloseHandle(hFile);
257+
_dosmaperr(err);
252258
return-1;
253259
}
254260
#endif/* _WIN32_WINNT < 0x0600 */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp