diff options
author | Guy Harris <guy@alum.mit.edu> | 2015-12-29 00:00:59 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2015-12-29 08:01:54 +0000 |
commit | ddd217469de7032a3509369b3ca7dfca55374c2e (patch) | |
tree | 781bd60b0289cd9d0c8cabfacecbe0eb8df7c76e /ui | |
parent | 98456ce10f92dcb58c65ca0506c143d5e767ddd1 (diff) | |
download | wireshark-ddd217469de7032a3509369b3ca7dfca55374c2e.tar.gz |
Always supply a g_mallocated error message from select_rlc_lte_session().
That way, we don't have to pass a "free this" indication separately.
While we're at it, don't just free the error message, *display* it in
all cases where rlc_graph_segment_list_get() fails.
(I wish more programming languages had a proper string type, including
some whose names consist solely of the third letter of the alphabet, but
I digress....)
Change-Id: I99f8b088aa19bc8fbb178bdb36d85ba5b89c06e0
Reviewed-on: https://code.wireshark.org/review/12902
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/gtk/rlc_lte_graph.c | 20 | ||||
-rw-r--r-- | ui/qt/lte_rlc_graph_dialog.cpp | 7 | ||||
-rw-r--r-- | ui/tap-rlc-graph.c | 16 | ||||
-rw-r--r-- | ui/tap-rlc-graph.h | 4 |
4 files changed, 22 insertions, 25 deletions
diff --git a/ui/gtk/rlc_lte_graph.c b/ui/gtk/rlc_lte_graph.c index a352b21a20..efb314693f 100644 --- a/ui/gtk/rlc_lte_graph.c +++ b/ui/gtk/rlc_lte_graph.c @@ -376,16 +376,13 @@ void rlc_lte_graph_cb(GtkAction *action _U_, gpointer user_data _U_) struct rlc_segment current; struct gtk_rlc_graph *g; gchar *err_msg = NULL; - gboolean free_err_msg = FALSE; debug(DBS_FENTRY) puts("rlc_lte_graph_cb()"); /* Can we choose an RLC channel from the selected frame? */ - if (!select_rlc_lte_session(&cfile, ¤t, &err_msg, &free_err_msg)) { + if (!select_rlc_lte_session(&cfile, ¤t, &err_msg)) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg); - if (free_err_msg) { - g_free(err_msg); - } + g_free(err_msg); return; } @@ -397,7 +394,11 @@ void rlc_lte_graph_cb(GtkAction *action _U_, gpointer user_data _U_) graph_initialize_values(g); /* Get our list of segments from the packet list */ - rlc_graph_segment_list_get(&cfile, &(g->graph), FALSE, &err_msg, &free_err_msg); + if (!rlc_graph_segment_list_get(&cfile, &(g->graph), FALSE, &err_msg)) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg); + g_free(err_msg); + return; + } create_gui(g); graph_init_sequence(g); @@ -409,7 +410,6 @@ void rlc_lte_graph_known_channel_launch(guint16 ueid, guint8 rlcMode, { struct gtk_rlc_graph *g; gchar *err_msg = NULL; - gboolean free_err_msg = FALSE; debug(DBS_FENTRY) puts("rlc_lte_graph_known_channel_launch()"); @@ -429,7 +429,11 @@ void rlc_lte_graph_known_channel_launch(guint16 ueid, guint8 rlcMode, g->graph.channelSet = TRUE; /* Get our list of segments from the packet list */ - rlc_graph_segment_list_get(&cfile, &(g->graph), TRUE, &err_msg, &free_err_msg); + if (!rlc_graph_segment_list_get(&cfile, &(g->graph), TRUE, &err_msg)) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg); + g_free(err_msg); + return; + } create_gui(g); graph_init_sequence(g); diff --git a/ui/qt/lte_rlc_graph_dialog.cpp b/ui/qt/lte_rlc_graph_dialog.cpp index 744287a7ef..2327c89e4a 100644 --- a/ui/qt/lte_rlc_graph_dialog.cpp +++ b/ui/qt/lte_rlc_graph_dialog.cpp @@ -200,17 +200,14 @@ void LteRlcGraphDialog::findChannel() disconnect(rp, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoved(QMouseEvent*))); char *err_string = NULL; - gboolean free_err_string = FALSE; // Rescan for channel data. rlc_graph_segment_list_free(&graph_); if (!rlc_graph_segment_list_get(cap_file_.capFile(), &graph_, graph_.channelSet, - &err_string, &free_err_string)) { + &err_string)) { // Pop up an error box to report error. simple_error_message_box("%s", err_string); - if (free_err_string) { - g_free(err_string); - } + g_free(err_string); return; } diff --git a/ui/tap-rlc-graph.c b/ui/tap-rlc-graph.c index 20b8a582ca..b964ea272c 100644 --- a/ui/tap-rlc-graph.c +++ b/ui/tap-rlc-graph.c @@ -108,7 +108,7 @@ tap_lte_rlc_packet(void *pct, packet_info *pinfo _U_, epan_dissect_t *edt _U_, c * depending upon which GUI toolkit is being used. */ rlc_lte_tap_info *select_rlc_lte_session(capture_file *cf, struct rlc_segment *hdrs, - gchar **err_msg, gboolean *free_err_msg) + gchar **err_msg) { frame_data *fdata; epan_dissect_t edt; @@ -127,7 +127,6 @@ rlc_lte_tap_info *select_rlc_lte_session(capture_file *cf, /* No real filter yet */ if (!dfilter_compile("rlc-lte", &sfcode, err_msg)) { - *free_err_msg = TRUE; return NULL; } @@ -156,16 +155,14 @@ rlc_lte_tap_info *select_rlc_lte_session(capture_file *cf, /* This "shouldn't happen", as the graph menu items won't * even be enabled if the selected packet isn't an RLC PDU. */ - *err_msg = "Selected packet doesn't have an RLC PDU"; - *free_err_msg = FALSE; + *err_msg = g_strdup("Selected packet doesn't have an RLC PDU"); return NULL; } /* XXX fix this later, we should show a dialog allowing the user * to select which session he wants here */ if (th.num_hdrs>1){ /* Can only handle a single RLC channel yet */ - *err_msg = "The selected packet has more than one LTE RLC channel in it."; - *free_err_msg = FALSE; + *err_msg = g_strdup("The selected packet has more than one LTE RLC channel in it."); return NULL; } @@ -250,7 +247,7 @@ int rlc_lte_tap_for_graph_data(void *pct, packet_info *pinfo, epan_dissect_t *ed /* If don't have a channel, try to get one from current frame, then read all frames looking for data * for that channel. */ gboolean rlc_graph_segment_list_get(capture_file *cf, struct rlc_graph *g, gboolean stream_known, - char **err_string, gboolean *free_err_string) + char **err_string) { struct rlc_segment current; GString *error_string; @@ -263,7 +260,7 @@ gboolean rlc_graph_segment_list_get(capture_file *cf, struct rlc_graph *g, gbool } if (!stream_known) { - struct rlc_lte_tap_info *header = select_rlc_lte_session(cf, ¤t, err_string, free_err_string); + struct rlc_lte_tap_info *header = select_rlc_lte_session(cf, ¤t, err_string); if (!header) { /* Didn't have a channel, and current frame didn't provide one */ return FALSE; @@ -294,8 +291,7 @@ gboolean rlc_graph_segment_list_get(capture_file *cf, struct rlc_graph *g, gbool remove_tap_listener(g); if (g->last_segment == NULL) { - *err_string = "No packets found"; - *free_err_string = FALSE; + *err_string = g_strdup("No packets found"); return FALSE; } diff --git a/ui/tap-rlc-graph.h b/ui/tap-rlc-graph.h index 748471d1c9..679b89717e 100644 --- a/ui/tap-rlc-graph.h +++ b/ui/tap-rlc-graph.h @@ -83,7 +83,7 @@ struct rlc_graph { }; gboolean rlc_graph_segment_list_get(capture_file *cf, struct rlc_graph *tg, gboolean stream_known, - char **err_string, gboolean *free_err_string); + char **err_string); void rlc_graph_segment_list_free(struct rlc_graph * ); @@ -92,7 +92,7 @@ int compare_rlc_headers(guint16 ueid1, guint16 channelType1, guint16 channelId1, guint16 ueid2, guint16 channelType2, guint16 channelId2, guint8 rlcMode2, guint8 direction2, gboolean isControlFrame); rlc_lte_tap_info *select_rlc_lte_session(capture_file *cf, struct rlc_segment *hdrs, - gchar **err_msg, gboolean *free_err_msg); + gchar **err_msg); int rlc_lte_tap_for_graph_data(void *pct, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *vip); |