Skip to content

Commit fca0e40

Browse files
committed
deps/switchres: fix -Wformat warnings on 32-bit builds
Three -Wformat= warnings surface on i386 Linux where size_t is unsigned int and uint64_t is unsigned long long (both differ from x86_64, where the existing specifiers happen to match): display_linux.cpp:166 %ld on vector::size_type (size_t) custom_video_xrandr.cpp:679 %lx on uint64_t platform_data custom_video_xrandr.cpp:685 %lx on uint64_t platform_data The size_t case is signedness-only and benign in practice; switch to %zu, the C99 specifier intended for size_t. The uint64_t cases are an actual 32-bit truncation bug -- %lx reads four bytes off the stack on i386 cdecl, dropping the high 32 bits of platform_data and misaligning any following format arguments. Use %llx with an explicit (unsigned long long) cast, matching the raw-printf idiom Switchres uses everywhere else (no <inttypes.h> / PRIx64 elsewhere in the tree). deps/switchres/ is a verbatim mirror of antonioginer/switchres; this fix should also be sent upstream so the next sync doesn't reintroduce the warnings.
1 parent 07b6551 commit fca0e40

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

deps/switchres/custom_video_xrandr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,13 +676,13 @@ bool xrandr_timing::add_mode(modeline *mode)
676676
// remove unlinked modeline
677677
if (mode->platform_data)
678678
{
679-
log_error("XRANDR: <%d> (add_mode) [ERROR] remove mode [%04lx]\n", m_id, mode->platform_data);
679+
log_error("XRANDR: <%d> (add_mode) [ERROR] remove mode [%04llx]\n", m_id, (unsigned long long)mode->platform_data);
680680
XRRDestroyMode(m_pdisplay, mode->platform_data);
681681
mode->platform_data = 0;
682682
}
683683
}
684684
else
685-
log_verbose("XRANDR: <%d> (add_mode) mode %04lx %dx%d refresh %.6f added\n", m_id, mode->platform_data, mode->hactive, mode->vactive, mode->vfreq);
685+
log_verbose("XRANDR: <%d> (add_mode) mode %04llx %dx%d refresh %.6f added\n", m_id, (unsigned long long)mode->platform_data, mode->hactive, mode->vactive, mode->vfreq);
686686

687687
return ms_xerrors == 0;
688688
}

deps/switchres/display_linux.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ int linux_display::get_available_video_modes()
163163
video_modes.push_back(mode);
164164
backup_modes.push_back(mode);
165165

166-
log_verbose("Switchres: [%3ld] %4dx%4d @%3d%s%s %s: ", video_modes.size(), mode.width, mode.height, mode.refresh, mode.interlace ? "i" : "p", mode.type & MODE_DESKTOP ? "*" : "", mode.type & MODE_ROTATED ? "rot" : "");
166+
log_verbose("Switchres: [%3zu] %4dx%4d @%3d%s%s %s: ", video_modes.size(), mode.width, mode.height, mode.refresh, mode.interlace ? "i" : "p", mode.type & MODE_DESKTOP ? "*" : "", mode.type & MODE_ROTATED ? "rot" : "");
167167
log_mode(&mode);
168168
};
169169

0 commit comments

Comments
 (0)