Skip to content

Reduce compilation warnings #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/FileHistory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ QModelIndex FileHistory::index(int row, int column, const QModelIndex&) const {
if (row < 0 || row >= rowCnt)
return QModelIndex();

return createIndex(row, column, (void*)0);
return createIndex(row, column, nullptr);
}

QModelIndex FileHistory::parent(const QModelIndex&) const {
Expand All @@ -213,12 +213,12 @@ QModelIndex FileHistory::parent(const QModelIndex&) const {
return no_parent;
}

const QString FileHistory::timeDiff(unsigned long secs) const {
const QString FileHistory::timeDiff(unsigned long s) const {

ulong days = secs / (3600 * 24);
ulong hours = (secs - days * 3600 * 24) / 3600;
ulong min = (secs - days * 3600 * 24 - hours * 3600) / 60;
ulong sec = secs - days * 3600 * 24 - hours * 3600 - min * 60;
ulong days = s / (3600 * 24);
ulong hours = (s - days * 3600 * 24) / 3600;
ulong min = (s - days * 3600 * 24 - hours * 3600) / 60;
ulong sec = s - days * 3600 * 24 - hours * 3600 - min * 60;
QString tmp;
if (days > 0)
tmp.append(QString::number(days) + "d ");
Expand Down
16 changes: 8 additions & 8 deletions src/FileHistory.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ class FileHistory : public QAbstractItemModel
void setEarlyOutputState(bool b = true) { earlyOutputCnt = (b ? earlyOutputCntBase : -1); }
void setAnnIdValid(bool b = true) { annIdValid = b; }

virtual QVariant data(const QModelIndex &index, int role) const;
virtual Qt::ItemFlags flags(const QModelIndex& index) const;
virtual QVariant headerData(int s, Qt::Orientation o, int role = Qt::DisplayRole) const;
virtual QModelIndex index(int r, int c, const QModelIndex& par = QModelIndex()) const;
virtual QModelIndex parent(const QModelIndex& index) const;
virtual int rowCount(const QModelIndex& par = QModelIndex()) const;
virtual bool hasChildren(const QModelIndex& par = QModelIndex()) const;
virtual int columnCount(const QModelIndex&) const { return 6; }
virtual QVariant data(const QModelIndex &index, int role) const override;
virtual Qt::ItemFlags flags(const QModelIndex& index) const override;
virtual QVariant headerData(int s, Qt::Orientation o, int role = Qt::DisplayRole) const override;
virtual QModelIndex index(int r, int c, const QModelIndex& par = QModelIndex()) const override;
virtual QModelIndex parent(const QModelIndex& index) const override;
virtual int rowCount(const QModelIndex& par = QModelIndex()) const override;
virtual bool hasChildren(const QModelIndex& par = QModelIndex()) const override;
virtual int columnCount(const QModelIndex&) const override { return 6; }

public slots:
void on_changeFont(const QFont&);
Expand Down
26 changes: 13 additions & 13 deletions src/annotate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ void Annotate::doAnnotate(const ShaString& ss) {
int parentNum = 1;
while (it != parents.constEnd()) {

FileAnnotation* pa = getFileAnnotation(*it);
const QString& diff(getPatch(sha, parentNum++));
pa = getFileAnnotation(*it);
const QString& diff2(getPatch(sha, parentNum++));
QStringList tmpAnn;
setAnnotation(diff, "Merge", pa->lines, tmpAnn);
setAnnotation(diff2, "Merge", pa->lines, tmpAnn);

// the two annotations must be of the same length
if (fa->lines.count() != tmpAnn.count()) {
Expand Down Expand Up @@ -214,7 +214,7 @@ void Annotate::setInitialAnnotation(SCRef fileSha, FileAnnotation* fa) {
fa->lines.append(empty);
}

const QString Annotate::setupAuthor(SCRef origAuthor, int annId) {
const QString Annotate::setupAuthor(SCRef origAuthor, int id) {

QString tmp(origAuthor.section('<', 0, 0).trimmed()); // strip e-mail address
if (tmp.isEmpty()) { // probably only e-mail
Expand All @@ -232,7 +232,7 @@ const QString Annotate::setupAuthor(SCRef origAuthor, int annId) {

tmp.truncate(MAX_AUTHOR_LEN);
}
return QString("%1.%2").arg(annId, annNumLen).arg(tmp);
return QString("%1.%2").arg(id, annNumLen).arg(tmp);
}

void Annotate::unify(SList dst, SCList src) {
Expand Down Expand Up @@ -786,23 +786,23 @@ const QString Annotate::computeRanges(SCRef sha, int paraFrom, int paraTo, SCRef

for ( ; shaIdx >= 0; shaIdx--) {

SCRef sha(histRevOrder[shaIdx]);
SCRef sha2(histRevOrder[shaIdx]);

if (!ranges.contains(sha)) {
if (!ranges.contains(sha2)) {

curRev = git->revLookup(sha, fh);
curRev = git->revLookup(sha2, fh);

if (curRev->parentsCount() == 0) {
// the start of an independent branch is found in this case
// insert an empty range, the whole branch will be ignored.
// Merge of outside branches are very rare so this solution
// seems enough if we don't want to dive in (useless) complications.
ranges.insert(sha, RangeInfo());
ranges.insert(sha2, RangeInfo());
continue;
}
const QString& diff(getPatch(sha));
const QString& diff(getPatch(sha2));
if (diff.isEmpty()) {
dbp("ASSERT in rangeFilter 2: diff for %1 not found", sha);
dbp("ASSERT in rangeFilter 2: diff for %1 not found", sha2);
return "";
}
QString parSha(curRev->parent(0));
Expand All @@ -817,9 +817,9 @@ const QString Annotate::computeRanges(SCRef sha, int paraFrom, int paraTo, SCRef
}
RangeInfo r(ranges[parSha]);
updateRange(&r, diff, false);
ranges.insert(sha, r);
ranges.insert(sha2, r);

if (sha == target) // stop now, no need to continue
if (sha2 == target) // stop now, no need to continue
return ancestor;
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ bool Cache::save(const QString& gitDir, const RevFileMap& rf,
QDataStream stream(&data, QIODevice::WriteOnly);

// Write a header with a "magic number" and a version
stream << (quint32)C_MAGIC;
stream << (qint32)C_VERSION;
stream << static_cast<quint32>(C_MAGIC);
stream << static_cast<qint32>(C_VERSION);

stream << (qint32)dirs.count();
stream << static_cast<qint32>(dirs.count());
for (int i = 0; i < dirs.count(); ++i)
stream << dirs.at(i);

stream << (qint32)files.count();
stream << static_cast<qint32>(files.count());
for (int i = 0; i < files.count(); ++i)
stream << files.at(i);

Expand Down Expand Up @@ -83,7 +83,7 @@ bool Cache::save(const QString& gitDir, const RevFileMap& rf,
}
}
buf.resize(newSize);
stream << (qint32)newSize;
stream << static_cast<qint32>(newSize);
stream << buf;

for (int i = 0; i < v.size(); ++i)
Expand Down
4 changes: 2 additions & 2 deletions src/commitimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Q_OBJECT
void changesCommitted(bool);

public slots:
virtual void closeEvent(QCloseEvent*);
virtual void closeEvent(QCloseEvent*) override;
void pushButtonCommit_clicked();
void pushButtonAmend_clicked();
void pushButtonCancel_clicked();
Expand All @@ -43,7 +43,7 @@ private slots:
bool checkPatchName(QString& patchName);
bool checkConfirm(SCRef msg, SCRef patchName, SCList selFiles, bool amend);
void computePosition(int &col_pos, int &line_pos);
bool eventFilter(QObject* obj, QEvent* event);
bool eventFilter(QObject* obj, QEvent* event) override;

Git* git;
QString origMsg;
Expand Down
20 changes: 10 additions & 10 deletions src/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
#include <QTextDocument>
#include "common.h"

const QString Rev::mid(int start, int len) const {
const QString Rev::mid(int from, int len) const {

// warning no sanity check is done on arguments
const char* data = ba.constData();
return QString::fromLocal8Bit(data + start, len);
return QString::fromLocal8Bit(data + from, len);
}

const QString Rev::midSha(int start, int len) const {
const QString Rev::midSha(int from, int len) const {

// warning no sanity check is done on arguments
const char* data = ba.constData();
return QString::fromLatin1(data + start, len); // faster then formAscii
return QString::fromLatin1(data + from, len); // faster then formAscii
}

const ShaString Rev::parent(int idx) const {
Expand Down Expand Up @@ -217,19 +217,19 @@ const RevFile& RevFile::operator>>(QDataStream& stream) const {

// skip common case of only modified files
bool isEmpty = onlyModified;
stream << (quint32)isEmpty;
stream << static_cast<quint32>(isEmpty);
if (!isEmpty)
stream << status;

// skip common case of just one parent
isEmpty = (mergeParent.isEmpty() || mergeParent.last() == 1);
stream << (quint32)isEmpty;
stream << static_cast<quint32>(isEmpty);
if (!isEmpty)
stream << mergeParent;

// skip common case of no rename/copies
isEmpty = extStatus.isEmpty();
stream << (quint32)isEmpty;
stream << static_cast<quint32>(isEmpty);
if (!isEmpty)
stream << extStatus;

Expand All @@ -247,17 +247,17 @@ RevFile& RevFile::operator<<(QDataStream& stream) {
quint32 tmp;

stream >> tmp;
onlyModified = (bool)tmp;
onlyModified = static_cast<bool>(tmp);
if (!onlyModified)
stream >> status;

stream >> tmp;
isEmpty = (bool)tmp;
isEmpty = static_cast<bool>(tmp);
if (!isEmpty)
stream >> mergeParent;

stream >> tmp;
isEmpty = (bool)tmp;
isEmpty = static_cast<bool>(tmp);
if (!isEmpty)
stream >> extStatus;

Expand Down
12 changes: 6 additions & 6 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
template<typename T> inline const QString _valueOf(const T& x) { return QVariant(x).toString(); }
template<> inline const QString _valueOf(const QStringList& x) { return x.join(" "); }
inline const QString& _valueOf(const QString& x) { return x; }
inline const QString _valueOf(size_t x) { return QString::number((uint)x); }
inline const QString _valueOf(size_t x) { return QString::number(static_cast<uint>(x)); }

// some debug macros
#define constlatin(x) (_valueOf(x).toLatin1().constData())
Expand Down Expand Up @@ -403,15 +403,15 @@ class RevFile {
*/
QByteArray pathsIdx;

int dirAt(uint idx) const { return ((const int*)pathsIdx.constData())[idx]; }
int nameAt(uint idx) const { return ((const int*)pathsIdx.constData())[count() + idx]; }
int dirAt(uint idx) const { return reinterpret_cast<const int *>(pathsIdx.constData())[idx]; }
int nameAt(uint idx) const { return reinterpret_cast<const int *>(pathsIdx.constData())[count() + idx]; }

QVector<int> mergeParent;

// helper functions
int count() const {

return pathsIdx.size() / ((int)sizeof(int) * 2);
return pathsIdx.size() / (sizeof(int) * 2);
}
bool statusCmp(int idx, StatusFlag sf) const {

Expand Down Expand Up @@ -445,14 +445,14 @@ typedef QHash<ShaString, FileAnnotation> AnnotateHistory;

class BaseEvent: public QEvent {
public:
BaseEvent(SCRef d, int id) : QEvent((QEvent::Type)id), payLoad(d) {}
BaseEvent(SCRef ref, int id) : QEvent(static_cast<QEvent::Type>(id)), payLoad(ref) {}
const QString myData() const { return payLoad; }
private:
const QString payLoad; // passed by copy
};

#define DEF_EVENT(X, T) class X : public BaseEvent { public: \
explicit X (SCRef d) : BaseEvent(d, T) {} }
explicit X (SCRef ref) : BaseEvent(ref, T) {} }

DEF_EVENT(MessageEvent, QGit::MSG_EV);
DEF_EVENT(AnnotateProgressEvent, QGit::ANN_PRG_EV);
Expand Down
4 changes: 2 additions & 2 deletions src/consoleimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ bool ConsoleImpl::start(const QString& cmd) {
return !proc.isNull();
}

void ConsoleImpl::procReadyRead(const QByteArray& data) {
void ConsoleImpl::procReadyRead(const QByteArray& read) {

QString newParagraph;
if (QGit::stripPartialParaghraps(data, &newParagraph, &inpBuf))
if (QGit::stripPartialParaghraps(read, &newParagraph, &inpBuf))
// QTextEdit::append() adds a new paragraph,
// i.e. inserts a LF if not already present.
textEditOutput->append(newParagraph);
Expand Down
2 changes: 1 addition & 1 deletion src/consoleimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public slots:
void procFinished();

protected slots:
virtual void closeEvent(QCloseEvent* ce);
virtual void closeEvent(QCloseEvent* ce) override;
void pushButtonTerminate_clicked();
void pushButtonOk_clicked();

Expand Down
3 changes: 1 addition & 2 deletions src/customactionimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ void CustomActionImpl::loadAction(const QString& name) {
const QString flags(ACT_GROUP_KEY + name + ACT_FLAGS_KEY);
checkBoxRefreshAfterAction->setChecked(testFlag(ACT_REFRESH_F, flags));
QSettings set;
const QString& data(set.value(ACT_GROUP_KEY + name + ACT_TEXT_KEY, "").toString());
textEditAction->setPlainText(data);
textEditAction->setPlainText(set.value(ACT_GROUP_KEY + name + ACT_TEXT_KEY, "").toString());
}

void CustomActionImpl::removeAction(const QString& name) {
Expand Down
2 changes: 1 addition & 1 deletion src/customactionimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Q_OBJECT
void listChanged(const QStringList&);

protected slots:
virtual void closeEvent(QCloseEvent*);
virtual void closeEvent(QCloseEvent*) override;
void listWidgetNames_currentItemChanged(QListWidgetItem*, QListWidgetItem*);
void pushButtonNew_clicked();
void pushButtonRename_clicked();
Expand Down
2 changes: 1 addition & 1 deletion src/dataloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ void DataLoader::addSplittedChunks(const QByteArray* hc) {
}
// do not assume we have only one chunk in hc
int ofs = 0;
while (ofs != -1 && ofs != (int)hc->size())
while (ofs != -1 && ofs != static_cast<int>(hc->size()))
ofs = git->addChunk(fh, *hc, ofs);
}

Expand Down
16 changes: 12 additions & 4 deletions src/domain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ StateInfo& StateInfo::operator=(const StateInfo& newState) {
return *this;
}

StateInfo::StateInfo(const StateInfo& newState) {

isLocked = false;
curS = newState.curS; // prevS is mot modified to allow a rollback
}

bool StateInfo::operator==(const StateInfo& newState) const {

if (&newState == this)
Expand Down Expand Up @@ -217,13 +223,13 @@ bool Domain::event(QEvent* e) {
fromMaster = true;
// fall through
case UPD_DM_EV:
update(fromMaster, ((UpdateDomainEvent*)e)->isForced());
update(fromMaster, static_cast<UpdateDomainEvent *>(e)->isForced());
break;
case MSG_EV:
if (!busy && !st.requestPending())
QApplication::postEvent(m(), new MessageEvent(((MessageEvent*)e)->myData()));
QApplication::postEvent(m(), new MessageEvent(static_cast<MessageEvent *>(e)->myData()));
else // waiting for the end of updating
statusBarRequest = ((MessageEvent*)e)->myData();
statusBarRequest = static_cast<MessageEvent *>(e)->myData();
break;
default:
break;
Expand Down Expand Up @@ -275,7 +281,9 @@ void Domain::update(bool fromMaster, bool force) {
busy = false;
if (git->curContext() != this)
qDebug("ASSERT in Domain::update, context is %p "
"instead of %p", (void*)git->curContext(), (void*)this);
"instead of %p",
static_cast<void *>(git->curContext()),
static_cast<void *>(this));

git->setCurContext(NULL);
git->setThrowOnStop(false);
Expand Down
Loading