From 018fdeaf3d18086c517390e678dcfac05639cd18 Mon Sep 17 00:00:00 2001 From: Yongqin Liu Date: Wed, 11 Apr 2018 00:25:43 +0800 Subject: Fix compiling problem reported with P Preview Change-Id: I628c060557362920a45256f554d9814e8bfdc222 Signed-off-by: Yongqin Liu --- Android.mk | 2 ++ dhry_1.c | 10 ++++++---- harness.c | 16 ++++++++-------- stringbench.c | 2 +- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Android.mk b/Android.mk index c8ae07c..08428f7 100644 --- a/Android.mk +++ b/Android.mk @@ -13,6 +13,7 @@ LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) LOCAL_MODULE_TAGS := debug LOCAL_CFLAGS += -std=gnu99 +LOCAL_CFLAGS += "-D__unused=__attribute__((unused))" include $(BUILD_EXECUTABLE) @@ -31,6 +32,7 @@ LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) LOCAL_MODULE_TAGS := debug LOCAL_CFLAGS += -std=gnu99 +LOCAL_CFLAGS += "-D__unused=__attribute__((unused))" include $(BUILD_EXECUTABLE) diff --git a/dhry_1.c b/dhry_1.c index 54cc1f5..4e6a6bb 100644 --- a/dhry_1.c +++ b/dhry_1.c @@ -114,7 +114,7 @@ int Int_Glob; /* end of variables for time measurement */ - void main (int argc, char *argv[]) + int main (int argc, char *argv[]) /*****/ /* main program, corresponds to procedures */ @@ -131,7 +131,7 @@ int Int_Glob; Str_30 Str_2_Loc; REG int Run_Index; REG int Number_Of_Runs; - int endit, count = 10; + int /*endit, */count = 10; FILE *Ap; char general[9][80] = {" "}; @@ -540,7 +540,7 @@ int Int_Glob; fprintf (Ap, "%10d\n", Arr_2_Glob[8][7]); fprintf (Ap, "Ptr_Glob-> \n"); - fprintf (Ap, " Ptr_Comp: * %x\n", (long) Ptr_Glob->Ptr_Comp); + fprintf (Ap, " Ptr_Comp: * %lx\n", (long) Ptr_Glob->Ptr_Comp); fprintf (Ap, " Discr: "); if (Ptr_Glob->Discr == 0) fprintf (Ap, "O.K. "); @@ -566,7 +566,7 @@ int Int_Glob; fprintf (Ap, "%s\n", Ptr_Glob->variant.var_1.Str_Comp); fprintf (Ap, "Next_Ptr_Glob-> \n"); - fprintf (Ap, " Ptr_Comp: * %x", (long) Next_Ptr_Glob->Ptr_Comp); + fprintf (Ap, " Ptr_Comp: * %lx", (long) Next_Ptr_Glob->Ptr_Comp); fprintf (Ap, " same as above\n"); fprintf (Ap, " Discr: "); @@ -654,6 +654,8 @@ int Int_Glob; printf("Press any key to exit\n"); printf ("\nIf this is displayed you must close the window in the normal way\n"); } + + return 0; } diff --git a/harness.c b/harness.c index 4af8bd0..d47abb5 100644 --- a/harness.c +++ b/harness.c @@ -77,7 +77,7 @@ static void empty(volatile char *against) } /** Stub that does nothing. Used for calibrating */ -static void xbounce(void *dest, void *src, size_t n) +static void xbounce(void *dest __unused, void *src __unused, size_t n __unused) { SPOIL(0); } @@ -89,31 +89,31 @@ static void xmemcpy(void *dest, void *src, size_t n) } /** Stub that calls memset */ -static void xmemset(void *dest, void *src, size_t n) +static void xmemset(void *dest, void *src __unused, size_t n) { SPOIL(memset(dest, 0, n)); } /** Stub that calls strcpy */ -static void xstrcpy(void *dest, void *src, size_t n) +static void xstrcpy(void *dest, void *src, size_t n __unused) { SPOIL(strcpy(dest, src)); } /** Stub that calls strlen */ -static void xstrlen(void *dest, void *src, size_t n) +static void xstrlen(void *dest, void *src __unused, size_t n __unused) { SPOIL(strlen(dest)); } /** Stub that calls strcmp */ -static void xstrcmp(void *dest, void *src, size_t n) +static void xstrcmp(void *dest, void *src, size_t n __unused) { SPOIL(strcmp(dest, src)); } /** Stub that calls strchr */ -static void xstrchr(void *dest, void *src, size_t n) +static void xstrchr(void *dest __unused, void *src, size_t n) { /* Put the character at the end of the string and before the null */ ((char *)src)[n-1] = 32; @@ -121,7 +121,7 @@ static void xstrchr(void *dest, void *src, size_t n) } /** Stub that calls memchr */ -static void xmemchr(void *dest, void *src, size_t n) +static void xmemchr(void *dest __unused, void *src, size_t n) { /* Put the character at the end of the block */ ((char *)src)[n-1] = 32; @@ -139,7 +139,7 @@ static const struct test tests[] = { "strcmp", xstrcmp }, { "strcpy", xstrcpy }, { "strlen", xstrlen }, - { NULL } + { NULL, NULL } }; /** Show basic usage */ diff --git a/stringbench.c b/stringbench.c index 804d76c..7dcc9fd 100644 --- a/stringbench.c +++ b/stringbench.c @@ -6,7 +6,7 @@ #define START gettimeofday(&tv1, 0); #define END(x) gettimeofday(&tv2, 0); t1 = ((double)tv1.tv_sec)+((double)tv1.tv_usec)/1000000.0; t2 = ((double)tv2.tv_sec)+((double)tv2.tv_usec)/1000000.0; printf("%s: %f seconds\n", x, t2-t1) -int main(int argc, char **argv) { +int main(int argc __unused, char **argv __unused) { struct timeval tv1, tv2; double t1, t2; char * const s = (char * const) malloc(16); -- cgit v1.2.3