Qt: Fix various compiler warnings.

Fix const-qual and missing-prototypes warnings found by Clang.
This commit is contained in:
Gerald Combs 2021-04-19 12:02:31 -07:00 committed by Wireshark GitLab Utility
parent 26c5635973
commit cd81255da2
10 changed files with 23 additions and 15 deletions

View File

@ -92,7 +92,7 @@ void CredentialsDialog::tapReset(void *tapdata)
tap_packet_status CredentialsDialog::tapPacket(void *tapdata, _packet_info *, epan_dissect *, const void *data)
{
CredentialsDialog * d = (CredentialsDialog*) tapdata;
d->model_->addRecord((tap_credential_t*)data);
d->model_->addRecord((const tap_credential_t*)data);
return TAP_PACKET_REDRAW;
}

View File

@ -998,9 +998,13 @@ static stat_tap_ui lte_rlc_statistics_ui = {
};
extern "C" {
void register_tap_listener_qt_lte_rlc_statistics(void);
void
register_tap_listener_qt_lte_rlc_statistics(void)
{
register_stat_tap_ui(&lte_rlc_statistics_ui, NULL);
}
}

View File

@ -120,9 +120,10 @@ static void plugin_if_mainwindow_preference(GHashTable * data_set)
const char * pref_name;
const char * pref_value;
if (g_hash_table_lookup_extended(data_set, "pref_module", NULL, (void**)&module_name) &&
g_hash_table_lookup_extended(data_set, "pref_key", NULL, (void**)&pref_name) &&
g_hash_table_lookup_extended(data_set, "pref_value", NULL, (void**)&pref_value))
DIAG_OFF_CAST_AWAY_CONST
if (g_hash_table_lookup_extended(data_set, "pref_module", NULL, (gpointer *)&module_name) &&
g_hash_table_lookup_extended(data_set, "pref_key", NULL, (gpointer *)&pref_name) &&
g_hash_table_lookup_extended(data_set, "pref_value", NULL, (gpointer *)&pref_value))
{
unsigned int changed_flags = prefs_store_ext(module_name, pref_name, pref_value);
if (changed_flags) {
@ -130,6 +131,7 @@ static void plugin_if_mainwindow_preference(GHashTable * data_set)
wsApp->emitAppSignal(WiresharkApplication::PreferencesChanged);
}
}
DIAG_ON_CAST_AWAY_CONST
}
static void plugin_if_mainwindow_gotoframe(GHashTable * data_set)

View File

@ -51,7 +51,7 @@ public:
BoolPreference(QObject * parent = Q_NULLPTR) : WiresharkPreference(parent) {}
virtual QWidget * editor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index)
{
((QAbstractItemModel*)index.model())->setData(index, QString("BOOL"), Qt::EditRole);
const_cast<QAbstractItemModel*>(index.model())->setData(index, QString("BOOL"), Qt::EditRole);
return WiresharkPreference::editor(parent, option, index);
}
};
@ -180,7 +180,7 @@ public:
QString filename = WiresharkFileDialog::getSaveFileName(parent, wsApp->windowTitleString(prefs_get_title(prefsItem()->getPref())),
index.model()->data(index, Qt::DisplayRole).toString());
if (!filename.isEmpty()) {
((QAbstractItemModel*)index.model())->setData(index, QDir::toNativeSeparators(filename), Qt::EditRole);
const_cast<QAbstractItemModel*>(index.model())->setData(index, QDir::toNativeSeparators(filename), Qt::EditRole);
}
return WiresharkPreference::editor(parent, option, index);
}
@ -196,7 +196,7 @@ public:
QString filename = WiresharkFileDialog::getOpenFileName(parent, wsApp->windowTitleString(prefs_get_title(prefsItem()->getPref())),
index.model()->data(index, Qt::DisplayRole).toString());
if (!filename.isEmpty()) {
((QAbstractItemModel*)index.model())->setData(index, QDir::toNativeSeparators(filename), Qt::EditRole);
const_cast<QAbstractItemModel*>(index.model())->setData(index, QDir::toNativeSeparators(filename), Qt::EditRole);
}
return WiresharkPreference::editor(parent, option, index);
}
@ -212,7 +212,7 @@ public:
QString filename = WiresharkFileDialog::getExistingDirectory(parent, wsApp->windowTitleString(prefs_get_title(prefsItem()->getPref())),
index.model()->data(index, Qt::DisplayRole).toString());
if (!filename.isEmpty()) {
((QAbstractItemModel*)index.model())->setData(index, QDir::toNativeSeparators(filename), Qt::EditRole);
const_cast<QAbstractItemModel*>(index.model())->setData(index, QDir::toNativeSeparators(filename), Qt::EditRole);
}
return WiresharkPreference::editor(parent, option, index);
}

View File

@ -99,7 +99,7 @@ QVariant CredentialsModel::data(const QModelIndex &index, int role) const
return QVariant();
}
void CredentialsModel::addRecord(tap_credential_t* auth)
void CredentialsModel::addRecord(const tap_credential_t* auth)
{
emit beginInsertRows(QModelIndex(), rowCount(), rowCount() + 1);

View File

@ -30,7 +30,7 @@ public:
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
void addRecord(tap_credential_t* rec);
void addRecord(const tap_credential_t *rec);
void clear();
enum {

View File

@ -116,7 +116,9 @@ void ExpertInfoModel::clear()
ExpertPacketItem* ExpertInfoModel::createRootItem()
{
static const char* rootName = "ROOT";
DIAG_OFF_CAST_AWAY_CONST
static expert_info_t root_expert = { 0, -1, -1, -1, rootName, (gchar*)rootName, NULL };
DIAG_ON_CAST_AWAY_CONST
return new ExpertPacketItem(root_expert, NULL, NULL);
}

View File

@ -37,7 +37,7 @@ QWidget *AdvancedPrefDelegate::createEditor(QWidget *parent, const QStyleOptionV
case AdvancedPrefsModel::colType:
//If user clicks on any of these columns, reset preference back to default
//There is no need to launch an editor
((QAbstractItemModel*)index.model())->setData(index, QVariant(), Qt::EditRole);
const_cast<QAbstractItemModel*>(index.model())->setData(index, QVariant(), Qt::EditRole);
break;
case AdvancedPrefsModel::colValue:
pref = indexToPref(index);

View File

@ -184,7 +184,7 @@ void UatDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
if (qobject_cast<QColorDialog *>(editor))
{
QColor newColor = qobject_cast<QColorDialog *>(editor)->currentColor();
((QAbstractItemModel *)index.model())->setData(index, newColor.name(), Qt::EditRole);
const_cast<QAbstractItemModel *>(index.model())->setData(index, newColor.name(), Qt::EditRole);
}
break;
@ -197,6 +197,6 @@ void UatDelegate::applyFilename(const QModelIndex& index)
{
if (index.isValid()) {
EditorFileDialog* fileDialog = static_cast<EditorFileDialog*>(sender());
((QAbstractItemModel *)index.model())->setData(index, fileDialog->text(), Qt::EditRole);
const_cast<QAbstractItemModel *>(index.model())->setData(index, fileDialog->text(), Qt::EditRole);
}
}

View File

@ -321,8 +321,8 @@ void VoipCallsDialog::tapDraw(void *tapinfo_ptr)
gint VoipCallsDialog::compareCallNums(gconstpointer a, gconstpointer b)
{
voip_calls_info_t *call_a = (voip_calls_info_t *)a;
voip_calls_info_t *call_b = (voip_calls_info_t *)b;
const voip_calls_info_t *call_a = (const voip_calls_info_t *)a;
const voip_calls_info_t *call_b = (const voip_calls_info_t *)b;
return (call_a->call_num != call_b->call_num);
}