crash_reporter: Fix initial compile issues with Android toolchain
Fix some issues to get crash_reporter to compile on Android.
C++ source:
* bits/wordsize.h is used for __WORDSIZE, but is unavailable for most
Android toolchain architectures. It instead is available in sys/cdefs.h
Flex source:
* The Flex compiler toolchain doesn't link against the default fl library
using -lfl. Thus there is no yywrap() function defined. Since the
default fl library implementation just returns 1 (true), instead add a
directive to disable yywrap.
* The index(..) function has been deprecated in favor of strchr(..)
* Add a directive to disable the "deprecated conversion from string constant
to 'char*'" warning in the generated code.
* Remove warning suppression for the input() function which doesn't get
generated with Flex v2.5.39 and the arguments passed in the build command.
Bug: 22874187
Change-Id: I6d7dcf5f801010aeae06db9f0628a6652ee269ee
diff --git a/crash_reporter/user_collector.cc b/crash_reporter/user_collector.cc
index ac2f90e..069b581 100644
--- a/crash_reporter/user_collector.cc
+++ b/crash_reporter/user_collector.cc
@@ -4,13 +4,13 @@
#include "user_collector.h"
-#include <bits/wordsize.h>
#include <elf.h>
#include <fcntl.h>
#include <grp.h> // For struct group.
#include <pcrecpp.h>
#include <pwd.h> // For struct passwd.
#include <stdint.h>
+#include <sys/cdefs.h> // For __WORDSIZE
#include <sys/types.h> // For getpwuid_r, getgrnam_r, WEXITSTATUS.
#include <string>
diff --git a/crash_reporter/user_collector_test.cc b/crash_reporter/user_collector_test.cc
index a0ada06..ee3ca12 100644
--- a/crash_reporter/user_collector_test.cc
+++ b/crash_reporter/user_collector_test.cc
@@ -4,8 +4,8 @@
#include "user_collector.h"
-#include <bits/wordsize.h>
#include <elf.h>
+#include <sys/cdefs.h> // For __WORDSIZE
#include <unistd.h>
#include <base/files/file_util.h>
diff --git a/crash_reporter/warn_collector.l b/crash_reporter/warn_collector.l
index 691ef99..de746fe 100644
--- a/crash_reporter/warn_collector.l
+++ b/crash_reporter/warn_collector.l
@@ -11,6 +11,8 @@
* shipment to the crash server.
*/
+%option noyywrap
+
%{
#include <fcntl.h>
#include <inttypes.h>
@@ -122,6 +124,7 @@
hash_bitmap[word_index] |= 1 << bit_index;
}
+#pragma GCC diagnostic ignored "-Wwrite-strings"
int WarnStart(void) {
uint32_t hash;
char *spacep;
@@ -140,7 +143,7 @@
yyout = fopen(warn_dump_path, "w");
if (yyout == NULL)
Die("fopen %s failed: %s\n", warn_dump_path, strerror(errno));
- spacep = index(yytext, ' ');
+ spacep = strchr(yytext, ' ');
if (spacep == NULL || spacep[1] == '\0')
spacep = "unknown-function";
fprintf(yyout, "%08x-%s\n", hash, spacep + 1);
@@ -318,5 +321,4 @@
*/
void UnusedFunctionWarningSuppressor(void) {
yyunput(0, 0);
- (void) input();
}