touch up 64bit build cleanliness
Some of the types being used happened to work on 32bit systems because
size_t is pretty much an unsigned int. But with a 64bit system, we see:
kernel_collector.cc: In member function
'virtual bool KernelCollector::LoadParameters()':
kernel_collector.cc:141: error: cannot convert 'size_t*' to 'unsigned int*'
for argument '2' to 'bool LoadValue(FilePath, unsigned int*)'
This is easy to fix by using the correct type in LoadValue().
Next up, we get a failure due to the assumption that int64 can be
displayed using the lld format string. But on 64bit systems, this
doesn't work:
crash_collector.cc: In member function
'void CrashCollector::WriteCrashMetaData(const FilePath&, const std::string&, const std::string&)':
crash_collector.cc:355: error:
format '%lld' expects type 'long long int', but argument 6 has type 'int64'
This takes a little bit more magic to make work. Since printf itself
does not provide a printf string to handle "64bit" types, use the macros
that POSIX provides in inttypes.h. The printf string is a little uglier,
but now should work for all targets.
BUG=chromium-os:20636
TEST=`emerge-amd64-generic crash-reporter` now works
TEST=`emerge-x86-generic crash-reporter` still works
TEST=build+booting x86-alex still works
Change-Id: I8401f2ad932223085dfbe54541590e9b65297783
Reviewed-on: http://gerrit.chromium.org/gerrit/8051
Reviewed-by: Ken Mixter <kmixter@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Michael Krebs <mkrebs@chromium.org>
diff --git a/crash_reporter/crash_collector.cc b/crash_reporter/crash_collector.cc
index b60f7ba..fc7a52c 100644
--- a/crash_reporter/crash_collector.cc
+++ b/crash_reporter/crash_collector.cc
@@ -10,6 +10,8 @@
#include <sys/types.h> // for mode_t.
#include <sys/wait.h> // For waitpid.
#include <unistd.h> // For execv and fork.
+#define __STDC_FORMAT_MACROS // PRId64
+#include <inttypes.h>
#include <set>
@@ -346,7 +348,7 @@
std::string meta_data = StringPrintf("%sexec_name=%s\n"
"ver=%s\n"
"payload=%s\n"
- "payload_size=%lld\n"
+ "payload_size=%"PRId64"\n"
"done=1\n",
extra_metadata_.c_str(),
exec_name.c_str(),
diff --git a/crash_reporter/kernel_collector.cc b/crash_reporter/kernel_collector.cc
index 0c69dd6..8652d35 100644
--- a/crash_reporter/kernel_collector.cc
+++ b/crash_reporter/kernel_collector.cc
@@ -118,7 +118,7 @@
return true;
}
-bool LoadValue(FilePath path, unsigned int *element){
+bool LoadValue(FilePath path, size_t *element){
std::string buf;
char *end;
if (!file_util::ReadFileToString(path, &buf)) {