Skip to content

Commit d98711d

Browse files
committed
Silence a few compiler warnings from gcc on MinGW.
Most of these cast DWORD to int or unsigned int for printf type handling. This is safe even on 64 bit architectures because a DWORD is always 32 bits. In one case a variable is initialised to keep the compiler happy.
1 parent 970d8a3 commit d98711d

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/backend/port/win32/crashdump.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,17 @@ crashDumpHandler(struct _EXCEPTION_POINTERS * pExceptionInfo)
135135

136136
systemTicks = GetTickCount();
137137
snprintf(dumpPath, _MAX_PATH,
138-
"crashdumps\\postgres-pid%0i-%0i.mdmp", selfPid, systemTicks);
138+
"crashdumps\\postgres-pid%0i-%0i.mdmp",
139+
(int) selfPid, (int) systemTicks);
139140
dumpPath[_MAX_PATH - 1] = '\0';
140141

141142
dumpFile = CreateFile(dumpPath, GENERIC_WRITE, FILE_SHARE_WRITE,
142143
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,
143144
NULL);
144145
if (dumpFile == INVALID_HANDLE_VALUE)
145146
{
146-
write_stderr("could not open crash dump file %s for writing: error code %d\n",
147-
dumpPath, GetLastError());
147+
write_stderr("could not open crash dump file %s for writing: error code %u\n",
148+
dumpPath, (unsigned int) GetLastError());
148149
return EXCEPTION_CONTINUE_SEARCH;
149150
}
150151

@@ -153,7 +154,7 @@ crashDumpHandler(struct _EXCEPTION_POINTERS * pExceptionInfo)
153154
write_stderr("wrote crash dump to %s\n", dumpPath);
154155
else
155156
write_stderr("could not write crash dump to %s: error code %08x\n",
156-
dumpPath, GetLastError());
157+
dumpPath, (unsigned int) GetLastError());
157158

158159
CloseHandle(dumpFile);
159160
}

src/backend/port/win32_latch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ WaitLatchOrSocket(volatile Latch *latch, SOCKET sock, bool forRead,
9494
DWORD rc;
9595
HANDLE events[3];
9696
HANDLE latchevent;
97-
HANDLE sockevent;
97+
HANDLE sockevent = WSA_INVALID_EVENT; /* silence compiler */
9898
int numevents;
9999
int result = 0;
100100

@@ -161,7 +161,7 @@ WaitLatchOrSocket(volatile Latch *latch, SOCKET sock, bool forRead,
161161
break;
162162
}
163163
else if (rc != WAIT_OBJECT_0)
164-
elog(ERROR, "unexpected return code from WaitForMultipleObjects(): %d", rc);
164+
elog(ERROR, "unexpected return code from WaitForMultipleObjects(): %d", (int) rc);
165165
}
166166

167167
/* Clean up the handle we created for the socket */

0 commit comments

Comments
 (0)