mirror of
https://github.com/yuzu-emu/breakpad.git
synced 2024-11-24 06:35:46 +01:00
linux_core_dumper: add explicit casts for exception fields
Some of the fields we save might have signed types depending on the system (e.g. `typedef int pid_t`). Depending on the toolchain, we can trip -Werror=narrowing failures like: src/client/linux/minidump_writer/linux_core_dumper.cc:248:66: error: narrowing conversion of ‘(__pid_t)info->siginfo_t::_sifields.siginfo_t::<anonymous union>::_kill.siginfo_t::<anonymous union>::<anonymous struct>::si_pid’ from ‘__pid_t {aka int}’ to ‘long unsigned int’ inside { } [-Werror=narrowing] set_crash_exception_info({info->si_pid, info->si_uid}); ^^^^^^ src/client/linux/minidump_writer/linux_core_dumper.cc:252:71: error: narrowing conversion of ‘(int)info->siginfo_t::_sifields.siginfo_t::<anonymous union>::_sigsys.siginfo_t::<anonymous union>::<anonymous struct>::_syscall’ from ‘int’ to ‘long unsigned int’ inside { } [-Werror=narrowing] set_crash_exception_info({info->si_syscall, info->si_arch}); ^^^^^^^^^^ Since the exception info fields are all uint64_t which should be large enough to handle all the fields in the siginfo_t structure, add casts for all the assignments to avoid these errors. We have implicit casts even without them, so we aren't changing behavior. Bug: google-breakpad:791 Bug: chromium:945653 Change-Id: Ib04e015998f08b857159ac13e9a065a66d228d49 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1544862 Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
parent
b4a0eb2d06
commit
e2b3b80e43
@ -242,14 +242,21 @@ bool LinuxCoreDumper::EnumerateThreads() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set crash_exception_info for common signals.
|
// Set crash_exception_info for common signals. Since exception info is
|
||||||
|
// unsigned, but some of these fields might be signed, we always cast.
|
||||||
switch (info->si_signo) {
|
switch (info->si_signo) {
|
||||||
case MD_EXCEPTION_CODE_LIN_SIGKILL:
|
case MD_EXCEPTION_CODE_LIN_SIGKILL:
|
||||||
set_crash_exception_info({info->si_pid, info->si_uid});
|
set_crash_exception_info({
|
||||||
|
static_cast<uint64_t>(info->si_pid),
|
||||||
|
static_cast<uint64_t>(info->si_uid),
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
case MD_EXCEPTION_CODE_LIN_SIGSYS:
|
case MD_EXCEPTION_CODE_LIN_SIGSYS:
|
||||||
#ifdef si_syscall
|
#ifdef si_syscall
|
||||||
set_crash_exception_info({info->si_syscall, info->si_arch});
|
set_crash_exception_info({
|
||||||
|
static_cast<uint64_t>(info->si_syscall),
|
||||||
|
static_cast<uint64_t>(info->si_arch),
|
||||||
|
});
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user