From: Benjamin ROBIN <dev@benjarobin.fr>
To: <y.karadz@gmail.com>
Cc: <linux-trace-devel@vger.kernel.org>, Benjamin ROBIN <dev@benjarobin.fr>
Subject: [PATCH 31/34] kernelshark: Fix comparison of integers of different signs warnings
Date: Sun, 14 Jan 2024 18:17:20 +0100 [thread overview]
Message-ID: <20240114171723.14092-32-dev@benjarobin.fr> (raw)
In-Reply-To: <20240114171723.14092-1-dev@benjarobin.fr>
Most of them have been fixed, but a few still remain.
Signed-off-by: Benjamin ROBIN <dev@benjarobin.fr>
---
examples/configio.c | 3 ++-
examples/datafilter.c | 9 ++++++---
examples/datahisto.c | 2 +-
src/libkshark-collection.c | 14 ++++++++------
src/libkshark-configio.c | 6 ++++--
src/libkshark-hash.c | 5 +++--
src/libkshark-model.c | 16 +++++++++-------
src/libkshark-tepdata.c | 2 +-
src/libkshark.c | 17 +++++++++--------
src/plugins/sched_events.c | 2 +-
10 files changed, 44 insertions(+), 32 deletions(-)
diff --git a/examples/configio.c b/examples/configio.c
index 9710d53..575211d 100644
--- a/examples/configio.c
+++ b/examples/configio.c
@@ -8,7 +8,8 @@ int main(int argc, char **argv)
struct kshark_config_doc *conf, *filter, *hello;
struct kshark_context *kshark_ctx;
struct kshark_data_stream *stream;
- int sd, *ids = NULL, i;
+ int sd, *ids = NULL;
+ size_t i;
/* Create a new kshark session. */
kshark_ctx = NULL;
diff --git a/examples/datafilter.c b/examples/datafilter.c
index 8e86d9c..21a38fe 100644
--- a/examples/datafilter.c
+++ b/examples/datafilter.c
@@ -23,6 +23,7 @@ int main(int argc, char **argv)
struct kshark_entry **data = NULL;
int *pids, *evt_ids;
char *entry_str;
+ int rt;
/* Create a new kshark session. */
kshark_ctx = NULL;
@@ -31,15 +32,17 @@ int main(int argc, char **argv)
/* Open a trace data file produced by trace-cmd. */
if (argc > 1)
- sd = kshark_open(kshark_ctx, argv[1]);
+ rt = kshark_open(kshark_ctx, argv[1]);
else
- sd = kshark_open(kshark_ctx, default_file);
+ rt = kshark_open(kshark_ctx, default_file);
- if (sd < 0) {
+ if (rt < 0) {
kshark_free(kshark_ctx);
return 1;
}
+ sd = (size_t)rt;
+
/* Load the content of the file into an array of entries. */
n_rows = kshark_load_entries(kshark_ctx, sd, &data);
diff --git a/examples/datahisto.c b/examples/datahisto.c
index 568072d..b54b9e9 100644
--- a/examples/datahisto.c
+++ b/examples/datahisto.c
@@ -70,7 +70,7 @@ void dump_bin(struct kshark_trace_histo *histo, int bin, int sd,
void dump_histo(struct kshark_trace_histo *histo, int sd, const char *type, int val)
{
- size_t bin;
+ int bin;
for (bin = 0; bin < histo->n_bins; ++bin)
dump_bin(histo, bin, sd, type, val);
diff --git a/src/libkshark-collection.c b/src/libkshark-collection.c
index 915983b..2ce113f 100644
--- a/src/libkshark-collection.c
+++ b/src/libkshark-collection.c
@@ -518,14 +518,16 @@ static int
map_collection_front_request(const struct kshark_entry_collection *col,
struct kshark_entry_request *req)
{
- size_t req_first, req_end;
- ssize_t col_index;
+ size_t req_first, req_end, col_index;
+ ssize_t r;
int req_count;
- col_index = map_collection_request_init(col, req, true, &req_end);
- if (col_index == KS_EMPTY_BIN)
+ r = map_collection_request_init(col, req, true, &req_end);
+ if (r == KS_EMPTY_BIN)
return 0;
+ col_index = (size_t)r;
+
/*
* Now loop over the intervals of the collection going forwards till
* the end of the inputted request and create a separate request for
@@ -746,7 +748,7 @@ kshark_find_data_collection(struct kshark_entry_collection *col,
while (col) {
if (col->cond == cond &&
col->stream_id == sd &&
- col->n_val == n_val &&
+ (size_t)col->n_val == n_val &&
val_compare(col->values, values, n_val))
return col;
@@ -899,7 +901,7 @@ void kshark_unregister_data_collection(struct kshark_entry_collection **col,
for (list = *col; list; list = list->next) {
if (list->cond == cond &&
list->stream_id == sd &&
- list->n_val == n_val &&
+ (size_t)list->n_val == n_val &&
val_compare(list->values, values, n_val)) {
*last = list->next;
kshark_free_data_collection(list);
diff --git a/src/libkshark-configio.c b/src/libkshark-configio.c
index 49f957b..0694e19 100644
--- a/src/libkshark-configio.c
+++ b/src/libkshark-configio.c
@@ -1117,7 +1117,8 @@ static bool kshark_event_filter_to_json(struct kshark_data_stream *stream,
json_object *jfilter_data, *jname;
struct kshark_hash_id *filter;
char *name_str;
- int i, *ids;
+ int *ids;
+ size_t i;
filter = kshark_get_filter(stream, filter_type);
if (!filter)
@@ -1286,7 +1287,8 @@ static bool kshark_filter_array_to_json(struct kshark_hash_id *filter,
struct json_object *jobj)
{
json_object *jfilter_data, *jpid = NULL;
- int i, *ids;
+ int *ids;
+ size_t i;
/*
* If this Json document already contains a description of the filter,
diff --git a/src/libkshark-hash.c b/src/libkshark-hash.c
index 89c021b..d4f0a31 100644
--- a/src/libkshark-hash.c
+++ b/src/libkshark-hash.c
@@ -169,7 +169,7 @@ void kshark_hash_id_clear(struct kshark_hash_id *hash)
{
struct kshark_hash_id_item *item, *next;
size_t size;
- int i;
+ size_t i;
if (!hash || ! hash->hash)
return;
@@ -212,7 +212,8 @@ int *kshark_hash_ids(struct kshark_hash_id *hash)
{
struct kshark_hash_id_item *item;
size_t size = hash_size(hash);
- int count = 0, i;
+ size_t i;
+ int count = 0;
int *ids;
if (!hash->count)
diff --git a/src/libkshark-model.c b/src/libkshark-model.c
index 4cd9f6a..2918567 100644
--- a/src/libkshark-model.c
+++ b/src/libkshark-model.c
@@ -97,6 +97,8 @@ static void ksmodel_set_in_range_bining(struct kshark_trace_histo *histo,
int64_t corrected_range, delta_range, range = max - min;
struct kshark_entry *last;
+ assert(min <= max);
+
if (n <= 0) {
histo->n_bins = histo->bin_size = 0;
histo->min = min;
@@ -110,7 +112,7 @@ static void ksmodel_set_in_range_bining(struct kshark_trace_histo *histo,
}
/* The size of the bin must be >= 1, hence the range must be >= n. */
- if (range < n) {
+ if ((size_t)range < n) {
range = n;
max = min + n;
}
@@ -119,7 +121,7 @@ static void ksmodel_set_in_range_bining(struct kshark_trace_histo *histo,
* If the number of bins changes, allocate memory for the descriptor of
* the model.
*/
- if (n != histo->n_bins) {
+ if (n != (size_t)histo->n_bins) {
if (!ksmodel_histo_alloc(histo, n)) {
ksmodel_clear(histo);
return;
@@ -282,7 +284,7 @@ static void ksmodel_set_next_bin_edge(struct kshark_trace_histo *histo,
* case we have to increase the size of the very last bin in order to
* make sure that the last entry of the dataset will fall into it.
*/
- if (next_bin == histo->n_bins - 1)
+ if (next_bin == (size_t)(histo->n_bins - 1))
++time_max;
/*
@@ -544,7 +546,7 @@ void ksmodel_shift_forward(struct kshark_trace_histo *histo, size_t n)
void ksmodel_shift_backward(struct kshark_trace_histo *histo, size_t n)
{
size_t last_row = 0;
- int bin;
+ size_t bin;
if (!histo->data_size)
return;
@@ -561,7 +563,7 @@ void ksmodel_shift_backward(struct kshark_trace_histo *histo, size_t n)
histo->min -= n * histo->bin_size;
histo->max -= n * histo->bin_size;
- if (n >= histo->n_bins) {
+ if (n >= (size_t)histo->n_bins) {
/*
* No overlap between the new and the old range. Recalculate
* all bins from scratch. First calculate the new range.
@@ -649,7 +651,7 @@ void ksmodel_jump_to(struct kshark_trace_histo *histo, int64_t ts)
static void ksmodel_zoom(struct kshark_trace_histo *histo,
double r, int mark, bool zoom_in)
{
- size_t range, min, max, delta_min;
+ int64_t range, min, max, delta_min;
double delta_tot;
if (!histo->data_size)
@@ -668,7 +670,7 @@ static void ksmodel_zoom(struct kshark_trace_histo *histo,
* Avoid overzooming. If needed, adjust the Scale factor to a the value
* which provides bin_size >= 5.
*/
- if (zoom_in && (size_t) (range * (1. - r)) < histo->n_bins * 5)
+ if (zoom_in && (int)(range * (1. - r)) < (histo->n_bins * 5))
r = 1. - (histo->n_bins * 5.) / range;
/*
diff --git a/src/libkshark-tepdata.c b/src/libkshark-tepdata.c
index a178de6..4171fab 100644
--- a/src/libkshark-tepdata.c
+++ b/src/libkshark-tepdata.c
@@ -239,7 +239,7 @@ static int get_next_pid(struct kshark_data_stream *stream,
ret = tep_read_number_field(get_sched_next(stream),
record->data, &val);
- return ret ? : val;
+ return ret ? : (int)val;
}
static void register_command(struct kshark_data_stream *stream,
diff --git a/src/libkshark.c b/src/libkshark.c
index 44e553f..698b8d6 100644
--- a/src/libkshark.c
+++ b/src/libkshark.c
@@ -1371,9 +1371,10 @@ void kshark_clear_all_filters(struct kshark_context *kshark_ctx,
{
struct kshark_data_stream *stream;
int *stream_ids, i;
+ size_t j;
- for (i = 0; i < n_entries; ++i)
- set_all_visible(&data[i]->visible);
+ for (j = 0; j < n_entries; ++j)
+ set_all_visible(&data[j]->visible);
stream_ids = kshark_all_streams(kshark_ctx);
for (i = 0; i < kshark_ctx->n_streams; i++) {
@@ -1942,7 +1943,7 @@ kshark_merge_data_entries(struct kshark_entry_data_set *buffers, int n_buffers)
return NULL;
}
- for (i = 0; i < n_buffers; ++i) {
+ for (i = 0; i < (size_t)n_buffers; ++i) {
count[i] = 0;
if (buffers[i].n_rows > 0)
tot += buffers[i].n_rows;
@@ -2111,7 +2112,7 @@ kshark_merge_data_matrices(struct kshark_matrix_data_set *buffers, int n_buffers
{
struct kshark_matrix_data_set merged_data;
size_t i, tot = 0, count[n_buffers];
- int i_first;
+ int i_first, j;
bool status;
merged_data.n_rows = -1;
@@ -2121,10 +2122,10 @@ kshark_merge_data_matrices(struct kshark_matrix_data_set *buffers, int n_buffers
goto end;
}
- for (i = 0; i < n_buffers; ++i) {
- count[i] = 0;
- if (buffers[i].n_rows > 0)
- tot += buffers[i].n_rows;
+ for (j = 0; j < n_buffers; ++j) {
+ count[j] = 0;
+ if (buffers[j].n_rows > 0)
+ tot += buffers[j].n_rows;
}
status = kshark_data_matrix_alloc(tot, &merged_data.event_array,
diff --git a/src/plugins/sched_events.c b/src/plugins/sched_events.c
index c3a4f47..a605fca 100644
--- a/src/plugins/sched_events.c
+++ b/src/plugins/sched_events.c
@@ -115,7 +115,7 @@ static void plugin_sched_swith_action(struct kshark_data_stream *stream,
ret = tep_read_number_field(plugin_ctx->sched_switch_next_field,
record->data, &next_pid);
- if (ret == 0 && next_pid >= 0) {
+ if (ret == 0) {
plugin_sched_set_pid(&ks_field, entry->pid);
ret = tep_read_number_field(plugin_ctx->sched_switch_prev_state_field,
--
2.43.0
next prev parent reply other threads:[~2024-01-14 17:23 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-14 17:16 [PATCH 00/34] Fix kernelshark issues introduced by the migration to Qt6 Benjamin ROBIN
2024-01-14 17:16 ` [PATCH 01/34] kernelshark: Fix modelReset() signaling, rename update to updateGeom Benjamin ROBIN
2024-01-14 17:16 ` [PATCH 02/34] kernelshark: Add .gitignore Benjamin ROBIN
2024-01-14 17:16 ` [PATCH 03/34] kernelshark: Remove function param when not used, whenever possible Benjamin ROBIN
2024-01-14 17:16 ` [PATCH 04/34] kernelshark: Do not create a temporary container for looping over QMap Benjamin ROBIN
2024-01-21 17:16 ` Yordan Karadzhov
2024-01-28 21:30 ` Benjamin ROBIN
2024-02-04 18:34 ` Yordan Karadzhov
2024-02-04 18:59 ` Benjamin ROBIN
2024-01-14 17:16 ` [PATCH 05/34] kernelshark: Prevent potential detach of QMap container Benjamin ROBIN
2024-01-21 17:17 ` Yordan Karadzhov
2024-01-28 19:38 ` [PATCH v2 " Benjamin ROBIN
2024-01-14 17:16 ` [PATCH 06/34] kernelshark: Fix used after free of QByteArray raw data Benjamin ROBIN
2024-01-14 17:16 ` [PATCH 07/34] kernelshark: Fix potential memory leak in KsGLWidget Benjamin ROBIN
2024-01-14 17:16 ` [PATCH 08/34] kernelshark: Use lambda parameter instead of captured local variable Benjamin ROBIN
2024-01-14 17:16 ` [PATCH 09/34] kernelshark: Keep overridden method protected instead of public Benjamin ROBIN
2024-01-14 17:16 ` [PATCH 10/34] kernelshark: Use sliced() or first() instead of mid/right/left() Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 11/34] kernelshark: Prevent potential divide by zero in Shape::center() Benjamin ROBIN
2024-01-21 19:49 ` Yordan Karadzhov
2024-01-28 19:26 ` [PATCH v2 " Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 12/34] kernelshark: Fix potential access to uninitialized variable Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 13/34] kernelshark: Remove unused locals variables Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 14/34] kernelshark: Fix range-loop-reference Clazy warning Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 15/34] kernelshark: Fix moving a temp object prevents copy elision warning Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 16/34] kernelshark: Add receiver object to connect() call Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 17/34] kernelshark: Return by reference the list of header in KsModels Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 18/34] kernelshark: Fix detaching-temporary Clazy warning Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 19/34] kernelshark: Fix qfileinfo-exists " Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 20/34] kernelshark: Fix potential memory leaks in libkshark-configio Benjamin ROBIN
2024-01-21 18:41 ` Yordan Karadzhov
2024-01-28 19:25 ` [PATCH v2 " Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 21/34] kernelshark: Fix potential access to uninitialized variable Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 22/34] kernelshark: Fix potential double free of histo->map, histo->bin_count Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 23/34] kernelshark: Fix 'const' type qualifier on return type has no effect Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 24/34] kernelshark: Fix potential memory leaks in libkshark-tepdata Benjamin ROBIN
2024-01-21 18:50 ` Yordan Karadzhov
2024-01-28 19:24 ` [PATCH v2 " Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 25/34] kernelshark: Fix typo in comment of KsGLWidget::resizeGL() Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 26/34] kernelshark: Remove unused KsDataWidget::wipPtr() and broken function Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 27/34] kernelshark: In KsTimeOffsetDialog() constructor use parent param Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 28/34] kernelshark: Fixed loop counter incremented suspiciously twice Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 29/34] kernelshark: Fix tepdata_dump_entry() for event_id = KS_EVENT_OVERFLOW Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 30/34] kernelshark: Use static_cast instead of C cast in KsMainWindow Benjamin ROBIN
2024-01-14 17:17 ` Benjamin ROBIN [this message]
2024-01-21 19:09 ` [PATCH 31/34] kernelshark: Fix comparison of integers of different signs warnings Yordan Karadzhov
2024-01-14 17:17 ` [PATCH 32/34] kernelshark: Fix KsTableView columns width, and KsTraceViewer size Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 33/34] kernelshark: Allow to reduce a bit more the graph height Benjamin ROBIN
2024-01-21 19:37 ` Yordan Karadzhov
2024-01-28 18:59 ` [PATCH v2 " Benjamin ROBIN
2024-01-14 17:17 ` [PATCH 34/34] kernelshark: Cleanup of KsDualMarker methods Benjamin ROBIN
2024-01-21 17:08 ` [PATCH 00/34] Fix kernelshark issues introduced by the migration to Qt6 Yordan Karadzhov
2024-03-03 9:56 ` Benjamin ROBIN
2024-03-03 15:47 ` Yordan Karadzhov
2024-03-03 17:07 ` Sudip Mukherjee
2024-03-03 20:43 ` Sudip Mukherjee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240114171723.14092-32-dev@benjarobin.fr \
--to=dev@benjarobin.fr \
--cc=linux-trace-devel@vger.kernel.org \
--cc=y.karadz@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).