Fix uninitialized variables

This commit is contained in:
Jonas Kvinge 2021-03-26 21:30:13 +01:00
parent 8a39a43ad5
commit 14fb647647
27 changed files with 64 additions and 65 deletions

View File

@ -22,6 +22,7 @@
#include <QtGlobal>
#include <cstring>
#include <cmath>
#include <glib.h>
@ -74,7 +75,7 @@ static void gst_fastspectrum_class_init (GstFastSpectrumClass * klass) {
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstBaseTransformClass *trans_class = GST_BASE_TRANSFORM_CLASS (klass);
GstAudioFilterClass *filter_class = GST_AUDIO_FILTER_CLASS (klass);
GstCaps *caps;
GstCaps *caps = nullptr;
gobject_class->set_property = gst_fastspectrum_set_property;
gobject_class->get_property = gst_fastspectrum_get_property;
@ -264,7 +265,7 @@ static void input_data_mixed_float(const guint8* _in, double* out, guint len, do
Q_UNUSED(max_value);
guint j, ip = 0;
guint j = 0, ip = 0;
const gfloat *in = reinterpret_cast<const gfloat*>(_in);
for (j = 0; j < len; j++) {
@ -278,7 +279,7 @@ static void input_data_mixed_double (const guint8 * _in, double* out, guint len,
Q_UNUSED(max_value);
guint j, ip = 0;
guint j = 0, ip = 0;
const gdouble *in = reinterpret_cast<const gdouble*>(_in);
for (j = 0; j < len; j++) {
@ -290,7 +291,7 @@ static void input_data_mixed_double (const guint8 * _in, double* out, guint len,
static void input_data_mixed_int32_max (const guint8 * _in, double* out, guint len, double max_value, guint op, guint nfft) {
guint j, ip = 0;
guint j = 0, ip = 0;
const gint32 *in = reinterpret_cast<const gint32*>(_in);
for (j = 0; j < len; j++) {
@ -302,7 +303,7 @@ static void input_data_mixed_int32_max (const guint8 * _in, double* out, guint l
static void input_data_mixed_int24_max (const guint8 * _in, double* out, guint len, double max_value, guint op, guint nfft) {
guint j;
guint j = 0;
for (j = 0; j < len; j++) {
#if G_BYTE_ORDER == G_BIG_ENDIAN
@ -322,7 +323,7 @@ static void input_data_mixed_int24_max (const guint8 * _in, double* out, guint l
static void input_data_mixed_int16_max (const guint8 * _in, double * out, guint len, double max_value, guint op, guint nfft) {
guint j, ip = 0;
guint j = 0, ip = 0;
const gint16 *in = reinterpret_cast<const gint16*>(_in);
for (j = 0; j < len; j++) {
@ -369,7 +370,7 @@ static gboolean gst_fastspectrum_setup (GstAudioFilter * base, const GstAudioInf
static void gst_fastspectrum_run_fft (GstFastSpectrum * spectrum, guint input_pos) {
guint i;
guint i = 0;
guint bands = spectrum->bands;
guint nfft = 2 * bands - 2;
@ -379,7 +380,7 @@ static void gst_fastspectrum_run_fft (GstFastSpectrum * spectrum, guint input_po
// Should be safe to execute the same plan multiple times in parallel.
fftw_execute(spectrum->plan);
gdouble val;
gdouble val = 0.0;
/* Calculate magnitude in db */
for (i = 0; i < bands; i++) {
val = spectrum->fft_output[i][0] * spectrum->fft_output[i][0];
@ -399,13 +400,13 @@ static GstFlowReturn gst_fastspectrum_transform_ip (GstBaseTransform *trans, Gst
double max_value = (1UL << ((bps << 3) - 1)) - 1;
guint bands = spectrum->bands;
guint nfft = 2 * bands - 2;
guint input_pos;
guint input_pos = 0;
GstMapInfo map;
const guint8 *data;
gsize size;
guint fft_todo, msg_todo, block_size;
gboolean have_full_interval;
GstFastSpectrumInputData input_data;
const guint8 *data = nullptr;
gsize size = 0;
guint fft_todo = 0, msg_todo = 0, block_size = 0;
gboolean have_full_interval = false;
GstFastSpectrumInputData input_data = nullptr;
g_mutex_lock (&spectrum->lock);
gst_buffer_map (buffer, &map, GST_MAP_READ);

View File

@ -278,7 +278,7 @@ QString CXXDemangle(const QString &mangled_function);
QString CXXDemangle(const QString &mangled_function) {
int status;
int status = 0;
char* demangled_function = abi::__cxa_demangle(mangled_function.toLatin1().constData(), nullptr, nullptr, &status);
if (status == 0) {
QString ret = QString::fromLatin1(demangled_function);

View File

@ -141,7 +141,7 @@ int Analyzer::Base::resizeExponent(int exp) {
int Analyzer::Base::resizeForBands(int bands) {
int exp;
int exp = 0;
if (bands <= 8)
exp = 4;
else if (bands <= 16)

View File

@ -164,7 +164,7 @@ void BlockAnalyzer::analyze(QPainter &p, const Analyzer::Scope &s, bool new_fram
// Paint the background
canvas_painter.drawPixmap(0, 0, background_);
for (int y, x = 0; x < static_cast<int>(scope_.size()); ++x) {
for (int x = 0, y = 0; x < static_cast<int>(scope_.size()); ++x) {
// determine y
for (y = 0; scope_[x] < yscale_[y]; ++y) continue;
@ -242,7 +242,7 @@ QColor ensureContrast(const QColor &bg, const QColor &fg, int amount) {
public:
explicit OutputOnExit(const QColor &color) : c(color) {}
~OutputOnExit() {
int h, s, v;
int h = 0, s = 0, v = 0;
c.getHsv(&h, &s, &v);
}
@ -252,8 +252,8 @@ QColor ensureContrast(const QColor &bg, const QColor &fg, int amount) {
OutputOnExit allocateOnTheStack(fg);
int bh, bs, bv;
int fh, fs, fv;
int bh = 0, bs = 0, bv = 0;
int fh = 0, fs = 0, fv = 0;
bg.getHsv(&bh, &bs, &bv);
fg.getHsv(&fh, &fs, &fv);
@ -347,7 +347,7 @@ void BlockAnalyzer::paletteChange(const QPalette&) {
// make a complimentary fadebar colour
// TODO dark is not always correct, dumbo!
int h, s, v;
int h = 0, s = 0, v = 0;
palette().color(QPalette::Window).darker(150).getHsv(&h, &s, &v);
const QColor fg2(QColor::fromHsv(h + 120, s, v));

View File

@ -116,7 +116,7 @@ void BoomAnalyzer::analyze(QPainter& p, const Scope& scope, bool new_frame) {
p.drawPixmap(0, 0, canvas_);
return;
}
double h;
double h = 0.0;
const uint MAX_HEIGHT = height() - 1;
QPainter canvas_painter(&canvas_);
@ -124,7 +124,7 @@ void BoomAnalyzer::analyze(QPainter& p, const Scope& scope, bool new_frame) {
Analyzer::interpolate(scope, scope_);
for (int i = 0, x = 0, y; i < bands_; ++i, x += kColumnWidth + 1) {
for (int i = 0, x = 0, y = 0; i < bands_; ++i, x += kColumnWidth + 1) {
h = log10(scope_[i] * 256.0) * F_;
if (h > MAX_HEIGHT) h = MAX_HEIGHT;

View File

@ -68,7 +68,7 @@ void FHT::ewma(float* d, float* s, float w) {
void FHT::logSpectrum(float* out, float* p) {
int n = num_ / 2, i, j, k, *r;
int n = num_ / 2, i = 0, j = 0, k = 0, *r = nullptr;
if (log_vector_.size() < n) {
log_vector_.resize(n);
float f = n / log10(static_cast<double>(n));
@ -135,8 +135,8 @@ void FHT::transform(float* p) {
void FHT::transform8(float* p) {
float a, b, c, d, e, f, g, h, b_f2, d_h2;
float a_c_eg, a_ce_g, ac_e_g, aceg, b_df_h, bdfh;
float a = 0.0, b = 0.0, c = 0.0, d = 0.0, e = 0.0, f = 0.0, g = 0.0, h = 0.0, b_f2 = 0.0, d_h2 = 0.0;
float a_c_eg = 0.0, a_ce_g = 0.0, ac_e_g = 0.0, aceg = 0.0, b_df_h = 0.0, bdfh = 0.0;
a = *p++, b = *p++, c = *p++, d = *p++;
e = *p++, f = *p++, g = *p++, h = *p;
@ -169,8 +169,8 @@ void FHT::_transform(float* p, int n, int k) {
return;
}
int i, j, ndiv2 = n / 2;
float a, *t1, *t2, *t3, *t4, *ptab, *pp;
int i = 0, j = 0, ndiv2 = n / 2;
float a = 0.0, *t1 = nullptr, *t2 = nullptr, *t3 = nullptr, *t4 = nullptr, *ptab = nullptr, *pp = nullptr;
for (i = 0, t1 = buf_(), t2 = buf_() + ndiv2, pp = &p[k]; i < ndiv2; i++)
*t1++ = *pp++, *t2++ = *pp++;

View File

@ -1914,7 +1914,7 @@ QDataStream &operator<<(QDataStream &s, const CollectionModel::Grouping &g) {
QDataStream &operator>>(QDataStream &s, CollectionModel::Grouping &g) {
quint32 buf;
quint32 buf = 0;
s >> buf;
g.first = CollectionModel::GroupBy(buf);
s >> buf;

View File

@ -33,11 +33,11 @@ FileSystemWatcherInterface::FileSystemWatcherInterface(QObject *parent)
: QObject(parent) {}
FileSystemWatcherInterface *FileSystemWatcherInterface::Create(QObject *parent) {
FileSystemWatcherInterface *ret;
#ifdef Q_OS_MACOS
ret = new MacFSListener(parent);
FileSystemWatcherInterface *ret = new MacFSListener(parent);
#else
ret = new QtFSListener(parent);
FileSystemWatcherInterface *ret = new QtFSListener(parent);
#endif
ret->Init();

View File

@ -282,7 +282,7 @@ QModelIndex MergedProxyModel::mapFromSource(const QModelIndex &source_index) con
// Add a mapping if we don't have one already
const auto &it = p_->mappings_.get<tag_by_source>().find(source_index);
Mapping *mapping;
Mapping *mapping = nullptr;
if (it != p_->mappings_.get<tag_by_source>().end()) {
mapping = *it;
}

View File

@ -566,8 +566,8 @@ void SongLoader::ErrorMessageReceived(GstMessage *msg) {
if (state_ == Finished) return;
GError *error;
gchar *debugs;
GError *error = nullptr;
gchar *debugs = nullptr;
gst_message_parse_error(msg, &error, &debugs);
qLog(Error) << __PRETTY_FUNCTION__ << error->message;

View File

@ -315,7 +315,7 @@ bool Copy(QIODevice *source, QIODevice *destination) {
std::unique_ptr<char[]> data(new char[bytes]);
qint64 pos = 0;
qint64 bytes_read;
qint64 bytes_read = 0;
do {
bytes_read = source->read(data.get() + pos, bytes - pos);
if (bytes_read == -1) return false;
@ -324,7 +324,7 @@ bool Copy(QIODevice *source, QIODevice *destination) {
} while (bytes_read > 0 && pos != bytes);
pos = 0;
qint64 bytes_written;
qint64 bytes_written = 0;
do {
bytes_written = destination->write(data.get() + pos, bytes - pos);
if (bytes_written == -1) return false;

View File

@ -166,7 +166,7 @@ void CddaSongLoader::LoadSongs() {
// Handle TOC message: get tracks duration
if (msg_toc) {
GstToc *toc;
GstToc *toc = nullptr;
gst_message_parse_toc (msg_toc, &toc, nullptr);
if (toc) {
GList *entries = gst_toc_get_entries(toc);
@ -175,7 +175,7 @@ void CddaSongLoader::LoadSongs() {
for (GList *node = entries; node != nullptr; node = node->next) {
GstTocEntry *entry = static_cast<GstTocEntry*>(node->data);
quint64 duration = 0;
gint64 start, stop;
gint64 start = 0, stop = 0;
if (gst_toc_entry_get_start_stop_times (entry, &start, &stop)) duration = stop - start;
songs[i++].set_length_nanosec(duration);
}

View File

@ -215,7 +215,7 @@ bool GstEnginePipeline::InitFromUrl(const QByteArray &stream_url, const QUrl ori
g_object_set(G_OBJECT(pipeline_), "uri", stream_url.constData(), nullptr);
gint flags;
gint flags = 0;
g_object_get(G_OBJECT(pipeline_), "flags", &flags, nullptr);
flags |= 0x00000002;
flags &= ~0x00000001;
@ -816,7 +816,7 @@ GstBusSyncReply GstEnginePipeline::BusCallbackSync(GstBus*, GstMessage *msg, gpo
void GstEnginePipeline::StreamStatusMessageReceived(GstMessage *msg) {
GstStreamStatusType type;
GstStreamStatusType type = GST_STREAM_STATUS_TYPE_CREATE;
GstElement *owner = nullptr;
gst_message_parse_stream_status(msg, &type, &owner);
@ -985,7 +985,7 @@ QString GstEnginePipeline::ParseStrTag(GstTagList *list, const char *tag) const
guint GstEnginePipeline::ParseUIntTag(GstTagList *list, const char *tag) const {
guint data;
guint data = 0;
bool success = gst_tag_list_get_uint(list, tag, &data);
guint ret = 0;
@ -1001,7 +1001,7 @@ void GstEnginePipeline::StateChangedMessageReceived(GstMessage *msg) {
return;
}
GstState old_state, new_state, pending;
GstState old_state = GST_STATE_NULL, new_state = GST_STATE_NULL, pending = GST_STATE_NULL;
gst_message_parse_state_changed(msg, &old_state, &new_state, &pending);
if (!pipeline_is_initialized_ && (new_state == GST_STATE_PAUSED || new_state == GST_STATE_PLAYING)) {
@ -1074,7 +1074,7 @@ qint64 GstEnginePipeline::length() const {
GstState GstEnginePipeline::state() const {
GstState s, sp;
GstState s = GST_STATE_NULL, sp = GST_STATE_NULL;
if (!pipeline_ || gst_element_get_state(pipeline_, &s, &sp, kGstStateTimeoutNanosecs) == GST_STATE_CHANGE_FAILURE)
return GST_STATE_NULL;

View File

@ -71,7 +71,7 @@ bool LocalRedirectServer::GenerateCertificate() {
return false;
}
gnutls_x509_privkey_t key;
gnutls_x509_privkey_t key = nullptr;
if (int result = gnutls_x509_privkey_init(&key) != GNUTLS_E_SUCCESS) {
error_ = QString("Failed to initialize the private key structure: %1").arg(gnutls_strerror(result));
gnutls_global_deinit();
@ -104,7 +104,7 @@ bool LocalRedirectServer::GenerateCertificate() {
return false;
}
gnutls_x509_crt_t crt;
gnutls_x509_crt_t crt = nullptr;
if (int result = gnutls_x509_crt_init(&crt) != GNUTLS_E_SUCCESS) {
error_ = QString("Failed to initialize an X.509 certificate structure: %1").arg(gnutls_strerror(result));
gnutls_x509_privkey_deinit(key);
@ -173,7 +173,7 @@ bool LocalRedirectServer::GenerateCertificate() {
return false;
}
gnutls_privkey_t pkey;
gnutls_privkey_t pkey = nullptr;
if (int result = gnutls_privkey_init(&pkey) != GNUTLS_E_SUCCESS) {
error_ = QString("Failed to initialize a private key object: %1").arg(gnutls_strerror(result));
gnutls_x509_privkey_deinit(key);

View File

@ -134,8 +134,8 @@ void MoodbarPipeline::Start() {
void MoodbarPipeline::ReportError(GstMessage *msg) {
GError *error;
gchar *debugs;
GError *error = nullptr;
gchar *debugs = nullptr;
gst_message_parse_error(msg, &error, &debugs);
QString message = QString::fromLocal8Bit(error->message);

View File

@ -136,7 +136,7 @@ void MoodbarRenderer::Render(const ColorVector &colors, QPainter *p, const QRect
// Draw the actual moodbar.
for (int x = 0; x < rect.width(); x++) {
int h, s, v;
int h = 0, s = 0, v = 0;
screen_colors[x].getHsv(&h, &s, &v);
for (int y = 0; y <= rect.height() / 2; y++) {

View File

@ -440,7 +440,7 @@ FilterTree *FilterParser::createSearchTermTreeNode(const QString &col, const QSt
}
else if (!col.isEmpty() && columns_.contains(col) && numerical_columns_.contains(columns_[col])) {
// the length column contains the time in seconds (nano seconds, actually - the "nano" part is handled by the DropTailComparatorDecorator, though).
int search_value;
int search_value = 0;
if (columns_[col] == Playlist::Column_Length) {
search_value = parseTime(search);
}

View File

@ -226,7 +226,7 @@ void PlaylistTabBar::CloseSlot() {
QDialogButtonBox *buttons = confirmation_box.findChild<QDialogButtonBox*>();
if (grid && buttons) {
const int index = grid->indexOf(buttons);
int row, column, row_span, column_span = 0;
int row = 0, column = 0, row_span = 0, column_span = 0;
grid->getItemPosition(index, &row, &column, &row_span, &column_span);
QLayoutItem *buttonsItem = grid->takeAt(index);
grid->addWidget(&dont_prompt_again, row, column, row_span, column_span, Qt::AlignLeft | Qt::AlignTop);

View File

@ -303,7 +303,7 @@ void NotificationsSettingsPage::ChooseFgColor() {
void NotificationsSettingsPage::ChooseFont() {
bool ok;
bool ok = false;
QFont font = QFontDialog::getFont(&ok, pretty_popup_->font(), this);
if (ok) {
pretty_popup_->set_font(font);

View File

@ -134,8 +134,8 @@ QDataStream &operator<<(QDataStream &s, const SmartPlaylistSearch &search) {
QDataStream &operator>>(QDataStream &s, SmartPlaylistSearch &search) {
quint8 sort_type, sort_field, search_type;
qint32 limit;
quint8 sort_type = 0, sort_field = 0, search_type = 0;
qint32 limit = 0;
s >> search.terms_ >> sort_type >> sort_field >> limit >> search_type;
search.sort_type_ = SmartPlaylistSearch::SortType(sort_type);

View File

@ -456,7 +456,7 @@ QDataStream &operator<<(QDataStream &s, const SmartPlaylistSearchTerm &term) {
QDataStream &operator>>(QDataStream &s, SmartPlaylistSearchTerm &term) {
quint8 field, op, date;
quint8 field = 0, op = 0, date = 0;
s >> field >> op >> term.value_ >> term.second_value_ >> date;
term.field_ = SmartPlaylistSearchTerm::Field(field);
term.operator_ = SmartPlaylistSearchTerm::Operator(op);

View File

@ -153,8 +153,7 @@ void SubsonicRequest::FlushAlbumsRequests() {
if (request.size > 0) params << Param("size", QString::number(request.size));
if (request.offset > 0) params << Param("offset", QString::number(request.offset));
QNetworkReply *reply;
reply = CreateGetRequest(QString("getAlbumList2"), params);
QNetworkReply *reply = CreateGetRequest(QString("getAlbumList2"), params);
replies_ << reply;
QObject::connect(reply, &QNetworkReply::finished, this, [this, reply, request]() { AlbumsReplyReceived(reply, request.offset); });

View File

@ -81,8 +81,7 @@ void SubsonicScrobbleRequest::FlushScrobbleRequests() {
Param("submission", QVariant(request.submission).toString()) <<
Param("time", QVariant(request.time_ms).toString());
QNetworkReply *reply;
reply = CreateGetRequest(QString("scrobble"), params);
QNetworkReply *reply = CreateGetRequest(QString("scrobble"), params);
replies_ << reply;
QObject::connect(reply, &QNetworkReply::finished, this, [this, reply]() { ScrobbleReplyReceived(reply); });

View File

@ -934,7 +934,7 @@ void TidalService::CancelSearch() {
void TidalService::SendSearch() {
TidalBaseRequest::QueryType type;
TidalBaseRequest::QueryType type = TidalBaseRequest::QueryType_None;
switch (pending_search_type_) {
case InternetSearchView::SearchType_Artists:

View File

@ -396,8 +396,8 @@ GstBusSyncReply Transcoder::BusCallbackSync(GstBus*, GstMessage *msg, gpointer d
void Transcoder::JobState::ReportError(GstMessage *msg) {
GError *error;
gchar *debugs;
GError *error = nullptr;
gchar *debugs = nullptr;
gst_message_parse_error(msg, &error, &debugs);
QString message = QString::fromLocal8Bit(error->message);

View File

@ -271,7 +271,7 @@ class FancyTabBar: public QTabBar {
{
p.save();
QTransform m;
int textFlags;
int textFlags = 0;
Qt::Alignment iconFlags;
QRect tabrectText;

View File

@ -278,7 +278,7 @@ void GroupedIconView::paintEvent(QPaintEvent *e) {
if (selections && selections->isSelected(*it))
option.state |= QStyle::State_Selected;
if (enabled) {
QPalette::ColorGroup cg;
QPalette::ColorGroup cg = QPalette::Active;
if ((itemModel->flags(*it) & Qt::ItemIsEnabled) == 0) {
option.state &= ~QStyle::State_Enabled;
cg = QPalette::Disabled;