aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Knall <rknall@gmail.com>2019-08-14 10:18:51 +0200
committerRoland Knall <rknall@gmail.com>2019-08-30 13:37:25 +0000
commita53545c0c81ac71aaa10ae91d080f1640551b5b8 (patch)
tree77bf1f42dfa8d10607a05b69929f5efcaa36c6eb
parentb43ff704446cd7a3b4c5dc3fa4268f5ebac2c326 (diff)
Qt: Add macro for g_list_next for C++
Using a simple (type *) cast on g_list_next results in a warning with modern compilers "old-style cast" Adding a warning for g_list_next and data access to avoid the warning A good overview why reinterpret_cast has been used can be found here: https://stackoverflow.com/questions/332030/when-should-static-cast-dynamic-cast-const-cast-and-reinterpret-cast-be-used It is a 1:1 replacement in this case, but does not use any of the new cast styles and therefore should be used with caution. Change-Id: I989f237afc39aaf40133a788b1c0bbd7a51bf974 Reviewed-on: https://code.wireshark.org/review/34284 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com>
-rw-r--r--ui/qt/capture_interfaces_dialog.cpp26
-rw-r--r--ui/qt/extcap_options_dialog.cpp18
-rw-r--r--ui/qt/filter_dialog.cpp4
-rw-r--r--ui/qt/follow_stream_dialog.cpp18
-rw-r--r--ui/qt/iax2_analysis_dialog.cpp8
-rw-r--r--ui/qt/main_window.cpp40
-rw-r--r--ui/qt/main_window_slots.cpp4
-rw-r--r--ui/qt/manage_interfaces_dialog.cpp10
-rw-r--r--ui/qt/models/interface_tree_model.cpp4
-rw-r--r--ui/qt/models/pref_models.cpp4
-rw-r--r--ui/qt/models/profile_model.cpp2
-rw-r--r--ui/qt/models/voip_calls_info_model.cpp4
-rw-r--r--ui/qt/multicast_statistics_dialog.cpp4
-rw-r--r--ui/qt/preferences_dialog.cpp16
-rw-r--r--ui/qt/rtp_analysis_dialog.cpp6
-rw-r--r--ui/qt/rtp_stream_dialog.cpp6
-rw-r--r--ui/qt/sctp_all_assocs_dialog.cpp6
-rw-r--r--ui/qt/sctp_assoc_analyse_dialog.cpp20
-rw-r--r--ui/qt/sctp_graph_arwnd_dialog.cpp14
-rw-r--r--ui/qt/sctp_graph_byte_dialog.cpp14
-rw-r--r--ui/qt/sctp_graph_dialog.cpp52
-rw-r--r--ui/qt/sequence_diagram.cpp8
-rw-r--r--ui/qt/utils/qt_ui_utils.h10
-rw-r--r--ui/qt/voip_calls_dialog.cpp32
-rw-r--r--ui/qt/widgets/additional_toolbar.cpp14
-rw-r--r--ui/qt/widgets/capture_filter_combo.cpp4
-rw-r--r--ui/qt/widgets/capture_filter_edit.cpp16
-rw-r--r--ui/qt/widgets/display_filter_edit.cpp17
28 files changed, 196 insertions, 185 deletions
diff --git a/ui/qt/capture_interfaces_dialog.cpp b/ui/qt/capture_interfaces_dialog.cpp
index 8fe1c61d72..c238c98897 100644
--- a/ui/qt/capture_interfaces_dialog.cpp
+++ b/ui/qt/capture_interfaces_dialog.cpp
@@ -116,8 +116,8 @@ public:
linkname = "Unknown";
else {
linkname = QObject::tr("DLT %1").arg(device->active_dlt);
- for (GList *list = device->links; list != NULL; list = g_list_next(list)) {
- link_row *linkr = (link_row*)(list->data);
+ for (GList *list = device->links; list != NULL; list = gxx_list_next(list)) {
+ link_row *linkr = gxx_list_data(link_row *, list);
if (linkr->dlt == device->active_dlt) {
linkname = linkr->name;
break;
@@ -415,10 +415,10 @@ void CaptureInterfacesDialog::interfaceItemChanged(QTreeWidgetItem *item, int co
caps = capture_get_if_capabilities(device->name, monitor_mode, auth_str, NULL, main_window_update);
g_free(auth_str);
- if (caps != NULL) {
+ if (caps != Q_NULLPTR) {
- for (int i = (gint)g_list_length(device->links)-1; i >= 0; i--) {
- GList* rem = g_list_nth(device->links, i);
+ for (int i = static_cast<int>(g_list_length(device->links)) - 1; i >= 0; i--) {
+ GList* rem = g_list_nth(device->links, static_cast<guint>(i));
device->links = g_list_remove_link(device->links, rem);
g_list_free_1(rem);
}
@@ -426,16 +426,16 @@ void CaptureInterfacesDialog::interfaceItemChanged(QTreeWidgetItem *item, int co
device->monitor_mode_supported = caps->can_set_rfmon;
device->monitor_mode_enabled = monitor_mode;
- for (GList *lt_entry = caps->data_link_types; lt_entry != NULL; lt_entry = g_list_next(lt_entry)) {
- link_row *linkr = (link_row *)g_malloc(sizeof(link_row));
- data_link_info_t *data_link_info = (data_link_info_t *)lt_entry->data;
+ for (GList *lt_entry = caps->data_link_types; lt_entry != Q_NULLPTR; lt_entry = gxx_list_next(lt_entry)) {
+ link_row *linkr = new link_row();
+ data_link_info_t *data_link_info = gxx_list_data(data_link_info_t *, lt_entry);
/*
* For link-layer types libpcap/WinPcap doesn't know about, the
* name will be "DLT n", and the description will be null.
* We mark those as unsupported, and don't allow them to be
* used - capture filters won't work on them, for example.
*/
- if (data_link_info->description != NULL) {
+ if (data_link_info->description != Q_NULLPTR) {
linkr->dlt = data_link_info->dlt;
if (active_dlt_name.isEmpty()) {
device->active_dlt = data_link_info->dlt;
@@ -1238,8 +1238,8 @@ QWidget* InterfaceTreeDelegate::createEditor(QWidget *parent, const QStyleOption
// types we'll have to jump through the hoops necessary to disable
// QComboBox items.
- for (list = links; list != NULL; list = g_list_next(list)) {
- linkr = (link_row*)(list->data);
+ for (list = links; list != Q_NULLPTR; list = gxx_list_next(list)) {
+ linkr = gxx_list_data(link_row*, list);
if (linkr->dlt >= 0) {
valid_link_types << linkr->name;
}
@@ -1322,8 +1322,8 @@ void InterfaceTreeDelegate::linkTypeChanged(QString selected_link_type)
if (!device) {
return;
}
- for (list = device->links; list != NULL; list = g_list_next(list)) {
- temp = (link_row*) (list->data);
+ for (list = device->links; list != Q_NULLPTR; list = gxx_list_next(list)) {
+ temp = gxx_list_data(link_row*, list);
if (!selected_link_type.compare(temp->name)) {
device->active_dlt = temp->dlt;
}
diff --git a/ui/qt/extcap_options_dialog.cpp b/ui/qt/extcap_options_dialog.cpp
index 3abd6c4ce9..c26a6863a1 100644
--- a/ui/qt/extcap_options_dialog.cpp
+++ b/ui/qt/extcap_options_dialog.cpp
@@ -188,27 +188,27 @@ void ExtcapOptionsDialog::anyValueChanged()
void ExtcapOptionsDialog::loadArguments()
{
- GList * arguments = NULL, * walker = NULL, * item = NULL;
- ExtcapArgument * argument = NULL;
+ GList * arguments = Q_NULLPTR, * walker = Q_NULLPTR, * item = Q_NULLPTR;
+ ExtcapArgument * argument = Q_NULLPTR;
if ( device_name.length() == 0 )
return;
extcapArguments.clear();
- arguments = g_list_first(extcap_get_if_configuration((const char *)( device_name.toStdString().c_str() ) ));
+ arguments = g_list_first(extcap_get_if_configuration(device_name.toUtf8().constData()));
ExtcapArgumentList required;
ExtcapArgumentList optional;
walker = arguments;
- while ( walker != NULL )
+ while ( walker != Q_NULLPTR )
{
- item = g_list_first((GList *)(walker->data));
- while ( item != NULL )
+ item = g_list_first(gxx_list_data(GList *, walker));
+ while ( item != Q_NULLPTR )
{
- argument = ExtcapArgument::create((extcap_arg *)(item->data), this);
- if ( argument != NULL )
+ argument = ExtcapArgument::create(gxx_list_data(extcap_arg *, item), this);
+ if ( argument != Q_NULLPTR )
{
if ( argument->isRequired() )
required << argument;
@@ -218,7 +218,7 @@ void ExtcapOptionsDialog::loadArguments()
}
item = item->next;
}
- walker = g_list_next(walker);
+ walker = gxx_list_next(walker);
}
if ( required.length() > 0 )
diff --git a/ui/qt/filter_dialog.cpp b/ui/qt/filter_dialog.cpp
index 8ef43bbb2a..98985baa92 100644
--- a/ui/qt/filter_dialog.cpp
+++ b/ui/qt/filter_dialog.cpp
@@ -114,9 +114,9 @@ void FilterDialog::showEvent(QShowEvent *event)
} else {
filter_list = get_filter_list_first(DFILTER_LIST);
}
- for (GList *fl_item = filter_list; fl_item; fl_item = g_list_next(fl_item)) {
+ for (GList *fl_item = filter_list; fl_item; fl_item = gxx_list_next(fl_item)) {
if (!fl_item->data) continue;
- filter_def *fl_data = (filter_def *) fl_item->data;
+ filter_def *fl_data = gxx_list_data(filter_def *, fl_item);
if (!fl_data->name || !fl_data->strval) continue;
addFilter(fl_data->name, fl_data->strval);
diff --git a/ui/qt/follow_stream_dialog.cpp b/ui/qt/follow_stream_dialog.cpp
index 6af72f133c..d6f96f7679 100644
--- a/ui/qt/follow_stream_dialog.cpp
+++ b/ui/qt/follow_stream_dialog.cpp
@@ -400,8 +400,8 @@ void FollowStreamDialog::resetStream()
if (!data_out_filename_.isEmpty()) {
ws_unlink(data_out_filename_.toUtf8().constData());
}
- for (cur = follow_info_.payload; cur; cur = g_list_next(cur)) {
- follow_record = (follow_record_t *)cur->data;
+ for (cur = follow_info_.payload; cur; cur = gxx_list_next(cur)) {
+ follow_record = gxx_list_data(follow_record_t *, cur);
if(follow_record->data) {
g_byte_array_free(follow_record->data, TRUE);
}
@@ -411,25 +411,25 @@ void FollowStreamDialog::resetStream()
//Only TCP stream uses fragments
if (follow_type_ == FOLLOW_TCP) {
- for (cur = follow_info_.fragments[0]; cur; cur = g_list_next(cur)) {
- follow_record = (follow_record_t *)cur->data;
+ for (cur = follow_info_.fragments[0]; cur; cur = gxx_list_next(cur)) {
+ follow_record = gxx_list_data(follow_record_t *, cur);
if(follow_record->data) {
g_byte_array_free(follow_record->data, TRUE);
}
g_free(follow_record);
}
- follow_info_.fragments[0] = NULL;
- for (cur = follow_info_.fragments[1]; cur; cur = g_list_next(cur)) {
- follow_record = (follow_record_t *)cur->data;
+ follow_info_.fragments[0] = Q_NULLPTR;
+ for (cur = follow_info_.fragments[1]; cur; cur = gxx_list_next(cur)) {
+ follow_record = gxx_list_data(follow_record_t *, cur);
if(follow_record->data) {
g_byte_array_free(follow_record->data, TRUE);
}
g_free(follow_record);
}
- follow_info_.fragments[1] = NULL;
+ follow_info_.fragments[1] = Q_NULLPTR;
}
- follow_info_.payload = NULL;
+ follow_info_.payload = Q_NULLPTR;
follow_info_.client_port = 0;
}
diff --git a/ui/qt/iax2_analysis_dialog.cpp b/ui/qt/iax2_analysis_dialog.cpp
index 2ebdf5f916..de6a6ccb24 100644
--- a/ui/qt/iax2_analysis_dialog.cpp
+++ b/ui/qt/iax2_analysis_dialog.cpp
@@ -352,13 +352,13 @@ Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) :
// register_tap_listener_rtpstream(&tapinfo, NULL);
/* Scan for RTP streams (redissect all packets) */
- rtpstream_scan(&tapinfo, cap_file_.capFile(), NULL);
+ rtpstream_scan(&tapinfo, cap_file_.capFile(), Q_NULLPTR);
int num_streams = 0;
// TODO: Not used
//GList *filtered_list = NULL;
- for (GList *strinfo_list = g_list_first(tapinfo.strinfo_list); strinfo_list; strinfo_list = g_list_next(strinfo_list)) {
- rtpstream_info_t * strinfo = (rtpstream_info_t*)(strinfo_list->data);
+ for (GList *strinfo_list = g_list_first(tapinfo.strinfo_list); strinfo_list; strinfo_list = gxx_list_next(strinfo_list)) {
+ rtpstream_info_t * strinfo = gxx_list_data(rtpstream_info_t*, strinfo_list);
if (rtpstream_id_equal(&(strinfo->id), &(fwd_id_),RTPSTREAM_ID_EQUAL_NONE))
{
++num_streams;
@@ -393,7 +393,7 @@ Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) :
this, SLOT(captureEvent(CaptureEvent)));
updateWidgets();
- registerTapListener("IAX2", this, NULL, 0, tapReset, tapPacket, tapDraw);
+ registerTapListener("IAX2", this, Q_NULLPTR, 0, tapReset, tapPacket, tapDraw);
cap_file_.retapPackets();
removeTapListeners();
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index 2c87bd0a9e..c38279d053 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -2138,9 +2138,9 @@ void MainWindow::initConversationMenus()
<< main_ui_->actionViewColorizeConversation7 << main_ui_->actionViewColorizeConversation8
<< main_ui_->actionViewColorizeConversation9 << main_ui_->actionViewColorizeConversation10;
- for (GList *conv_filter_list_entry = conv_filter_list; conv_filter_list_entry; conv_filter_list_entry = g_list_next(conv_filter_list_entry)) {
+ for (GList *conv_filter_list_entry = conv_filter_list; conv_filter_list_entry; conv_filter_list_entry = gxx_list_next(conv_filter_list_entry)) {
// Main menu items
- conversation_filter_t* conv_filter = (conversation_filter_t *)conv_filter_list_entry->data;
+ conversation_filter_t* conv_filter = gxx_list_data(conversation_filter_t *, conv_filter_list_entry);
ConversationAction *conv_action = new ConversationAction(main_ui_->menuConversationFilter, conv_filter);
main_ui_->menuConversationFilter->addAction(conv_action);
@@ -2717,20 +2717,20 @@ void MainWindow::reloadDynamicMenus()
void MainWindow::externalMenuHelper(ext_menu_t * menu, QMenu * subMenu, gint depth)
{
- QAction * itemAction = NULL;
- ext_menubar_t * item = NULL;
- GList * children = NULL;
+ QAction * itemAction = Q_NULLPTR;
+ ext_menubar_t * item = Q_NULLPTR;
+ GList * children = Q_NULLPTR;
/* There must exists an xpath parent */
- g_assert(subMenu != NULL);
+ Q_ASSERT(subMenu != NULL);
/* If the depth counter exceeds, something must have gone wrong */
- g_assert(depth < EXT_MENUBAR_MAX_DEPTH);
+ Q_ASSERT(depth < EXT_MENUBAR_MAX_DEPTH);
children = menu->children;
/* Iterate the child entries */
while (children && children->data) {
- item = (ext_menubar_t *)children->data;
+ item = gxx_list_data(ext_menubar_t *, children);
if (item->type == EXT_MENUBAR_MENU) {
/* Handle Submenu entry */
@@ -2739,14 +2739,14 @@ void MainWindow::externalMenuHelper(ext_menu_t * menu, QMenu * subMenu, gint de
subMenu->addSeparator();
} else if (item->type == EXT_MENUBAR_ITEM || item->type == EXT_MENUBAR_URL) {
itemAction = subMenu->addAction(item->name);
- itemAction->setData(QVariant::fromValue((void *)item));
+ itemAction->setData(QVariant::fromValue(static_cast<void *>(item)));
itemAction->setText(item->label);
connect(itemAction, SIGNAL(triggered()),
this, SLOT(externalMenuItem_triggered()));
}
/* Iterate Loop */
- children = g_list_next(children);
+ children = gxx_list_next(children);
}
}
@@ -2772,13 +2772,13 @@ void MainWindow::addPluginIFStructures()
GList *user_menu = ext_menubar_get_entries();
while (user_menu && user_menu->data) {
- QMenu *subMenu = NULL;
- ext_menu_t *menu = (ext_menu_t *)user_menu->data;
+ QMenu *subMenu = Q_NULLPTR;
+ ext_menu_t *menu = gxx_list_data(ext_menu_t *, user_menu);
/* On this level only menu items should exist. Not doing an assert here,
* as it could be an honest mistake */
if (menu->type != EXT_MENUBAR_MENU) {
- user_menu = g_list_next(user_menu);
+ user_menu = gxx_list_next(user_menu);
continue;
}
@@ -2797,7 +2797,7 @@ void MainWindow::addPluginIFStructures()
this->externalMenuHelper(menu, subMenu, 0);
/* Iterate Loop */
- user_menu = g_list_next(user_menu);
+ user_menu = gxx_list_next(user_menu);
}
int cntToolbars = 0;
@@ -2805,14 +2805,14 @@ void MainWindow::addPluginIFStructures()
QMenu *tbMenu = main_ui_->menuAdditionalToolbars;
GList *if_toolbars = ext_toolbar_get_entries();
while (if_toolbars && if_toolbars->data) {
- ext_toolbar_t *toolbar = (ext_toolbar_t*)if_toolbars->data;
+ ext_toolbar_t *toolbar = gxx_list_data(ext_toolbar_t*, if_toolbars);
if (toolbar->type != EXT_TOOLBAR_BAR) {
- if_toolbars = g_list_next(if_toolbars);
+ if_toolbars = gxx_list_next(if_toolbars);
continue;
}
- bool visible = g_list_find_custom(recent.gui_additional_toolbars, toolbar->name, (GCompareFunc)strcmp) ? true : false;
+ bool visible = g_list_find_custom(recent.gui_additional_toolbars, toolbar->name, reinterpret_cast<GCompareFunc>(strcmp)) ? true : false;
AdditionalToolBar *ifToolBar = AdditionalToolBar::create(this, toolbar);
@@ -2827,7 +2827,7 @@ void MainWindow::addPluginIFStructures()
iftbAction->setToolTip(tr("Show or hide the toolbar"));
iftbAction->setData(VariantPointer<ext_toolbar_t>::asQVariant(toolbar));
- QAction *before = 0;
+ QAction *before = Q_NULLPTR;
foreach(QAction *action, tbMenu->actions()) {
/* Ensure we add the menu entries in sorted order */
@@ -2848,7 +2848,7 @@ void MainWindow::addPluginIFStructures()
cntToolbars++;
}
- if_toolbars = g_list_next(if_toolbars);
+ if_toolbars = gxx_list_next(if_toolbars);
}
if (cntToolbars)
@@ -2865,7 +2865,7 @@ void MainWindow::removeAdditionalToolbar(QString toolbarName)
AdditionalToolBar *ifToolBar = dynamic_cast<AdditionalToolBar *>(tb);
if (ifToolBar && ifToolBar->menuName().compare(toolbarName)) {
- GList *entry = g_list_find_custom(recent.gui_additional_toolbars, qUtf8Printable(ifToolBar->menuName()), (GCompareFunc)strcmp);
+ GList *entry = g_list_find_custom(recent.gui_additional_toolbars, qUtf8Printable(ifToolBar->menuName()), reinterpret_cast<GCompareFunc>(strcmp));
if (entry) {
recent.gui_additional_toolbars = g_list_remove(recent.gui_additional_toolbars, entry->data);
}
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index 2dd873165c..3516730475 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -1522,7 +1522,7 @@ void MainWindow::addStatsPluginsToMenu() {
bool first_item = true;
while (iter) {
- stats_tree_cfg *cfg = (stats_tree_cfg*)iter->data;
+ stats_tree_cfg *cfg = gxx_list_data(stats_tree_cfg *, iter);
if (cfg->plugin) {
if (first_item) {
main_ui_->menuStatistics->addSeparator();
@@ -1545,7 +1545,7 @@ void MainWindow::addStatsPluginsToMenu() {
parent_menu->addAction(stats_tree_action);
connect(stats_tree_action, SIGNAL(triggered()), this, SLOT(actionStatisticsPlugin_triggered()));
}
- iter = g_list_next(iter);
+ iter = gxx_list_next(iter);
}
g_list_free(cfg_list);
}
diff --git a/ui/qt/manage_interfaces_dialog.cpp b/ui/qt/manage_interfaces_dialog.cpp
index 162f79c4cd..efbf0b13f0 100644
--- a/ui/qt/manage_interfaces_dialog.cpp
+++ b/ui/qt/manage_interfaces_dialog.cpp
@@ -336,9 +336,9 @@ void ManageInterfacesDialog::updateRemoteInterfaceList(GList* rlist, remote_opti
guint num_interfaces;
num_interfaces = global_capture_opts.all_ifaces->len;
- for (if_entry = g_list_first(rlist); if_entry != NULL; if_entry = g_list_next(if_entry)) {
+ for (if_entry = g_list_first(rlist); if_entry != NULL; if_entry = gxx_list_next(if_entry)) {
auth_str = NULL;
- if_info = (if_info_t *)if_entry->data;
+ if_info = gxx_list_data(if_info_t *, if_entry);
#if 0
add_interface_to_remote_list(if_info);
#endif
@@ -436,9 +436,9 @@ void ManageInterfacesDialog::updateRemoteInterfaceList(GList* rlist, remote_opti
device.monitor_mode_enabled = monitor_mode;
device.monitor_mode_supported = caps->can_set_rfmon;
#endif
- for (lt_entry = caps->data_link_types; lt_entry != NULL; lt_entry = g_list_next(lt_entry)) {
- data_link_info = (data_link_info_t *)lt_entry->data;
- linkr = (link_row *)g_malloc(sizeof(link_row));
+ for (lt_entry = caps->data_link_types; lt_entry != NULL; lt_entry = gxx_list_next(lt_entry)) {
+ data_link_info = gxx_list_data(data_link_info_t *, lt_entry);
+ linkr = new link_row;
/*
* For link-layer types libpcap/WinPcap doesn't know about, the
* name will be "DLT n", and the description will be null.
diff --git a/ui/qt/models/interface_tree_model.cpp b/ui/qt/models/interface_tree_model.cpp
index ad71161dc5..14e0944250 100644
--- a/ui/qt/models/interface_tree_model.cpp
+++ b/ui/qt/models/interface_tree_model.cpp
@@ -170,8 +170,8 @@ QVariant InterfaceTreeModel::data(const QModelIndex &index, int role) const
linkname = "Unknown";
else {
linkname = QObject::tr("DLT %1").arg(device->active_dlt);
- for (GList *list = device->links; list != NULL; list = g_list_next(list)) {
- link_row *linkr = (link_row*)(list->data);
+ for (GList *list = device->links; list != Q_NULLPTR; list = gxx_list_next(list)) {
+ link_row *linkr = gxx_list_data(link_row *, list);
if (linkr->dlt == device->active_dlt) {
linkname = linkr->name;
break;
diff --git a/ui/qt/models/pref_models.cpp b/ui/qt/models/pref_models.cpp
index 16065afd89..a2f07a7cbf 100644
--- a/ui/qt/models/pref_models.cpp
+++ b/ui/qt/models/pref_models.cpp
@@ -252,8 +252,8 @@ fill_prefs(module_t *module, gpointer root_ptr)
PrefsItem* module_item = new PrefsItem(module, NULL, root_item);
root_item->prependChild(module_item);
- for (GList *pref_l = module->prefs; pref_l && pref_l->data; pref_l = g_list_next(pref_l)) {
- pref_t *pref = (pref_t *) pref_l->data;
+ for (GList *pref_l = module->prefs; pref_l && pref_l->data; pref_l = gxx_list_next(pref_l)) {
+ pref_t *pref = gxx_list_data(pref_t *, pref_l);
if (prefs_get_type(pref) == PREF_OBSOLETE || prefs_get_type(pref) == PREF_STATIC_TEXT)
continue;
diff --git a/ui/qt/models/profile_model.cpp b/ui/qt/models/profile_model.cpp
index a8a6aee8d8..830484e241 100644
--- a/ui/qt/models/profile_model.cpp
+++ b/ui/qt/models/profile_model.cpp
@@ -27,8 +27,6 @@
#include <QFont>
#include <QTemporaryDir>
-#define gxx_list_next(list) ((list) ? ((reinterpret_cast<GList *>(list))->next) : Q_NULLPTR)
-
Q_LOGGING_CATEGORY(profileLogger, "wireshark.profiles")
ProfileSortModel::ProfileSortModel(QObject * parent):
diff --git a/ui/qt/models/voip_calls_info_model.cpp b/ui/qt/models/voip_calls_info_model.cpp
index 4b7642e14d..c3caebc9f3 100644
--- a/ui/qt/models/voip_calls_info_model.cpp
+++ b/ui/qt/models/voip_calls_info_model.cpp
@@ -189,9 +189,9 @@ void VoipCallsInfoModel::updateCalls(GQueue *callsinfos)
if (extra > 0) {
beginInsertRows(QModelIndex(), rowCount(), rowCount() + extra - 1);
while (cur_call && cur_call->data) {
- voip_calls_info_t *call_info = (voip_calls_info_t*) cur_call->data;
+ voip_calls_info_t *call_info = gxx_list_data(voip_calls_info_t*, cur_call);
callinfos_.push_back(call_info);
- cur_call = g_list_next(cur_call);
+ cur_call = gxx_list_next(cur_call);
}
endInsertRows();
}
diff --git a/ui/qt/multicast_statistics_dialog.cpp b/ui/qt/multicast_statistics_dialog.cpp
index 3c58740b54..c6076c3a05 100644
--- a/ui/qt/multicast_statistics_dialog.cpp
+++ b/ui/qt/multicast_statistics_dialog.cpp
@@ -281,8 +281,8 @@ void MulticastStatisticsDialog::tapDraw(mcaststream_tapinfo_t *tapinfo)
// Add missing rows and update stats
int cur_row = 0;
- for (GList *cur = g_list_first(tapinfo->strinfo_list); cur; cur = g_list_next(cur)) {
- mcast_stream_info_t *stream_info = (mcast_stream_info_t *) cur->data;
+ for (GList *cur = g_list_first(tapinfo->strinfo_list); cur; cur = gxx_list_next(cur)) {
+ mcast_stream_info_t *stream_info = gxx_list_data(mcast_stream_info_t *, cur);
if (!stream_info) continue;
MulticastStatTreeWidgetItem *ms_ti;
diff --git a/ui/qt/preferences_dialog.cpp b/ui/qt/preferences_dialog.cpp
index 789053c12a..816945903c 100644
--- a/ui/qt/preferences_dialog.cpp
+++ b/ui/qt/preferences_dialog.cpp
@@ -20,6 +20,8 @@
#include <ui/recent.h>
#include <main_window.h>
+#include <ui/qt/utils/qt_ui_utils.h>
+
#include "wireshark_application.h"
extern "C" {
@@ -28,14 +30,14 @@ extern "C" {
static guint
module_prefs_unstash(module_t *module, gpointer data)
{
- gboolean *must_redissect_p = (gboolean *)data;
+ gboolean *must_redissect_p = static_cast<gboolean *>(data);
pref_unstash_data_t unstashed_data;
unstashed_data.handle_decode_as = TRUE;
module->prefs_changed_flags = 0; /* assume none of them changed */
- for (GList *pref_l = module->prefs; pref_l && pref_l->data; pref_l = g_list_next(pref_l)) {
- pref_t *pref = (pref_t *) pref_l->data;
+ for (GList *pref_l = module->prefs; pref_l && pref_l->data; pref_l = gxx_list_next(pref_l)) {
+ pref_t *pref = gxx_list_data(pref_t *, pref_l);
if (prefs_get_type(pref) == PREF_OBSOLETE || prefs_get_type(pref) == PREF_STATIC_TEXT) continue;
@@ -57,16 +59,16 @@ module_prefs_unstash(module_t *module, gpointer data)
static guint
module_prefs_clean_stash(module_t *module, gpointer)
{
- for (GList *pref_l = module->prefs; pref_l && pref_l->data; pref_l = g_list_next(pref_l)) {
- pref_t *pref = (pref_t *) pref_l->data;
+ for (GList *pref_l = module->prefs; pref_l && pref_l->data; pref_l = gxx_list_next(pref_l)) {
+ pref_t *pref = gxx_list_data(pref_t *, pref_l);
if (prefs_get_type(pref) == PREF_OBSOLETE || prefs_get_type(pref) == PREF_STATIC_TEXT) continue;
- pref_clean_stash(pref, NULL);
+ pref_clean_stash(pref, Q_NULLPTR);
}
if(prefs_module_has_submodules(module))
- return prefs_modules_foreach_submodules(module, module_prefs_clean_stash, NULL);
+ return prefs_modules_foreach_submodules(module, module_prefs_clean_stash, Q_NULLPTR);
return 0; /* Keep cleaning modules */
}
diff --git a/ui/qt/rtp_analysis_dialog.cpp b/ui/qt/rtp_analysis_dialog.cpp
index cf06a6dbb7..935e50fb43 100644
--- a/ui/qt/rtp_analysis_dialog.cpp
+++ b/ui/qt/rtp_analysis_dialog.cpp
@@ -1609,10 +1609,10 @@ void RtpAnalysisDialog::findStreams()
// register_tap_listener_rtpstream(&tapinfo_, NULL);
/* Scan for RTP streams (redissect all packets) */
- rtpstream_scan(&tapinfo_, cap_file_.capFile(), NULL);
+ rtpstream_scan(&tapinfo_, cap_file_.capFile(), Q_NULLPTR);
- for (GList *strinfo_list = g_list_first(tapinfo_.strinfo_list); strinfo_list; strinfo_list = g_list_next(strinfo_list)) {
- rtpstream_info_t * strinfo = (rtpstream_info_t*)(strinfo_list->data);
+ for (GList *strinfo_list = g_list_first(tapinfo_.strinfo_list); strinfo_list; strinfo_list = gxx_list_next(strinfo_list)) {
+ rtpstream_info_t * strinfo = gxx_list_data(rtpstream_info_t*, strinfo_list);
if (rtpstream_id_equal(&(strinfo->id), &(fwd_statinfo_.id),RTPSTREAM_ID_EQUAL_NONE))
{
fwd_statinfo_.packet_count = strinfo->packet_count;
diff --git a/ui/qt/rtp_stream_dialog.cpp b/ui/qt/rtp_stream_dialog.cpp
index 519509358c..82df5debdd 100644
--- a/ui/qt/rtp_stream_dialog.cpp
+++ b/ui/qt/rtp_stream_dialog.cpp
@@ -329,13 +329,13 @@ void RtpStreamDialog::tapMarkPacket(rtpstream_tapinfo_t *tapinfo, frame_data *fd
void RtpStreamDialog::updateStreams()
{
- GList *cur_stream = g_list_nth(tapinfo_.strinfo_list, ui->streamTreeWidget->topLevelItemCount());
+ GList *cur_stream = g_list_nth(tapinfo_.strinfo_list, static_cast<guint>(ui->streamTreeWidget->topLevelItemCount()));
// Add any missing items
while (cur_stream && cur_stream->data) {
- rtpstream_info_t *stream_info = (rtpstream_info_t*) cur_stream->data;
+ rtpstream_info_t *stream_info = gxx_list_data(rtpstream_info_t*, cur_stream);
new RtpStreamTreeWidgetItem(ui->streamTreeWidget, stream_info);
- cur_stream = g_list_next(cur_stream);
+ cur_stream = gxx_list_next(cur_stream);
}
// Recalculate values
diff --git a/ui/qt/sctp_all_assocs_dialog.cpp b/ui/qt/sctp_all_assocs_dialog.cpp
index 1fff6824e8..b7b10a8a65 100644
--- a/ui/qt/sctp_all_assocs_dialog.cpp
+++ b/ui/qt/sctp_all_assocs_dialog.cpp
@@ -61,19 +61,19 @@ void SCTPAllAssocsDialog::fillTable()
cf_retap_packets(cap_file_);
}
numAssocs = 0;
- ui->assocList->setRowCount(g_list_length(sctp_assocs->assoc_info_list));
+ ui->assocList->setRowCount(static_cast<int>(g_list_length(sctp_assocs->assoc_info_list)));
list = g_list_first(sctp_assocs->assoc_info_list);
while (list) {
- assinfo = (const sctp_assoc_info_t*)(list->data);
+ assinfo = gxx_list_data(const sctp_assoc_info_t*, list);
ui->assocList->setItem(numAssocs, 0, new QTableWidgetItem(QString("%1").arg(assinfo->assoc_id)));
ui->assocList->setItem(numAssocs, 1, new QTableWidgetItem(QString("%1").arg(assinfo->port1)));
ui->assocList->setItem(numAssocs, 2, new QTableWidgetItem(QString("%1").arg(assinfo->port2)));
ui->assocList->setItem(numAssocs, 3, new QTableWidgetItem(QString("%1").arg(assinfo->n_packets)));
ui->assocList->setItem(numAssocs, 4, new QTableWidgetItem(QString("%1").arg(assinfo->n_data_chunks)));
ui->assocList->setItem(numAssocs, 5, new QTableWidgetItem(QString("%1").arg(assinfo->n_data_bytes)));
- list = g_list_next(list);
+ list = gxx_list_next(list);
numAssocs++;
}
ui->analyseButton->setEnabled(false);
diff --git a/ui/qt/sctp_assoc_analyse_dialog.cpp b/ui/qt/sctp_assoc_analyse_dialog.cpp
index 9d401a0961..4886c4e30e 100644
--- a/ui/qt/sctp_assoc_analyse_dialog.cpp
+++ b/ui/qt/sctp_assoc_analyse_dialog.cpp
@@ -60,7 +60,7 @@ const sctp_assoc_info_t* SCTPAssocAnalyseDialog::findAssocForPacket(capture_file
list = g_list_first(sctp_stat_get_info()->assoc_info_list);
while (list) {
- assoc = (const sctp_assoc_info_t*)(list->data);
+ assoc = gxx_list_data(const sctp_assoc_info_t*, list);
framelist = g_list_first(assoc->frame_numbers);
guint32 fn;
@@ -70,12 +70,12 @@ const sctp_assoc_info_t* SCTPAssocAnalyseDialog::findAssocForPacket(capture_file
frame_found = TRUE;
break;
}
- framelist = g_list_next(framelist);
+ framelist = gxx_list_next(framelist);
}
if (frame_found) {
return assoc;
} else {
- list = g_list_next(list);
+ list = gxx_list_next(list);
}
}
@@ -84,7 +84,7 @@ const sctp_assoc_info_t* SCTPAssocAnalyseDialog::findAssocForPacket(capture_file
msgBox.setText(tr("No Association found for this packet."));
msgBox.exec();
}
- return NULL;
+ return Q_NULLPTR;
}
const _sctp_assoc_info* SCTPAssocAnalyseDialog::findAssoc(QWidget *parent, guint16 assoc_id)
@@ -118,20 +118,20 @@ void SCTPAssocAnalyseDialog::fillTabs(const sctp_assoc_info_t* selected_assoc)
else
ui->labelEP1->setText(QString(tr("List of used IP-Addresses")));
- if (selected_assoc->addr1 != NULL) {
+ if (selected_assoc->addr1 != Q_NULLPTR) {
GList *list;
list = g_list_first(selected_assoc->addr1);
while (list) {
address *store;
- store = (address *)(list->data);
+ store = gxx_list_data(address *, list);
if (store->type != AT_NONE) {
if ((store->type == AT_IPv4) || (store->type == AT_IPv6)) {
ui->listWidgetEP1->addItem(address_to_qstring(store));
}
}
- list = g_list_next(list);
+ list = gxx_list_next(list);
}
} else {
return;
@@ -170,20 +170,20 @@ void SCTPAssocAnalyseDialog::fillTabs(const sctp_assoc_info_t* selected_assoc)
else
ui->labelEP2->setText(QString(tr("List of used IP-Addresses")));
- if (selected_assoc->addr2 != NULL) {
+ if (selected_assoc->addr2 != Q_NULLPTR) {
GList *list;
list = g_list_first(selected_assoc->addr2);
while (list) {
address *store;
- store = (address *)(list->data);
+ store = gxx_list_data(address *, list);
if (store->type != AT_NONE) {
if ((store->type == AT_IPv4) || (store->type == AT_IPv6)) {
ui->listWidgetEP2->addItem(address_to_qstring(store));
}
}
- list = g_list_next(list);
+ list = gxx_list_next(list);
}
} else {
return;
diff --git a/ui/qt/sctp_graph_arwnd_dialog.cpp b/ui/qt/sctp_graph_arwnd_dialog.cpp
index a1de32e669..304e3db259 100644
--- a/ui/qt/sctp_graph_arwnd_dialog.cpp
+++ b/ui/qt/sctp_graph_arwnd_dialog.cpp
@@ -59,7 +59,7 @@ SCTPGraphArwndDialog::~SCTPGraphArwndDialog()
void SCTPGraphArwndDialog::drawArwndGraph(const sctp_assoc_info_t *selected_assoc)
{
- GList *listSACK = NULL, *tlist;
+ GList *listSACK = Q_NULLPTR, *tlist;
struct sack_chunk_header *sack_header;
struct nr_sack_chunk_header *nr_sack_header;
tsn_t *tsn;
@@ -76,15 +76,15 @@ void SCTPGraphArwndDialog::drawArwndGraph(const sctp_assoc_info_t *selected_asso
bool detect_max_arwnd = (startArwnd == 0) ? true : false;
while (listSACK) {
- tsn = (tsn_t*) (listSACK->data);
+ tsn = gxx_list_data(tsn_t*, listSACK);
tlist = g_list_first(tsn->tsns);
while (tlist) {
- type = ((struct chunk_header *)tlist->data)->type;
+ type = gxx_list_data(struct chunk_header *, tlist)->type;
if (type == SCTP_SACK_CHUNK_ID) {
- sack_header =(struct sack_chunk_header *)tlist->data;
+ sack_header = gxx_list_data(struct sack_chunk_header *, tlist);
arwnd = g_ntohl(sack_header->a_rwnd);
} else if (type == SCTP_NR_SACK_CHUNK_ID) {
- nr_sack_header =(struct nr_sack_chunk_header *)tlist->data;
+ nr_sack_header = gxx_list_data(struct nr_sack_chunk_header *, tlist);
arwnd = g_ntohl(nr_sack_header->a_rwnd);
}
if (detect_max_arwnd && startArwnd < arwnd) {
@@ -93,9 +93,9 @@ void SCTPGraphArwndDialog::drawArwndGraph(const sctp_assoc_info_t *selected_asso
ya.append(arwnd);
xa.append(tsn->secs + tsn->usecs/1000000.0);
fa.append(tsn->frame_number);
- tlist = g_list_next(tlist);
+ tlist = gxx_list_next(tlist);
}
- listSACK = g_list_previous(listSACK);
+ listSACK = gxx_list_previous(listSACK);
}
QCPScatterStyle myScatter;
diff --git a/ui/qt/sctp_graph_byte_dialog.cpp b/ui/qt/sctp_graph_byte_dialog.cpp
index 7bc6b3749d..eb02cbd741 100644
--- a/ui/qt/sctp_graph_byte_dialog.cpp
+++ b/ui/qt/sctp_graph_byte_dialog.cpp
@@ -59,8 +59,8 @@ SCTPGraphByteDialog::~SCTPGraphByteDialog()
void SCTPGraphByteDialog::drawBytesGraph(const sctp_assoc_info_t *selected_assoc)
{
- GList *listTSN = NULL,*tlist;
- tsn_t *tsn;
+ GList *listTSN = Q_NULLPTR, *tlist = Q_NULLPTR;
+ tsn_t *tsn = Q_NULLPTR;
guint8 type;
guint32 maxBytes;
guint64 sumBytes = 0;
@@ -75,14 +75,14 @@ void SCTPGraphByteDialog::drawBytesGraph(const sctp_assoc_info_t *selected_assoc
while (listTSN) {
- tsn = (tsn_t*) (listTSN->data);
+ tsn = gxx_list_data(tsn_t*, listTSN);
tlist = g_list_first(tsn->tsns);
guint16 length;
while (tlist)
{
- type = ((struct chunk_header *)tlist->data)->type;
+ type = gxx_list_data(struct chunk_header *, tlist)->type;
if (type == SCTP_DATA_CHUNK_ID || type == SCTP_I_DATA_CHUNK_ID) {
- length = g_ntohs(((struct data_chunk_header *)tlist->data)->length);
+ length = g_ntohs(gxx_list_data(struct data_chunk_header *, tlist)->length);
if (type == SCTP_DATA_CHUNK_ID)
length -= DATA_CHUNK_HEADER_LENGTH;
else
@@ -92,9 +92,9 @@ void SCTPGraphByteDialog::drawBytesGraph(const sctp_assoc_info_t *selected_assoc
xb.append(tsn->secs + tsn->usecs/1000000.0);
fb.append(tsn->frame_number);
}
- tlist = g_list_next(tlist);
+ tlist = gxx_list_next(tlist);
}
- listTSN = g_list_previous(listTSN);
+ listTSN = gxx_list_previous(listTSN);
}
diff --git a/ui/qt/sctp_graph_dialog.cpp b/ui/qt/sctp_graph_dialog.cpp
index 03201e6923..e1a1ab6069 100644
--- a/ui/qt/sctp_graph_dialog.cpp
+++ b/ui/qt/sctp_graph_dialog.cpp
@@ -65,13 +65,13 @@ SCTPGraphDialog::~SCTPGraphDialog()
void SCTPGraphDialog::drawNRSACKGraph(const sctp_assoc_info_t* selected_assoc)
{
- tsn_t *sack;
- GList *list=NULL, *tlist;
+ tsn_t *sack = Q_NULLPTR;
+ GList *list = Q_NULLPTR, *tlist = Q_NULLPTR;
guint16 gap_start=0, gap_end=0, i, numberOf_gaps, numberOf_nr_gaps;
guint8 type;
guint32 tsnumber, j = 0, min_tsn, rel = 0;
- struct nr_sack_chunk_header *nr_sack_header;
- struct gaps *nr_gap;
+ struct nr_sack_chunk_header *nr_sack_header = Q_NULLPTR;
+ struct gaps *nr_gap = Q_NULLPTR;
/* This holds the sum of gap acks and nr gap acks */
guint16 total_gaps = 0;
@@ -86,12 +86,12 @@ void SCTPGraphDialog::drawNRSACKGraph(const sctp_assoc_info_t* selected_assoc)
rel = min_tsn;
}
while (list) {
- sack = (tsn_t*) (list->data);
+ sack = gxx_list_data(tsn_t*, list);
tlist = g_list_first(sack->tsns);
while (tlist) {
- type = ((struct chunk_header *)tlist->data)->type;
+ type = gxx_list_data(struct chunk_header *, tlist)->type;
if (type == SCTP_NR_SACK_CHUNK_ID) {
- nr_sack_header =(struct nr_sack_chunk_header *)tlist->data;
+ nr_sack_header = gxx_list_data(struct nr_sack_chunk_header *, tlist);
numberOf_nr_gaps=g_ntohs(nr_sack_header->nr_of_nr_gaps);
numberOf_gaps=g_ntohs(nr_sack_header->nr_of_gaps);
tsnumber = g_ntohl(nr_sack_header->cum_tsn_ack);
@@ -124,23 +124,23 @@ void SCTPGraphDialog::drawNRSACKGraph(const sctp_assoc_info_t* selected_assoc)
}
}
}
- tlist = g_list_next(tlist);
+ tlist = gxx_list_next(tlist);
}
- list = g_list_previous(list);
+ list = gxx_list_previous(list);
}
}
void SCTPGraphDialog::drawSACKGraph(const sctp_assoc_info_t* selected_assoc)
{
- GList *listSACK = NULL, *tlist;
+ GList *listSACK = Q_NULLPTR, *tlist = Q_NULLPTR;
guint16 gap_start=0, gap_end=0, nr, dup_nr;
- struct sack_chunk_header *sack_header;
- struct gaps *gap;
- tsn_t *tsn;
+ struct sack_chunk_header *sack_header = Q_NULLPTR;
+ struct gaps *gap = Q_NULLPTR;
+ tsn_t *tsn = Q_NULLPTR;
guint8 type;
guint32 tsnumber=0, rel = 0;
guint32 minTSN;
- guint32 *dup_list;
+ guint32 *dup_list = Q_NULLPTR;
int i, j;
if (direction == 1) {
@@ -154,12 +154,12 @@ void SCTPGraphDialog::drawSACKGraph(const sctp_assoc_info_t* selected_assoc)
rel = minTSN;
}
while (listSACK) {
- tsn = (tsn_t*) (listSACK->data);
+ tsn = gxx_list_data(tsn_t*, listSACK);
tlist = g_list_first(tsn->tsns);
while (tlist) {
- type = ((struct chunk_header *)tlist->data)->type;
+ type = gxx_list_data(struct chunk_header *, tlist)->type;
if (type == SCTP_SACK_CHUNK_ID) {
- sack_header =(struct sack_chunk_header *)tlist->data;
+ sack_header = gxx_list_data(struct sack_chunk_header *, tlist);
nr=g_ntohs(sack_header->nr_of_gaps);
tsnumber = g_ntohl(sack_header->cum_tsn_ack);
dup_nr=g_ntohs(sack_header->nr_of_dups);
@@ -194,9 +194,9 @@ void SCTPGraphDialog::drawSACKGraph(const sctp_assoc_info_t* selected_assoc)
}
}
}
- tlist = g_list_next(tlist);
+ tlist = gxx_list_next(tlist);
}
- listSACK = g_list_previous(listSACK);
+ listSACK = gxx_list_previous(listSACK);
}
QCPScatterStyle myScatter;
@@ -260,8 +260,8 @@ void SCTPGraphDialog::drawSACKGraph(const sctp_assoc_info_t* selected_assoc)
void SCTPGraphDialog::drawTSNGraph(const sctp_assoc_info_t* selected_assoc)
{
- GList *listTSN = NULL,*tlist;
- tsn_t *tsn;
+ GList *listTSN = Q_NULLPTR,*tlist = Q_NULLPTR;
+ tsn_t *tsn = Q_NULLPTR;
guint8 type;
guint32 tsnumber=0, rel = 0, minTSN;
@@ -278,20 +278,20 @@ void SCTPGraphDialog::drawTSNGraph(const sctp_assoc_info_t* selected_assoc)
}
while (listTSN) {
- tsn = (tsn_t*) (listTSN->data);
+ tsn = gxx_list_data(tsn_t*, listTSN);
tlist = g_list_first(tsn->tsns);
while (tlist)
{
- type = ((struct chunk_header *)tlist->data)->type;
+ type = gxx_list_data(struct chunk_header *, tlist)->type;
if (type == SCTP_DATA_CHUNK_ID || type == SCTP_I_DATA_CHUNK_ID || type == SCTP_FORWARD_TSN_CHUNK_ID) {
- tsnumber = g_ntohl(((struct data_chunk_header *)tlist->data)->tsn);
+ tsnumber = g_ntohl(gxx_list_data(struct data_chunk_header *, tlist)->tsn);
yt.append(tsnumber - rel);
xt.append(tsn->secs + tsn->usecs/1000000.0);
ft.append(tsn->frame_number);
}
- tlist = g_list_next(tlist);
+ tlist = gxx_list_next(tlist);
}
- listTSN = g_list_previous(listTSN);
+ listTSN = gxx_list_previous(listTSN);
}
QCPScatterStyle myScatter;
diff --git a/ui/qt/sequence_diagram.cpp b/ui/qt/sequence_diagram.cpp
index 690b725305..3be2843dc2 100644
--- a/ui/qt/sequence_diagram.cpp
+++ b/ui/qt/sequence_diagram.cpp
@@ -150,8 +150,8 @@ void SequenceDiagram::setData(_seq_analysis_info *sainfo)
int elide_w = com_fm.height() * max_comment_em_width_;
char* addr_str;
- for (GList *cur = g_queue_peek_nth_link(sainfo->items, 0); cur; cur = g_list_next(cur)) {
- seq_analysis_item_t *sai = (seq_analysis_item_t *) cur->data;
+ for (GList *cur = g_queue_peek_nth_link(sainfo->items, 0); cur; cur = gxx_list_next(cur)) {
+ seq_analysis_item_t *sai = gxx_list_data(seq_analysis_item_t *, cur);
if (sai->display) {
WSCPSeqData new_data;
@@ -170,13 +170,13 @@ void SequenceDiagram::setData(_seq_analysis_info *sainfo)
for (unsigned int i = 0; i < sainfo_->num_nodes; i++) {
val_ticks.append(i);
- addr_str = address_to_display(NULL, &(sainfo_->nodes[i]));
+ addr_str = address_to_display(Q_NULLPTR, &(sainfo_->nodes[i]));
val_labels.append(addr_str);
if (i % 2 == 0) {
val_labels.last().append("\n");
}
- wmem_free(NULL, addr_str);
+ wmem_free(Q_NULLPTR, addr_str);
}
keyAxis()->setTickVector(key_ticks);
keyAxis()->setTickVectorLabels(key_labels);
diff --git a/ui/qt/utils/qt_ui_utils.h b/ui/qt/utils/qt_ui_utils.h
index 23b63a0926..23cc547b3c 100644
--- a/ui/qt/utils/qt_ui_utils.h
+++ b/ui/qt/utils/qt_ui_utils.h
@@ -47,6 +47,16 @@ struct epan_range;
#define qUtf8Printable(str) str.toUtf8().constData()
#endif
+/*
+ * Helper macro, to prevent old-style-cast warnings, when using GList in c++ code
+ */
+#define gxx_list_next(list) ((list) ? ((reinterpret_cast<GList *>(list))->next) : Q_NULLPTR)
+#define gxx_constlist_next(list) ((list) ? ((reinterpret_cast<const GList *>(list))->next) : Q_NULLPTR)
+#define gxx_list_previous(list) ((list) ? ((reinterpret_cast<GList *>(list))->prev) : Q_NULLPTR)
+#define gxx_constlist_previous(list) ((list) ? ((reinterpret_cast<const GList *>(list))->prev) : Q_NULLPTR)
+
+#define gxx_list_data(type, list) ((list) ? ((reinterpret_cast<type>(list->data))) : Q_NULLPTR)
+
/** Create a glib-compatible copy of a QString.
*
* @param q_string A QString.
diff --git a/ui/qt/voip_calls_dialog.cpp b/ui/qt/voip_calls_dialog.cpp
index 4da971d24f..71cc128581 100644
--- a/ui/qt/voip_calls_dialog.cpp
+++ b/ui/qt/voip_calls_dialog.cpp
@@ -183,17 +183,17 @@ tap_packet_status VoipCallsDialog::tapPacket(void *, packet_info *, epan_dissect
void VoipCallsDialog::tapDraw(void *tapinfo_ptr)
{
- voip_calls_tapinfo_t *tapinfo = (voip_calls_tapinfo_t *) tapinfo_ptr;
+ voip_calls_tapinfo_t *tapinfo = static_cast<voip_calls_tapinfo_t *>(tapinfo_ptr);
if (!tapinfo || !tapinfo->redraw) {
return;
}
GList *graph_item = g_queue_peek_nth_link(tapinfo->graph_analysis->items, 0);
- for (; graph_item; graph_item = g_list_next(graph_item)) {
- for (GList *rsi_entry = g_list_first(tapinfo->rtpstream_list); rsi_entry; rsi_entry = g_list_next(rsi_entry)) {
- seq_analysis_item_t * sai = (seq_analysis_item_t *)graph_item->data;
- rtpstream_info_t *rsi = (rtpstream_info_t *)rsi_entry->data;
+ for (; graph_item; graph_item = gxx_list_next(graph_item)) {
+ for (GList *rsi_entry = g_list_first(tapinfo->rtpstream_list); rsi_entry; rsi_entry = gxx_list_next(rsi_entry)) {
+ seq_analysis_item_t * sai = gxx_list_data(seq_analysis_item_t *, graph_item);
+ rtpstream_info_t *rsi = gxx_list_data(rtpstream_info_t *, rsi_entry);
if (rsi->start_fd->num == sai->frame_number) {
rsi->call_num = sai->conv_num;
@@ -265,11 +265,11 @@ void VoipCallsDialog::prepareFilter()
GList *cur_ga_item = g_queue_peek_nth_link(tapinfo_.graph_analysis->items, 0);
while (cur_ga_item && cur_ga_item->data) {
- seq_analysis_item_t *ga_item = (seq_analysis_item_t*) cur_ga_item->data;
+ seq_analysis_item_t *ga_item = gxx_list_data(seq_analysis_item_t*, cur_ga_item);
if (selected_calls.contains(ga_item->conv_num)) {
frame_numbers += QString("%1 ").arg(ga_item->frame_number);
}
- cur_ga_item = g_list_next(cur_ga_item);
+ cur_ga_item = gxx_list_next(cur_ga_item);
}
if (!frame_numbers.isEmpty()) {
@@ -299,7 +299,7 @@ void VoipCallsDialog::prepareFilter()
/* Build a new filter based on protocol fields */
lista = g_queue_peek_nth_link(voip_calls_get_info()->callsinfos, 0);
while (lista) {
- listinfo = (voip_calls_info_t *)lista->data;
+ listinfo = gxx_list_data(voip_calls_info_t *, lista);
if (listinfo->selected) {
if (!is_first)
g_string_append_printf(filter_string_fwd, " or ");
@@ -335,11 +335,11 @@ void VoipCallsDialog::prepareFilter()
listb = g_list_first(h323info->h245_list);
wmem_free(NULL, guid_str);
while (listb) {
- h245_add = (h245_address_t *)listb->data;
+ h245_add = gxx_list_data(h245_address_t *, listb);
g_string_append_printf(filter_string_fwd,
" || (ip.addr == %s && tcp.port == %d && h245)",
address_to_qstring(&h245_add->h245_address), h245_add->h245_port);
- listb = g_list_next(listb);
+ listb = gxx_list_next(listb);
}
g_string_append_printf(filter_string_fwd, ")");
}
@@ -357,7 +357,7 @@ void VoipCallsDialog::prepareFilter()
}
is_first = FALSE;
}
- lista = g_list_next(lista);
+ lista = gxx_list_next(lista);
}
g_string_append_printf(filter_string_fwd, ")");
@@ -384,9 +384,9 @@ void VoipCallsDialog::showSequence()
sequence_analysis_list_sort(tapinfo_.graph_analysis);
GList *cur_ga_item = g_queue_peek_nth_link(tapinfo_.graph_analysis->items, 0);
while (cur_ga_item && cur_ga_item->data) {
- seq_analysis_item_t *ga_item = (seq_analysis_item_t*) cur_ga_item->data;
+ seq_analysis_item_t *ga_item = gxx_list_data(seq_analysis_item_t*, cur_ga_item);
ga_item->display = selected_calls.contains(ga_item->conv_num);
- cur_ga_item = g_list_next(cur_ga_item);
+ cur_ga_item = gxx_list_next(cur_ga_item);
}
SequenceDialog *sequence_dialog = new SequenceDialog(parent_, cap_file_, sequence_info_);
@@ -402,14 +402,14 @@ void VoipCallsDialog::showPlayer()
voip_calls_info_t *vci = VoipCallsInfoModel::indexToCallInfo(index);
if (!vci) continue;
- for (GList *rsi_entry = g_list_first(tapinfo_.rtpstream_list); rsi_entry; rsi_entry = g_list_next(rsi_entry)) {
- rtpstream_info_t *rsi = (rtpstream_info_t *)rsi_entry->data;
+ for (GList *rsi_entry = g_list_first(tapinfo_.rtpstream_list); rsi_entry; rsi_entry = gxx_list_next(rsi_entry)) {
+ rtpstream_info_t *rsi = gxx_list_data(rtpstream_info_t *, rsi_entry);
if (!rsi) continue;
//VOIP_CALLS_DEBUG("checking call %u, start frame %u == stream call %u, start frame %u, setup frame %u",
// vci->call_num, vci->start_fd->num,
// rsi->call_num, rsi->start_fd->num, rsi->setup_frame_number);
- if (vci->call_num == (guint)rsi->call_num) {
+ if (vci->call_num == static_cast<guint>(rsi->call_num)) {
//VOIP_CALLS_DEBUG("adding call number %u", vci->call_num);
rtp_player_dialog.addRtpStream(rsi);
}
diff --git a/ui/qt/widgets/additional_toolbar.cpp b/ui/qt/widgets/additional_toolbar.cpp
index 1c15598b01..b0565d2f42 100644
--- a/ui/qt/widgets/additional_toolbar.cpp
+++ b/ui/qt/widgets/additional_toolbar.cpp
@@ -54,7 +54,7 @@ AdditionalToolBar * AdditionalToolBar::create(QWidget * parent, ext_toolbar_t *
while ( walker && walker->data )
{
- ext_toolbar_t * item = (ext_toolbar_t *)walker->data;
+ ext_toolbar_t * item = gxx_list_data(ext_toolbar_t *, walker);
if ( item->type == EXT_TOOLBAR_ITEM )
{
if ( item->item_type == EXT_TOOLBAR_STRING )
@@ -69,11 +69,11 @@ AdditionalToolBar * AdditionalToolBar::create(QWidget * parent, ext_toolbar_t *
}
}
- walker = g_list_next ( walker );
+ walker = gxx_list_next ( walker );
}
if ( result->children().count() == 0 )
- return NULL;
+ return Q_NULLPTR;
if ( spacerNeeded )
{
@@ -369,13 +369,13 @@ toolbar_selector_cb(gpointer item, gpointer item_data, gpointer user_data)
while ( walker && walker->data )
{
- ext_toolbar_value_t * listvalue = (ext_toolbar_value_t *)walker->data;
+ ext_toolbar_value_t * listvalue = gxx_list_data(ext_toolbar_value_t *, walker);
QStandardItem * si = new QStandardItem(listvalue->display);
si->setData(VariantPointer<ext_toolbar_value_t>::asQVariant(listvalue), Qt::UserRole);
sourceModel->appendRow(si);
- walker = g_list_next(walker);
+ walker = gxx_list_next(walker);
}
}
else if ( update_entry->type == EXT_TOOLBAR_UPDATE_DATABYINDEX ||
@@ -454,7 +454,7 @@ QWidget * AdditionalToolbarWidgetAction::createSelector(ext_toolbar_t * item, QW
int selIndex = 0;
while ( walker && walker->data )
{
- ext_toolbar_value_t * listvalue = (ext_toolbar_value_t *)walker->data;
+ ext_toolbar_value_t * listvalue = gxx_list_data(ext_toolbar_value_t *, walker);
QStandardItem * si = new QStandardItem(listvalue->display);
si->setData(VariantPointer<ext_toolbar_value_t>::asQVariant(listvalue), Qt::UserRole);
@@ -463,7 +463,7 @@ QWidget * AdditionalToolbarWidgetAction::createSelector(ext_toolbar_t * item, QW
if ( listvalue->is_default )
selIndex = sourceModel->rowCount();
- walker = g_list_next(walker);
+ walker = gxx_list_next(walker);
}
myBox->setModel(sourceModel);
diff --git a/ui/qt/widgets/capture_filter_combo.cpp b/ui/qt/widgets/capture_filter_combo.cpp
index 7ed5389656..7e8c20a43e 100644
--- a/ui/qt/widgets/capture_filter_combo.cpp
+++ b/ui/qt/widgets/capture_filter_combo.cpp
@@ -128,8 +128,8 @@ void CaptureFilterCombo::rebuildFilterList()
GList *cfilter_list = recent_get_cfilter_list(NULL);
QString cur_filter = currentText();
clear();
- for (GList *li = g_list_first(cfilter_list); li != NULL; li = g_list_next(li)) {
- insertItem(0, (const gchar *) li->data);
+ for (GList *li = g_list_first(cfilter_list); li != NULL; li = gxx_list_next(li)) {
+ insertItem(0, gxx_list_data(const gchar *, li));
}
lineEdit()->setText(cur_filter);
lineEdit()->blockSignals(false);
diff --git a/ui/qt/widgets/capture_filter_edit.cpp b/ui/qt/widgets/capture_filter_edit.cpp
index a00edbd80d..7156e7acd9 100644
--- a/ui/qt/widgets/capture_filter_edit.cpp
+++ b/ui/qt/widgets/capture_filter_edit.cpp
@@ -325,9 +325,9 @@ void CaptureFilterEdit::checkFilter(const QString& filter)
if (bookmark_button_) {
bool match = false;
- for (GList *cf_item = get_filter_list_first(CFILTER_LIST); cf_item; cf_item = g_list_next(cf_item)) {
+ for (GList *cf_item = get_filter_list_first(CFILTER_LIST); cf_item; cf_item = gxx_list_next(cf_item)) {
if (!cf_item->data) continue;
- filter_def *cf_def = (filter_def *) cf_item->data;
+ filter_def *cf_def = gxx_list_data(filter_def *, cf_item);
if (!cf_def->name || !cf_def->strval) continue;
if (filter.compare(cf_def->strval) == 0) {
@@ -390,9 +390,9 @@ void CaptureFilterEdit::updateBookmarkMenu()
connect(manage_action, &QAction::triggered, this, &CaptureFilterEdit::showFilters);
bb_menu->addSeparator();
- for (GList *cf_item = get_filter_list_first(CFILTER_LIST); cf_item; cf_item = g_list_next(cf_item)) {
+ for (GList *cf_item = get_filter_list_first(CFILTER_LIST); cf_item; cf_item = gxx_list_next(cf_item)) {
if (!cf_item->data) continue;
- filter_def *cf_def = (filter_def *) cf_item->data;
+ filter_def *cf_def = gxx_list_data(filter_def *, cf_item);
if (!cf_def->name || !cf_def->strval) continue;
int one_em = bb_menu->fontMetrics().height();
@@ -463,8 +463,8 @@ void CaptureFilterEdit::buildCompletionList(const QString &primitive_word)
}
}
}
- for (const GList *cf_item = get_filter_list_first(CFILTER_LIST); cf_item; cf_item = g_list_next(cf_item)) {
- const filter_def *cf_def = (filter_def *) cf_item->data;
+ for (const GList *cf_item = get_filter_list_first(CFILTER_LIST); cf_item; cf_item = gxx_constlist_next(cf_item)) {
+ const filter_def *cf_def = gxx_list_data(const filter_def *, cf_item);
if (!cf_def || !cf_def->strval) continue;
QString saved_filter = cf_def->strval;
@@ -504,9 +504,9 @@ void CaptureFilterEdit::removeFilter()
QString remove_filter = ra->data().toString();
- for (GList *cf_item = get_filter_list_first(CFILTER_LIST); cf_item; cf_item = g_list_next(cf_item)) {
+ for (GList *cf_item = get_filter_list_first(CFILTER_LIST); cf_item; cf_item = gxx_list_next(cf_item)) {
if (!cf_item->data) continue;
- filter_def *cf_def = (filter_def *) cf_item->data;
+ filter_def *cf_def = gxx_list_data(filter_def *, cf_item);
if (!cf_def->name || !cf_def->strval) continue;
if (remove_filter.compare(cf_def->strval) == 0) {
diff --git a/ui/qt/widgets/display_filter_edit.cpp b/ui/qt/widgets/display_filter_edit.cpp
index 6308305597..238b7c4ad1 100644
--- a/ui/qt/widgets/display_filter_edit.cpp
+++ b/ui/qt/widgets/display_filter_edit.cpp
@@ -22,6 +22,7 @@
#include <ui/qt/widgets/stock_icon_tool_button.h>
#include <ui/qt/widgets/syntax_line_edit.h>
#include <ui/qt/utils/wireshark_mime_data.h>
+#include <ui/qt/utils/qt_ui_utils.h>
#include <ui/qt/models/pref_models.h>
#include <ui/qt/filter_action.h>
#include "wireshark_application.h"
@@ -281,9 +282,9 @@ void DisplayFilterEdit::checkFilter(const QString& filter_text)
bool enable_save_action = false;
bool match = false;
- for (GList *df_item = get_filter_list_first(DFILTER_LIST); df_item; df_item = g_list_next(df_item)) {
+ for (GList *df_item = get_filter_list_first(DFILTER_LIST); df_item; df_item = gxx_list_next(df_item)) {
if (!df_item->data) continue;
- filter_def *df_def = (filter_def *) df_item->data;
+ filter_def *df_def = gxx_list_data(filter_def *, df_item);
if (!df_def->name || !df_def->strval) continue;
if (filter_text.compare(df_def->strval) == 0) {
@@ -334,9 +335,9 @@ void DisplayFilterEdit::updateBookmarkMenu()
connect(expr_action, &QAction::triggered, this, &DisplayFilterEdit::showExpressionPrefs);
bb_menu->addSeparator();
- for (GList *df_item = get_filter_list_first(DFILTER_LIST); df_item; df_item = g_list_next(df_item)) {
+ for (GList *df_item = get_filter_list_first(DFILTER_LIST); df_item; df_item = gxx_list_next(df_item)) {
if (!df_item->data) continue;
- filter_def *df_def = (filter_def *) df_item->data;
+ filter_def *df_def = gxx_list_data(filter_def *, df_item);
if (!df_def->name || !df_def->strval) continue;
int one_em = bb_menu->fontMetrics().height();
@@ -397,8 +398,8 @@ void DisplayFilterEdit::buildCompletionList(const QString &field_word)
}
}
}
- for (const GList *df_item = get_filter_list_first(DFILTER_LIST); df_item; df_item = g_list_next(df_item)) {
- const filter_def *df_def = (filter_def *) df_item->data;
+ for (const GList *df_item = get_filter_list_first(DFILTER_LIST); df_item; df_item = gxx_constlist_next(df_item)) {
+ const filter_def *df_def = gxx_list_data(const filter_def *, df_item);
if (!df_def || !df_def->strval) continue;
QString saved_filter = df_def->strval;
@@ -492,9 +493,9 @@ void DisplayFilterEdit::removeFilter()
QString remove_filter = ra->data().toString();
- for (GList *df_item = get_filter_list_first(DFILTER_LIST); df_item; df_item = g_list_next(df_item)) {
+ for (GList *df_item = get_filter_list_first(DFILTER_LIST); df_item; df_item = gxx_list_next(df_item)) {
if (!df_item->data) continue;
- filter_def *df_def = (filter_def *) df_item->data;
+ filter_def *df_def = gxx_list_data(filter_def *, df_item);
if (!df_def->name || !df_def->strval) continue;
if (remove_filter.compare(df_def->strval) == 0) {