Skip to content

Commit 81edc27

Browse files
committed
Fix two warnings on MinGW
1 parent dc52487 commit 81edc27

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

src/asm/section.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -934,8 +934,14 @@ bool sect_BinaryFile(std::string const &name, uint32_t startPos) {
934934
Defer closeFile{[&] { fclose(file); }};
935935

936936
if (fseek(file, 0, SEEK_END) == 0) {
937-
if (startPos > ftell(file)) {
938-
error("Specified start position is greater than length of file \"%s\"", name.c_str());
937+
if (unsigned long fsize = ftell(file);
938+
startPos > fsize) { // `ftell` cannot fail here, since `fseek` succeeded.
939+
error(
940+
"Specified start position (%" PRIu32 ") is greater than length of \"%s\" (%lu)",
941+
startPos,
942+
name.c_str(),
943+
fsize
944+
);
939945
return false;
940946
}
941947
// The file is seekable; skip to the specified start position
@@ -989,8 +995,14 @@ bool sect_BinaryFileSlice(std::string const &name, uint32_t startPos, uint32_t l
989995
Defer closeFile{[&] { fclose(file); }};
990996

991997
if (fseek(file, 0, SEEK_END) == 0) {
992-
if (long fsize = ftell(file); startPos > fsize) {
993-
error("Specified start position is greater than length of file \"%s\"", name.c_str());
998+
if (unsigned long fsize = ftell(file);
999+
startPos > fsize) { // `ftell` cannot fail here, since `fseek` succeeded.
1000+
error(
1001+
"Specified start position (%" PRIu32 ") is greater than length of \"%s\" (%lu)",
1002+
startPos,
1003+
name.c_str(),
1004+
fsize
1005+
);
9941006
return false;
9951007
} else if (startPos + length > fsize) {
9961008
error(

test/asm/incbin-start-bad.err

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
error: Specified start position is greater than length of file "data.bin"
1+
error: Specified start position (999) is greater than length of "data.bin" (123)
22
at incbin-start-bad.asm(3)
3-
error: Specified start position is greater than length of file "data.bin"
3+
error: Specified start position (999) is greater than length of "data.bin" (123)
44
at incbin-start-bad.asm(4)
55
Assembly aborted with 2 errors

test/gfx/rgbgfx_test.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ static char *execProg(char const *name, char * const *argv) {
320320
nullptr,
321321
errnum,
322322
0,
323-
(LPTSTR)&buf,
323+
reinterpret_cast<LPTSTR>(&buf),
324324
0,
325325
nullptr
326326
)
@@ -341,7 +341,8 @@ static char *execProg(char const *name, char * const *argv) {
341341

342342
STARTUPINFOA startupInfo;
343343
GetStartupInfoA(&startupInfo);
344-
STARTUPINFOA childStartupInfo = {sizeof(startupInfo)};
344+
STARTUPINFOA childStartupInfo = {};
345+
childStartupInfo.cb = sizeof(startupInfo);
345346

346347
PROCESS_INFORMATION child;
347348
if (CreateProcessA(

0 commit comments

Comments
 (0)