summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorruengeler <ruengeler@wireshark.org>2015-12-03 13:47:33 +0100
committerAnders Broman <a.broman58@gmail.com>2015-12-07 07:14:57 +0000
commitd8bbd232cdd910e70ce15f9a11d0986b6a5c4621 (patch)
tree41f2a1d31e2da6ab1990af5f2f30e9b5f619c921 /ui
parent9a9b1c9bbaba1e23a17b6a3f06afac7116c6a82b (diff)
downloadwireshark-d8bbd232cdd910e70ce15f9a11d0986b6a5c4621.tar.gz
SCTP: Fix warning found by PVS Studio
Change-Id: I713eb6eff3681573baf77274847a32a4cc6b9ee0 Reviewed-on: https://code.wireshark.org/review/12408 Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/gtk/sctp_byte_graph_dlg.c6
-rw-r--r--ui/gtk/sctp_chunk_stat_dlg.c27
-rw-r--r--ui/gtk/sctp_graph_dlg.c8
-rw-r--r--ui/qt/sctp_all_assocs_dialog.cpp1
-rw-r--r--ui/qt/sctp_chunk_statistics_dialog.cpp4
-rw-r--r--ui/qt/sctp_graph_byte_dialog.cpp2
-rw-r--r--ui/tap-sctp-analysis.c9
7 files changed, 19 insertions, 38 deletions
diff --git a/ui/gtk/sctp_byte_graph_dlg.c b/ui/gtk/sctp_byte_graph_dlg.c
index 4b1815497c..c55c1f14a4 100644
--- a/ui/gtk/sctp_byte_graph_dlg.c
+++ b/ui/gtk/sctp_byte_graph_dlg.c
@@ -1017,8 +1017,8 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
GtkAllocation widget_alloc;
cairo_t *cr;
- g_snprintf(label_string, 15, "%d", 0);
- memcpy(label_string,(gchar *)g_locale_to_utf8(label_string, -1 , NULL, NULL, NULL), 15);
+ g_snprintf(label_string, sizeof(label_string), "%d", 0);
+ memcpy(label_string,(gchar *)g_locale_to_utf8(label_string, -1 , NULL, NULL, NULL), sizeof(label_string));
layout = gtk_widget_create_pango_layout(u_data->io->draw_area, label_string);
pango_layout_get_pixel_size(layout, &label_width, &label_height);
@@ -1197,7 +1197,7 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
else
position = event->x + 5;
- memcpy(label_string,(gchar *)g_locale_to_utf8(label_string, -1 , NULL, NULL, NULL), 15);
+ memcpy(label_string,(gchar *)g_locale_to_utf8(label_string, -1 , NULL, NULL, NULL), sizeof(label_string));
pango_layout_set_text(layout, label_string, -1);
pango_layout_get_pixel_size(layout, &lwidth, NULL);
diff --git a/ui/gtk/sctp_chunk_stat_dlg.c b/ui/gtk/sctp_chunk_stat_dlg.c
index 2fbc6ff81e..7ff8fb32e4 100644
--- a/ui/gtk/sctp_chunk_stat_dlg.c
+++ b/ui/gtk/sctp_chunk_stat_dlg.c
@@ -482,18 +482,6 @@ chunk_dlg_destroy(GObject *object _U_, gpointer user_data)
}
static void
-on_destroy(GObject *object _U_, gpointer user_data)
-{
- struct sctp_udata *u_data = (struct sctp_udata*)user_data;
-
- decrease_childcount(u_data->parent);
- remove_child(u_data, u_data->parent);
- g_free(u_data->io);
- g_free(u_data);
-}
-
-
-static void
add_to_clist(sctp_addr_chunk* sac)
{
GtkListStore *list_store = NULL;
@@ -579,17 +567,6 @@ sctp_chunk_stat_on_close (GtkButton *button _U_, gpointer user_data)
}
static void
-on_close_dlg (GtkButton *button _U_, gpointer user_data)
-{
- struct sctp_udata *udata;
-
- udata = (struct sctp_udata *)user_data;
- gtk_grab_remove(udata->io->window);
- gtk_widget_destroy(udata->io->window);
-}
-
-
-static void
path_window_set_title(struct sctp_udata *u_data, unsigned int direction)
{
char *display_name;
@@ -692,7 +669,7 @@ sctp_chunk_dlg(struct sctp_udata *u_data)
u_data->io->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_position (GTK_WINDOW (u_data->io->window), GTK_WIN_POS_CENTER);
gtk_widget_set_size_request(u_data->io->window, 500, 650);
- g_signal_connect(u_data->io->window, "destroy", G_CALLBACK(on_destroy), u_data);
+ g_signal_connect(u_data->io->window, "destroy", G_CALLBACK(chunk_dlg_destroy), u_data);
/* Container for each row of widgets */
main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 12, FALSE);
@@ -778,7 +755,7 @@ sctp_chunk_dlg(struct sctp_udata *u_data)
close_bt = ws_gtk_button_new_from_stock(GTK_STOCK_CLOSE);
gtk_box_pack_start(GTK_BOX(h_button_box), close_bt, FALSE, FALSE, 0);
gtk_widget_show(close_bt);
- g_signal_connect(close_bt, "clicked", G_CALLBACK(on_close_dlg), u_data);
+ g_signal_connect(close_bt, "clicked", G_CALLBACK(sctp_chunk_stat_on_close), u_data);
gtk_widget_show_all(u_data->io->window);
chunk_window_set_title(u_data);
diff --git a/ui/gtk/sctp_graph_dlg.c b/ui/gtk/sctp_graph_dlg.c
index 0811c3671c..3a0e055071 100644
--- a/ui/gtk/sctp_graph_dlg.c
+++ b/ui/gtk/sctp_graph_dlg.c
@@ -1416,8 +1416,8 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
PangoLayout *layout;
cairo_t *cr;
- g_snprintf(label_string, 15, "%d", 0);
- memcpy(label_string,(gchar *)g_locale_to_utf8(label_string, -1 , NULL, NULL, NULL), 15);
+ g_snprintf(label_string, sizeof(label_string), "%d", 0);
+ memcpy(label_string,(gchar *)g_locale_to_utf8(label_string, -1 , NULL, NULL, NULL), sizeof(label_string));
layout = gtk_widget_create_pango_layout(u_data->io->draw_area, label_string);
pango_layout_get_pixel_size(layout, &label_width, &label_height);
@@ -1542,7 +1542,7 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
sacklist = u_data->assoc->sort_sack2;
s_size = u_data->assoc->n_sack_chunks_ep2;
}
- x_tolerance = (gdouble)((u_data->io->tmp_width / u_data->io->axis_width*1.0))*5/1000000.0;
+ x_tolerance = (gdouble)(u_data->io->tmp_width / u_data->io->axis_width*1.0)*5/1000000.0;
y_tolerance = (guint32)(((u_data->io->max_y - u_data->io->min_y) / (u_data->io->surface_height-TOP_BORDER-BOTTOM_BORDER-u_data->io->offset)) * 2.0);
if (y_tolerance==0)
y_tolerance = 2;
@@ -1623,7 +1623,7 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer
position = event->x + 5;
- memcpy(label_string,(gchar *)g_locale_to_utf8(label_string, -1 , NULL, NULL, NULL), 15);
+ memcpy(label_string,(gchar *)g_locale_to_utf8(label_string, -1 , NULL, NULL, NULL), sizeof(label_string));
pango_layout_set_text(layout, label_string, -1);
pango_layout_get_pixel_size(layout, &lwidth, NULL);
diff --git a/ui/qt/sctp_all_assocs_dialog.cpp b/ui/qt/sctp_all_assocs_dialog.cpp
index a337de50f7..618f9d3d2b 100644
--- a/ui/qt/sctp_all_assocs_dialog.cpp
+++ b/ui/qt/sctp_all_assocs_dialog.cpp
@@ -57,7 +57,6 @@ SCTPAllAssocsDialog::~SCTPAllAssocsDialog()
void SCTPAllAssocsDialog::fillTable()
{
- QString output;
GList *list;
sctp_assoc_info_t* assinfo;
int numAssocs;
diff --git a/ui/qt/sctp_chunk_statistics_dialog.cpp b/ui/qt/sctp_chunk_statistics_dialog.cpp
index 8642a7bd94..9a20381c4c 100644
--- a/ui/qt/sctp_chunk_statistics_dialog.cpp
+++ b/ui/qt/sctp_chunk_statistics_dialog.cpp
@@ -235,9 +235,11 @@ void SCTPChunkStatisticsDialog::on_pushButton_clicked()
fprintf(fp,"# This file is automatically generated, DO NOT MODIFY.\n");
char str[40];
+ struct chunkTypes tempChunk;
for (int i = 0; i < chunks.size(); i++) {
- g_snprintf(str, sizeof str, "\"%d\",\"%s\",\"%s\"\n", chunks.value(i).id, chunks.value(i).name, (chunks.value(i).hide==0?"Show":"Hide"));
+ tempChunk = chunks.value(i);
+ g_snprintf(str, sizeof str, "\"%d\",\"%s\",\"%s\"\n", tempChunk.id, tempChunk.name, tempChunk.hide==0?"Show":"Hide");
fputs(str, fp);
void *rec = g_malloc0(uat->record_size);
uat_add_record(uat, rec, TRUE);
diff --git a/ui/qt/sctp_graph_byte_dialog.cpp b/ui/qt/sctp_graph_byte_dialog.cpp
index 4af5a847e2..9c369e82ba 100644
--- a/ui/qt/sctp_graph_byte_dialog.cpp
+++ b/ui/qt/sctp_graph_byte_dialog.cpp
@@ -72,7 +72,7 @@ void SCTPGraphByteDialog::drawBytesGraph()
tsn_t *tsn;
guint8 type;
guint32 maxBytes;
- long sumBytes = 0;
+ guint64 sumBytes = 0;
if (direction == 1) {
maxBytes = selected_assoc->n_data_bytes_ep1;
diff --git a/ui/tap-sctp-analysis.c b/ui/tap-sctp-analysis.c
index 4df0dc4128..d2ae35a3fe 100644
--- a/ui/tap-sctp-analysis.c
+++ b/ui/tap-sctp-analysis.c
@@ -181,7 +181,8 @@ calc_checksum(const struct _sctp_info *check_data, sctp_assoc_info_t *data)
{
if ((float)(data->n_adler32_correct*1.0/data->n_adler32_calculated) > 0.5)
{
- g_strlcpy(data->checksum_type,"ADLER32",8);
+ char str[] = "ADLER32";
+ g_strlcpy(data->checksum_type, str, strlen(str));
data->n_checksum_errors=(data->n_adler32_calculated-data->n_adler32_correct);
ok = TRUE;
}
@@ -191,7 +192,8 @@ calc_checksum(const struct _sctp_info *check_data, sctp_assoc_info_t *data)
{
if ((float)(data->n_crc32c_correct*1.0/data->n_crc32c_calculated) > 0.5)
{
- g_strlcpy(data->checksum_type,"CRC32C",8);
+ char str[] = "CRC32C";
+ g_strlcpy(data->checksum_type, str, strlen(str));
data->n_checksum_errors=data->n_crc32c_calculated-data->n_crc32c_correct;
ok = TRUE;
}
@@ -199,7 +201,8 @@ calc_checksum(const struct _sctp_info *check_data, sctp_assoc_info_t *data)
if (!ok)
{
- g_strlcpy(data->checksum_type,"UNKNOWN",8);
+ char str[] = "UNKNOWN";
+ g_strlcpy(data->checksum_type, str, strlen(str));
data->n_checksum_errors=0;
}