diff mbox series

[v2,3/3] kernel-shark: Fix all warnings when building on 32 bit systems

Message ID 20190614135045.17223-4-ykaradzhov@vmware.com (mailing list archive)
State Accepted
Commit 1db270ee30e95a28881ac6e79d6c4c43b0a8cf3a
Headers show
Series Fixes needed befor KS 1.0 | expand

Commit Message

Yordan Karadzhov June 14, 2019, 1:51 p.m. UTC
Fixing warnings coming from:
../examples/datahisto.c
../src/KsTraceGraph.cpp
../src/libkshark.c

Reported-by: Alan Mikhak <alanmikhak@gmail.com>
Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark/examples/datahisto.c |  4 ++--
 kernel-shark/src/KsTraceGraph.cpp | 10 +++++-----
 kernel-shark/src/libkshark.c      |  4 ++--
 3 files changed, 9 insertions(+), 9 deletions(-)

Comments

Alan Mikhak June 15, 2019, 10:26 a.m. UTC | #1
On Fri, Jun 14, 2019 at 6:51 AM Yordan Karadzhov <ykaradzhov@vmware.com> wrote:
>
> Fixing warnings coming from:
> ../examples/datahisto.c
> ../src/KsTraceGraph.cpp
> ../src/libkshark.c
>
> Reported-by: Alan Mikhak <alanmikhak@gmail.com>
> Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
> ---
>  kernel-shark/examples/datahisto.c |  4 ++--
>  kernel-shark/src/KsTraceGraph.cpp | 10 +++++-----
>  kernel-shark/src/libkshark.c      |  4 ++--
>  3 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/kernel-shark/examples/datahisto.c b/kernel-shark/examples/datahisto.c
> index 02c6285..b177b08 100644
> --- a/kernel-shark/examples/datahisto.c
> +++ b/kernel-shark/examples/datahisto.c
> @@ -56,11 +56,11 @@ void dump_bin(struct kshark_trace_histo *histo, int bin,
>                 puts ("EMPTY BIN");
>         } else {
>                 entry_str = kshark_dump_entry(e_front);
> -               printf("%li -> %s\n", i_front, entry_str);
> +               printf("%zd -> %s\n", i_front, entry_str);
>                 free(entry_str);
>
>                 entry_str = kshark_dump_entry(e_back);
> -               printf("%li -> %s\n", i_back, entry_str);
> +               printf("%zd -> %s\n", i_back, entry_str);
>                 free(entry_str);
>         }
>
> diff --git a/kernel-shark/src/KsTraceGraph.cpp b/kernel-shark/src/KsTraceGraph.cpp
> index da2c6aa..324f36e 100644
> --- a/kernel-shark/src/KsTraceGraph.cpp
> +++ b/kernel-shark/src/KsTraceGraph.cpp
> @@ -277,7 +277,7 @@ void KsTraceGraph::_resetPointer(uint64_t ts, int cpu, int pid)
>         QString pointer;
>
>         kshark_convert_nano(ts, &sec, &usec);
> -       pointer.sprintf("%lu.%06lu", sec, usec);
> +       pointer.sprintf("%" PRIu64 ".%06" PRIu64 "", sec, usec);
>         _labelP2.setText(pointer);
>
>         if (pid > 0 && cpu >= 0) {
> @@ -313,7 +313,7 @@ void KsTraceGraph::_setPointerInfo(size_t i)
>         uint64_t sec, usec;
>
>         kshark_convert_nano(e->ts, &sec, &usec);
> -       pointer.sprintf("%lu.%06lu", sec, usec);
> +       pointer.sprintf("%" PRIu64 ".%06" PRIu64 "", sec, usec);
>         _labelP2.setText(pointer);
>
>         comm.append("-");
> @@ -601,17 +601,17 @@ void KsTraceGraph::_updateTimeLegends()
>         QString tMin, tMid, tMax;
>
>         kshark_convert_nano(_glWindow.model()->histo()->min, &sec, &usec);
> -       tMin.sprintf("%lu.%06lu", sec, usec);
> +       tMin.sprintf("%" PRIu64 ".%06" PRIu64 "", sec, usec);
>         _labelXMin.setText(tMin);
>
>         tsMid = (_glWindow.model()->histo()->min +
>                  _glWindow.model()->histo()->max) / 2;
>         kshark_convert_nano(tsMid, &sec, &usec);
> -       tMid.sprintf("%lu.%06lu", sec, usec);
> +       tMid.sprintf("%" PRIu64 ".%06" PRIu64 "", sec, usec);
>         _labelXMid.setText(tMid);
>
>         kshark_convert_nano(_glWindow.model()->histo()->max, &sec, &usec);
> -       tMax.sprintf("%lu.%06lu", sec, usec);
> +       tMax.sprintf("%" PRIu64 ".%06" PRIu64 "", sec, usec);
>         _labelXMax.setText(tMax);
>  }
>
> diff --git a/kernel-shark/src/libkshark.c b/kernel-shark/src/libkshark.c
> index 0f0a1ba..9aaf1b7 100644
> --- a/kernel-shark/src/libkshark.c
> +++ b/kernel-shark/src/libkshark.c
> @@ -1423,7 +1423,7 @@ char* kshark_dump_custom_entry(struct kshark_context *kshark_ctx,
>         event_name = info_func(kshark_ctx, entry, false);
>         info = info_func(kshark_ctx, entry, true);
>
> -       size = asprintf(&entry_str, "%li; %s-%i; CPU %i; ; %s; %s",
> +       size = asprintf(&entry_str, "%" PRIu64 "; %s-%i; CPU %i; ; %s; %s",
>                         entry->ts,
>                         task,
>                         entry->pid,
> @@ -1472,7 +1472,7 @@ char* kshark_dump_entry(const struct kshark_entry *entry)
>                 event_name = event? event->name : "[UNKNOWN EVENT]";
>                 lat = kshark_get_latency(kshark_ctx->pevent, data);
>
> -               size = asprintf(&temp_str, "%li; %s-%i; CPU %i; %s;",
> +               size = asprintf(&temp_str, "%" PRIu64 "; %s-%i; CPU %i; %s;",
>                                 entry->ts,
>                                 task,
>                                 entry->pid,
> --
> 2.20.1
>

Hi Yordan,

I had to manually apply your two patches from 2019-06-14 manually on top of your
first patch from 2019-06-12. I was able to build KernelShark on my
Raspberry Pi 3
model B+ and observe that your combined changes resolved the abort issue as
well as compiler warnings. I also observed the same good results on my
ODROID-XU3
from hardkernel.com which also runs a 32-bit armv7l kernel as well as
my 96Boards
ROCK960 model C which runs a 64-bit aarch64 kernel.

Please see bugzilla for an attached patch file which shows the
combined changes I
manually applied as your patches intended.

Regards,
Alan
diff mbox series

Patch

diff --git a/kernel-shark/examples/datahisto.c b/kernel-shark/examples/datahisto.c
index 02c6285..b177b08 100644
--- a/kernel-shark/examples/datahisto.c
+++ b/kernel-shark/examples/datahisto.c
@@ -56,11 +56,11 @@  void dump_bin(struct kshark_trace_histo *histo, int bin,
 		puts ("EMPTY BIN");
 	} else {
 		entry_str = kshark_dump_entry(e_front);
-		printf("%li -> %s\n", i_front, entry_str);
+		printf("%zd -> %s\n", i_front, entry_str);
 		free(entry_str);
 
 		entry_str = kshark_dump_entry(e_back);
-		printf("%li -> %s\n", i_back, entry_str);
+		printf("%zd -> %s\n", i_back, entry_str);
 		free(entry_str);
 	}
 
diff --git a/kernel-shark/src/KsTraceGraph.cpp b/kernel-shark/src/KsTraceGraph.cpp
index da2c6aa..324f36e 100644
--- a/kernel-shark/src/KsTraceGraph.cpp
+++ b/kernel-shark/src/KsTraceGraph.cpp
@@ -277,7 +277,7 @@  void KsTraceGraph::_resetPointer(uint64_t ts, int cpu, int pid)
 	QString pointer;
 
 	kshark_convert_nano(ts, &sec, &usec);
-	pointer.sprintf("%lu.%06lu", sec, usec);
+	pointer.sprintf("%" PRIu64 ".%06" PRIu64 "", sec, usec);
 	_labelP2.setText(pointer);
 
 	if (pid > 0 && cpu >= 0) {
@@ -313,7 +313,7 @@  void KsTraceGraph::_setPointerInfo(size_t i)
 	uint64_t sec, usec;
 
 	kshark_convert_nano(e->ts, &sec, &usec);
-	pointer.sprintf("%lu.%06lu", sec, usec);
+	pointer.sprintf("%" PRIu64 ".%06" PRIu64 "", sec, usec);
 	_labelP2.setText(pointer);
 
 	comm.append("-");
@@ -601,17 +601,17 @@  void KsTraceGraph::_updateTimeLegends()
 	QString tMin, tMid, tMax;
 
 	kshark_convert_nano(_glWindow.model()->histo()->min, &sec, &usec);
-	tMin.sprintf("%lu.%06lu", sec, usec);
+	tMin.sprintf("%" PRIu64 ".%06" PRIu64 "", sec, usec);
 	_labelXMin.setText(tMin);
 
 	tsMid = (_glWindow.model()->histo()->min +
 		 _glWindow.model()->histo()->max) / 2;
 	kshark_convert_nano(tsMid, &sec, &usec);
-	tMid.sprintf("%lu.%06lu", sec, usec);
+	tMid.sprintf("%" PRIu64 ".%06" PRIu64 "", sec, usec);
 	_labelXMid.setText(tMid);
 
 	kshark_convert_nano(_glWindow.model()->histo()->max, &sec, &usec);
-	tMax.sprintf("%lu.%06lu", sec, usec);
+	tMax.sprintf("%" PRIu64 ".%06" PRIu64 "", sec, usec);
 	_labelXMax.setText(tMax);
 }
 
diff --git a/kernel-shark/src/libkshark.c b/kernel-shark/src/libkshark.c
index 0f0a1ba..9aaf1b7 100644
--- a/kernel-shark/src/libkshark.c
+++ b/kernel-shark/src/libkshark.c
@@ -1423,7 +1423,7 @@  char* kshark_dump_custom_entry(struct kshark_context *kshark_ctx,
 	event_name = info_func(kshark_ctx, entry, false);
 	info = info_func(kshark_ctx, entry, true);
 
-	size = asprintf(&entry_str, "%li; %s-%i; CPU %i; ; %s; %s",
+	size = asprintf(&entry_str, "%" PRIu64 "; %s-%i; CPU %i; ; %s; %s",
 			entry->ts,
 			task,
 			entry->pid,
@@ -1472,7 +1472,7 @@  char* kshark_dump_entry(const struct kshark_entry *entry)
 		event_name = event? event->name : "[UNKNOWN EVENT]";
 		lat = kshark_get_latency(kshark_ctx->pevent, data);
 
-		size = asprintf(&temp_str, "%li; %s-%i; CPU %i; %s;",
+		size = asprintf(&temp_str, "%" PRIu64 "; %s-%i; CPU %i; %s;",
 				entry->ts,
 				task,
 				entry->pid,