[minicoredumper] Building minicoredumper_demo/main.c fails

Anders Wallin wallinux at gmail.com
Mon Apr 24 16:35:05 CEST 2017


If configure is run with "--with-minicoredumper_demo" the build will fail
due to missing typecasts.

Making all in minicoredumper_demo
make[3]: Entering directory
'/media/awallin/sda1/home/awallin/src/minicoredumper/src/minicoredumper_demo'
gcc -DHAVE_CONFIG_H -I. -I../..  -Wall -D_GNU_SOURCE -D_LARGEFILE64_SOURCE
-Werror -I../../src/api  -std=c99 -g -O2 -MT minicoredumper_demo-main.o -MD
-MP -MF .deps/minicoredumper_demo-main.Tpo -c -o m
inicoredumper_demo-main.o `test -f 'main.c' || echo './'`main.c
main.c: In function ‘main’:
main.c:76:9: error: format ‘%x’ expects argument of type ‘unsigned int *’,
but argument 5 has type ‘long unsigned int *’ [-Werror=format=]
         " %%x=0x%x", &val1);
         ^
main.c:78:9: error: format ‘%hx’ expects argument of type ‘short unsigned
int *’, but argument 5 has type ‘long unsigned int *’ [-Werror=format=]
         " %%hx=0x%hx", &val1);
         ^
main.c:80:9: error: format ‘%hhx’ expects argument of type ‘unsigned char
*’, but argument 5 has type ‘long unsigned int *’ [-Werror=format=]
         " %%hhx=0x%hhx\n", &val1);
         ^

This patch fix the problem;
Message-Id: <
3138c2eb01ac2f61087258415d5857613b2cf0f2.1493041764.git.anders.wallin at windriver.com
>
In-Reply-To: <
94f99f63eb7188ef74e953f6e98304af51e15c92.1493041764.git.anders.wallin at windriver.com
>
References: <
94f99f63eb7188ef74e953f6e98304af51e15c92.1493041764.git.anders.wallin at windriver.com
>
From: Anders Wallin <anders.wallin at windriver.com>
Date: Mon, 24 Apr 2017 15:48:39 +0200
Subject: [PATCH 2/2] typecasts when dumping data in minicoredumper_demo

Signed-off-by: Anders Wallin <anders.wallin at windriver.com>
---
 src/minicoredumper_demo/main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/minicoredumper_demo/main.c b/src/minicoredumper_demo/main.c
index 9d5cd3b..f722fa1 100644
--- a/src/minicoredumper_demo/main.c
+++ b/src/minicoredumper_demo/main.c
@@ -73,11 +73,11 @@ int __attribute__((optimize("O0"))) main(int argc, char
*argv[])
        mcd_dump_data_register_text("tdump3.txt", 6, &dd[2],
                                    "val1: %%lx=0x%lx", &val1);
        mcd_dump_data_register_text("tdump3.txt", 6, &dd[3],
-                                   " %%x=0x%x", &val1);
+                                   " %%x=0x%x", (int*) &val1);
        mcd_dump_data_register_text("tdump3.txt", 6, &dd[4],
-                                   " %%hx=0x%hx", &val1);
+                                   " %%hx=0x%hx", (short*) &val1);
        mcd_dump_data_register_text("tdump3.txt", 6, &dd[5],
-                                   " %%hhx=0x%hhx\n", &val1);
+                                   " %%hhx=0x%hhx\n", (char *) &val1);
        /* "val1=0x0 val2=0x0 val3=0x0\n" */
        mcd_dump_data_register_text("tdump4.txt", 6, &dd[6],
                                    "val1=0x%lx val2=0x%lx "
-- 
2.11.0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linutronix.de/pipermail/minicoredumper/attachments/20170424/c4d0665b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-typecasts-when-dumping-data-in-minicoredumper_demo.patch
Type: text/x-patch
Size: 1567 bytes
Desc: not available
URL: <http://lists.linutronix.de/pipermail/minicoredumper/attachments/20170424/c4d0665b/attachment.bin>


More information about the minicoredumper mailing list