aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDario Lombardo <lomato@gmail.com>2016-10-25 11:52:28 +0200
committerMichael Mann <mmann78@netscape.net>2016-10-26 21:45:03 +0000
commit8d0af2f57826b309404c5b7f3b02aaf5b3171f27 (patch)
tree40c0fa2aae111de1484854a48c8bf337d35be854
parentdab4ea552dbeccbb403b6aff701a9de3bc25a64a (diff)
Gtk: remove atoi calls and use ws_strtoi functions.
Change-Id: Ie38bdd27d9e3810e3a64b985dfd5621a3aa6d073 Reviewed-on: https://code.wireshark.org/review/18445 Reviewed-by: Peter Wu <peter@lekensteyn.nl> Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r--ui/gtk/capture_dlg.c26
-rw-r--r--ui/gtk/expert_comp_table.c12
-rw-r--r--ui/gtk/main_80211_toolbar.c4
-rw-r--r--ui/gtk/rlc_lte_graph.c7
-rw-r--r--ui/gtk/rlc_lte_stat_dlg.c8
-rw-r--r--ui/gtk/sctp_graph_dlg.c7
-rw-r--r--ui/gtk/tcp_graph.c6
7 files changed, 52 insertions, 18 deletions
diff --git a/ui/gtk/capture_dlg.c b/ui/gtk/capture_dlg.c
index 5958987456..6b92f69924 100644
--- a/ui/gtk/capture_dlg.c
+++ b/ui/gtk/capture_dlg.c
@@ -35,6 +35,7 @@
#include <epan/addr_resolv.h>
#include <epan/prefs.h>
#include <wsutil/filesystem.h>
+#include <wsutil/strtoi.h>
#include "ui/capture.h"
#include "caputils/capture_ifinfo.h"
@@ -2666,7 +2667,12 @@ void options_interface_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColum
break;
}
}
- marked_row = atoi(gtk_tree_path_to_string(path));
+ // not sure if this can happen, just to be sure...
+ if (gtk_tree_path_get_depth(path) == 0) {
+ marked_row = 0;
+ } else {
+ marked_row = gtk_tree_path_get_indices(path)[0];
+ }
opt_edit_w = dlg_window_new("Edit Interface Settings");
gtk_window_set_modal(GTK_WINDOW(opt_edit_w), TRUE);
gtk_window_set_type_hint (GTK_WINDOW (opt_edit_w), GDK_WINDOW_TYPE_HINT_DIALOG);
@@ -3584,15 +3590,23 @@ pipe_del_bt_clicked_cb(GtkWidget *w _U_, gpointer data _U_)
GtkTreeModel *model, *optmodel;
GtkTreeIter iter, optiter;
GtkTreeView *if_cb;
+ GtkTreePath *path;
gchar *name, *optname = NULL;
guint i;
+ gint32 num;
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(pipe_l));
/* If something was selected */
if (gtk_tree_selection_get_selected(sel, &model, &iter)) {
gtk_tree_model_get(model, &iter, 0, &name, -1);
- if (name != NULL && atoi(gtk_tree_model_get_string_from_iter(model, &iter)) < (gint)global_capture_opts.all_ifaces->len) {
+ path = gtk_tree_model_get_path(model, &iter);
+ if (gtk_tree_path_get_depth(path) == 0) {
+ num = 0;
+ } else {
+ num = gtk_tree_path_get_indices(path)[0];
+ }
+ if (name != NULL && num < (gint)global_capture_opts.all_ifaces->len) {
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
if (strcmp(g_array_index(global_capture_opts.all_ifaces, interface_t, i).name, name) == 0) {
g_array_remove_index(global_capture_opts.all_ifaces, i);
@@ -5837,7 +5851,13 @@ activate_monitor(GtkTreeViewColumn *tree_column _U_, GtkCellRenderer *renderer,
{
interface_t device;
GtkTreePath *path = gtk_tree_model_get_path(tree_model, iter);
- int indx = atoi(gtk_tree_path_to_string(path));
+ int indx = 0;
+
+ if (gtk_tree_path_get_depth(path) == 0) {
+ indx = 0;
+ } else {
+ indx = gtk_tree_path_get_indices(path)[0];
+ }
device = g_array_index(global_capture_opts.all_ifaces, interface_t, indx);
diff --git a/ui/gtk/expert_comp_table.c b/ui/gtk/expert_comp_table.c
index c215fc05a2..53bd0c3dac 100644
--- a/ui/gtk/expert_comp_table.c
+++ b/ui/gtk/expert_comp_table.c
@@ -37,6 +37,7 @@
#include "ui/simple_dialog.h"
#include <wsutil/utf8_entities.h>
+#include <wsutil/strtoi.h>
#include "ui/gtk/expert_comp_table.h"
#include "ui/gtk/filter_utils.h"
@@ -115,9 +116,10 @@ proto_sort_func(GtkTreeModel *model,
}
else {
if (grp == packet) {
- gint int_a = atoi(str_a);
- gint int_b = atoi(str_b);
- if (int_a == int_b)
+ gint int_a = 0;
+ gint int_b = 0;
+ if (!ws_strtoi32(str_a, NULL, &int_a) || !ws_strtoi32(str_b, NULL, &int_b) ||
+ int_a == int_b)
ret = 0;
else if (int_a < int_b)
ret = -1;
@@ -577,6 +579,7 @@ expert_goto_pkt_cb (GtkTreeSelection *selection, gpointer data _U_)
GtkTreeIter iter;
GtkTreeModel *model;
gchar *pkt;
+ gint32 pkt_num = 0;
gchar *grp;
if (gtk_tree_selection_get_selected (selection, &model, &iter))
@@ -589,7 +592,8 @@ expert_goto_pkt_cb (GtkTreeSelection *selection, gpointer data _U_)
-1);
if (strcmp(grp, packet)==0) {
- cf_goto_frame(&cfile, atoi(pkt));
+ if (ws_strtoi32(pkt, NULL, &pkt_num))
+ cf_goto_frame(&cfile, pkt_num);
}
g_free (pkt);
}
diff --git a/ui/gtk/main_80211_toolbar.c b/ui/gtk/main_80211_toolbar.c
index 83150fcaac..153b09d0cd 100644
--- a/ui/gtk/main_80211_toolbar.c
+++ b/ui/gtk/main_80211_toolbar.c
@@ -44,6 +44,7 @@
#include <capchild/capture_sync.h>
#include <wsutil/frequency-utils.h>
+#include <wsutil/strtoi.h>
static GtkWidget *tb80211_tb, *tb80211_iface_list_box, *tb80211_freq_list_box, *tb80211_chan_type_box, *tb80211_info_label;
@@ -175,7 +176,8 @@ tb80211_do_set_channel(char *iface, int freq, int type)
/* Parse the error msg */
if (ret && primary_msg) {
- return atoi(primary_msg);
+ ws_strtoi32(primary_msg, NULL, &ret);
+ return ret;
}
g_free(data);
g_free(primary_msg);
diff --git a/ui/gtk/rlc_lte_graph.c b/ui/gtk/rlc_lte_graph.c
index 0fc380894d..7bc23c7f04 100644
--- a/ui/gtk/rlc_lte_graph.c
+++ b/ui/gtk/rlc_lte_graph.c
@@ -51,6 +51,8 @@
#include "ui/gtk/old-gtk-compat.h"
+#include <wsutil/strtoi.h>
+
#ifndef HAVE_LRINT
#define lrint rint
#endif
@@ -2705,10 +2707,11 @@ static void rlc_lte_make_elmtlist(struct gtk_rlc_graph *g)
static int rint(double x)
{
char *buf;
- int i,dec,sig;
+ int i = 0;
+ int dec,sig;
buf = _fcvt(x, 0, &dec, &sig);
- i = atoi(buf);
+ ws_strtoi32(buf, NULL, &i);
if (sig == 1) {
i = i * -1;
}
diff --git a/ui/gtk/rlc_lte_stat_dlg.c b/ui/gtk/rlc_lte_stat_dlg.c
index 4bb6f87477..16939fa10e 100644
--- a/ui/gtk/rlc_lte_stat_dlg.c
+++ b/ui/gtk/rlc_lte_stat_dlg.c
@@ -41,6 +41,8 @@
#include "ui/simple_dialog.h"
#include <epan/stat_groups.h>
+#include <wsutil/strtoi.h>
+
#include "ui/gtk/dlg_utils.h"
#include "ui/gtk/gui_stat_menu.h"
#include "ui/gtk/tap_param_dlg.h"
@@ -1155,7 +1157,7 @@ static void ul_filter_clicked(GtkWindow *win _U_, rlc_lte_stat_t* hs)
/* Read SN to filter on (if present) */
sn_string = gtk_entry_get_text(GTK_ENTRY(hs->sn_filter_te));
if (strlen(sn_string) > 0) {
- sn = atoi(sn_string);
+ ws_strtoi32(sn_string, NULL, &sn);
}
if (!get_channel_selection(hs, &ueid, &rlcMode, &channelType, &channelId)) {
@@ -1184,7 +1186,7 @@ static void dl_filter_clicked(GtkWindow *win _U_, rlc_lte_stat_t* hs)
/* Read SN to filter on (if present) */
sn_string = gtk_entry_get_text(GTK_ENTRY(hs->sn_filter_te));
if (strlen(sn_string) > 0) {
- sn = atoi(sn_string);
+ ws_strtoi32(sn_string, NULL, &sn);
}
if (!get_channel_selection(hs, &ueid, &rlcMode, &channelType, &channelId)) {
@@ -1213,7 +1215,7 @@ static void uldl_filter_clicked(GtkWindow *win _U_, rlc_lte_stat_t* hs)
/* Read SN to filter on (if present) */
sn_string = gtk_entry_get_text(GTK_ENTRY(hs->sn_filter_te));
if (strlen(sn_string) > 0) {
- sn = atoi(sn_string);
+ ws_strtoi32(sn_string, NULL, &sn);
}
if (!get_channel_selection(hs, &ueid, &rlcMode, &channelType, &channelId)) {
diff --git a/ui/gtk/sctp_graph_dlg.c b/ui/gtk/sctp_graph_dlg.c
index 0a59191015..9a6399e8e7 100644
--- a/ui/gtk/sctp_graph_dlg.c
+++ b/ui/gtk/sctp_graph_dlg.c
@@ -29,7 +29,7 @@
#include <gtk/gtk.h>
-
+#include <wsutil/strtoi.h>
#include "ui/simple_dialog.h"
#include "ui/gtk/dlg_utils.h"
@@ -1862,10 +1862,11 @@ static int
rint (double x)
{
char *buf;
- int i,dec,sig;
+ int i = 0
+ int dec,sig;
buf = _fcvt(x, 0, &dec, &sig);
- i = atoi(buf);
+ ws_strtoi32(buf, NULL, &i);
if(sig == 1) {
i = i * -1;
}
diff --git a/ui/gtk/tcp_graph.c b/ui/gtk/tcp_graph.c
index 5dec596645..3e181d2f2b 100644
--- a/ui/gtk/tcp_graph.c
+++ b/ui/gtk/tcp_graph.c
@@ -48,6 +48,7 @@
#include <epan/stat_groups.h>
#include "ui/tap-tcp-stream.h"
#include <wsutil/utf8_entities.h>
+#include <wsutil/strtoi.h>
#include "ui/gtk/gui_utils.h"
#include "ui/gtk/dlg_utils.h"
@@ -4495,10 +4496,11 @@ static void wscale_make_elmtlist(struct gtk_graph *g)
static int rint(double x)
{
char *buf;
- int i, dec, sig;
+ int i = 0;
+ int dec, sig;
buf = _fcvt(x, 0, &dec, &sig);
- i = atoi(buf);
+ ws_strtoi32(buf, NULL. &i);
if (sig == 1) {
i = i * -1;
}