Fix up ~14 warnings about 'Implicit conversion loses integer precision' on iOS.

git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1281 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
dmaclach 2014-02-18 22:52:02 +00:00
parent 0c18b07255
commit 9315301a56
7 changed files with 29 additions and 25 deletions

View File

@ -780,7 +780,7 @@ int BreakpadGetCrashReportCount(BreakpadRef ref) {
Breakpad *breakpad = (Breakpad *)ref;
if (breakpad) {
return [breakpad->CrashReportsToUpload() count];
return static_cast<int>([breakpad->CrashReportsToUpload() count]);
}
} catch(...) { // don't let exceptions leave this C API
fprintf(stderr, "BreakpadGetCrashReportCount() : error\n");

View File

@ -166,6 +166,8 @@ bool IosExceptionMinidumpGenerator::WriteThreadStream(mach_port_t thread_id,
return MinidumpGenerator::WriteThreadStream(thread_id, thread);
size_t frame_count = [return_addresses_ count];
if (frame_count == 0)
return false;
UntypedMDRVA memory(&writer_);
size_t pointer_size = sizeof(uintptr_t);
size_t frame_record_size = 2 * pointer_size;
@ -176,7 +178,7 @@ bool IosExceptionMinidumpGenerator::WriteThreadStream(mach_port_t thread_id,
uintptr_t sp = stack_size - pointer_size;
uintptr_t fp = 0;
uintptr_t lr = 0;
for (int current_frame = frame_count - 1;
for (size_t current_frame = frame_count - 1;
current_frame > 0;
--current_frame) {
AppendToMemory(stack_memory.get(), sp, lr);

View File

@ -567,7 +567,7 @@ cpu_type_t DynamicImages::DetermineTaskCPUType(task_t task) {
cpu_type_t cpu_type;
size_t cpuTypeSize = sizeof(cpu_type);
sysctl(mib, mibLen, &cpu_type, &cpuTypeSize, 0, 0);
sysctl(mib, static_cast<u_int>(mibLen), &cpu_type, &cpuTypeSize, 0, 0);
return cpu_type;
}

View File

@ -755,7 +755,8 @@ bool MinidumpGenerator::WriteStackX86_64(breakpad_thread_state_data_t state,
x86_thread_state64_t *machine_state =
reinterpret_cast<x86_thread_state64_t *>(state);
mach_vm_address_t start_addr = REGISTER_FROM_THREADSTATE(machine_state, rsp);
mach_vm_address_t start_addr = static_cast<mach_vm_address_t>(
REGISTER_FROM_THREADSTATE(machine_state, rsp));
return WriteStackFromStartAddress(start_addr, stack_location);
}
@ -827,7 +828,8 @@ bool MinidumpGenerator::WriteContextX86_64(
*register_location = context.location();
MDRawContextAMD64 *context_ptr = context.get();
#define AddReg(a) context_ptr->a = REGISTER_FROM_THREADSTATE(machine_state, a)
#define AddReg(a) context_ptr->a = static_cast<typeof(context_ptr->a)>( \
REGISTER_FROM_THREADSTATE(machine_state, a))
context_ptr->context_flags = MD_CONTEXT_AMD64;
AddReg(rax);
@ -871,7 +873,7 @@ bool MinidumpGenerator::GetThreadState(thread_act_t target_thread,
size_t final_size =
std::min(static_cast<size_t>(*count), sizeof(arm_thread_state_t));
memcpy(state, &task_context_->breakpad_uc_mcontext->__ss, final_size);
*count = final_size;
*count = static_cast<mach_msg_type_number_t>(final_size);
return true;
#endif
#ifdef HAS_ARM64_SUPPORT
@ -879,7 +881,7 @@ bool MinidumpGenerator::GetThreadState(thread_act_t target_thread,
size_t final_size =
std::min(static_cast<size_t>(*count), sizeof(arm_thread_state64_t));
memcpy(state, &task_context_->breakpad_uc_mcontext->__ss, final_size);
*count = final_size;
*count = static_cast<mach_msg_type_number_t>(final_size);
return true;
}
#endif
@ -891,7 +893,7 @@ bool MinidumpGenerator::GetThreadState(thread_act_t target_thread,
size_t final_size =
std::min(static_cast<size_t>(*count), state_size);
memcpy(state, &task_context_->breakpad_uc_mcontext->__ss, final_size);
*count = final_size;
*count = static_cast<mach_msg_type_number_t>(final_size);
return true;
}
#endif
@ -1040,9 +1042,9 @@ bool MinidumpGenerator::WriteMemoryListStream(
uintptr_t end_of_range =
std::min(uintptr_t(ip + (kIPMemorySize / 2)),
uintptr_t(addr + size));
ip_memory_d.memory.data_size =
end_of_range -
uintptr_t range_diff = end_of_range -
static_cast<uintptr_t>(ip_memory_d.start_of_memory_range);
ip_memory_d.memory.data_size = static_cast<uint32_t>(range_diff);
have_ip_memory = true;
// This needs to get appended to the list even though
// the memory bytes aren't filled in yet so the entire
@ -1054,7 +1056,7 @@ bool MinidumpGenerator::WriteMemoryListStream(
}
// Now fill in the memory list and write it.
unsigned memory_count = memory_blocks_.size();
size_t memory_count = memory_blocks_.size();
if (!list.AllocateObjectAndArray(memory_count,
sizeof(MDMemoryDescriptor)))
return false;
@ -1062,7 +1064,7 @@ bool MinidumpGenerator::WriteMemoryListStream(
memory_list_stream->stream_type = MD_MEMORY_LIST_STREAM;
memory_list_stream->location = list.location();
list.get()->number_of_memory_ranges = memory_count;
list.get()->number_of_memory_ranges = static_cast<uint32_t>(memory_count);
unsigned int i;
for (i = 0; i < memory_count; ++i) {
@ -1216,9 +1218,9 @@ bool MinidumpGenerator::WriteSystemInfoStream(
info_ptr->processor_level =
(info_ptr->cpu.x86_cpu_info.version_information & 0xF00) >> 8;
// 0xMMSS (Model, Stepping)
info_ptr->processor_revision =
(info_ptr->cpu.x86_cpu_info.version_information & 0xF) |
((info_ptr->cpu.x86_cpu_info.version_information & 0xF0) << 4);
info_ptr->processor_revision = static_cast<uint16_t>(
(info_ptr->cpu.x86_cpu_info.version_information & 0xF) |
((info_ptr->cpu.x86_cpu_info.version_information & 0xF0) << 4));
// decode extended model info
if (info_ptr->processor_level == 0xF ||
@ -1461,8 +1463,8 @@ bool MinidumpGenerator::WriteModuleListStream(
MDRawDirectory *module_list_stream) {
TypedMDRVA<MDRawModuleList> list(&writer_);
size_t image_count = dynamic_images_ ?
static_cast<size_t>(dynamic_images_->GetImageCount()) :
uint32_t image_count = dynamic_images_ ?
dynamic_images_->GetImageCount() :
_dyld_image_count();
if (!list.AllocateObjectAndArray(image_count, MD_MODULE_SIZE))
@ -1474,7 +1476,7 @@ bool MinidumpGenerator::WriteModuleListStream(
// Write out the executable module as the first one
MDRawModule module;
size_t executableIndex = FindExecutableModule();
uint32_t executableIndex = FindExecutableModule();
if (!WriteModuleStream(executableIndex, &module)) {
return false;
@ -1483,7 +1485,7 @@ bool MinidumpGenerator::WriteModuleListStream(
list.CopyIndexAfterObject(0, &module, MD_MODULE_SIZE);
int destinationIndex = 1; // Write all other modules after this one
for (size_t i = 0; i < image_count; ++i) {
for (uint32_t i = 0; i < image_count; ++i) {
if (i != executableIndex) {
if (!WriteModuleStream(i, &module)) {
return false;

View File

@ -58,7 +58,7 @@ void MD5Init(struct MD5Context *ctx)
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
void MD5Update(struct MD5Context *ctx, unsigned char const *buf, size_t len)
{
u32 t;

View File

@ -18,7 +18,7 @@ struct MD5Context {
void MD5Init(struct MD5Context *ctx);
void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len);
void MD5Update(struct MD5Context *ctx, unsigned char const *buf, size_t len);
void MD5Final(unsigned char digest[16], struct MD5Context *ctx);

View File

@ -67,7 +67,7 @@ class PageAllocator {
FreeAll();
}
void *Alloc(unsigned bytes) {
void *Alloc(size_t bytes) {
if (!bytes)
return NULL;
@ -82,7 +82,7 @@ class PageAllocator {
return ret;
}
const unsigned pages =
const size_t pages =
(bytes + sizeof(PageHeader) + page_size_ - 1) / page_size_;
uint8_t *const ret = GetNPages(pages);
if (!ret)
@ -109,7 +109,7 @@ class PageAllocator {
}
private:
uint8_t *GetNPages(unsigned num_pages) {
uint8_t *GetNPages(size_t num_pages) {
#ifdef __x86_64
void *a = sys_mmap(NULL, page_size_ * num_pages, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
@ -139,7 +139,7 @@ class PageAllocator {
struct PageHeader {
PageHeader *next; // pointer to the start of the next set of pages.
unsigned num_pages; // the number of pages in this set.
size_t num_pages; // the number of pages in this set.
};
const unsigned page_size_;