1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Scan-build cleanup

This commit is contained in:
tux3 2016-01-16 02:23:56 +01:00
parent a37f169386
commit c576a1485a
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
8 changed files with 19 additions and 17 deletions

View File

@ -167,13 +167,16 @@ void ChatLine::replaceContent(int col, ChatLineContent *lineContent)
void ChatLine::layout(qreal w, QPointF scenePos) void ChatLine::layout(qreal w, QPointF scenePos)
{ {
if (!content.size())
return;
width = w; width = w;
bbox.setTopLeft(scenePos); bbox.setTopLeft(scenePos);
qreal fixedWidth = (content.size()-1) * columnSpacing; qreal fixedWidth = (content.size()-1) * columnSpacing;
qreal varWidth = 0.0; // used for normalisation qreal varWidth = 0.0; // used for normalisation
for (int i = 0; i < static_cast<int>(format.size()); ++i) for (size_t i = 0; i < format.size(); ++i)
{ {
if (format[i].policy == ColumnFormat::FixedSize) if (format[i].policy == ColumnFormat::FixedSize)
fixedWidth += format[i].size; fixedWidth += format[i].size;
@ -190,8 +193,7 @@ void ChatLine::layout(qreal w, QPointF scenePos)
qreal xOffset = 0.0; qreal xOffset = 0.0;
qreal xPos[content.size()]; qreal xPos[content.size()];
for (size_t i = 0; i < content.size(); ++i)
for (int i = 0; i < static_cast<int>(content.size()); ++i)
{ {
// calculate the effective width of the current column // calculate the effective width of the current column
qreal width; qreal width;
@ -225,7 +227,7 @@ void ChatLine::layout(qreal w, QPointF scenePos)
maxVOffset = qMax(maxVOffset, content[i]->getAscent()); maxVOffset = qMax(maxVOffset, content[i]->getAscent());
} }
for (int i = 0; i < static_cast<int>(content.size()); ++i) for (size_t i = 0; i < content.size(); ++i)
{ {
// calculate vertical alignment // calculate vertical alignment
// vertical alignment may depend on width, so we do it in a second pass // vertical alignment may depend on width, so we do it in a second pass

View File

@ -973,20 +973,20 @@ QList<QString> Core::getGroupPeerNames(int groupId) const
{ {
QList<QString> names; QList<QString> names;
int nPeers = getGroupNumberPeers(groupId); int nPeers = getGroupNumberPeers(groupId);
if (nPeers == -1) if (nPeers < 0)
{ {
qWarning() << "getGroupPeerNames: Unable to get number of peers"; qWarning() << "getGroupPeerNames: Unable to get number of peers";
return names; return names;
} }
uint8_t namesArray[nPeers][TOX_MAX_NAME_LENGTH]; std::unique_ptr<uint8_t[][TOX_MAX_NAME_LENGTH]> namesArray{new uint8_t[nPeers][TOX_MAX_NAME_LENGTH]};
uint16_t* lengths = new uint16_t[nPeers]; std::unique_ptr<uint16_t[]> lengths{new uint16_t[nPeers]};
int result = tox_group_get_names(tox, groupId, namesArray, lengths, nPeers); int result = tox_group_get_names(tox, groupId, namesArray.get(), lengths.get(), nPeers);
if (result != nPeers) if (result != nPeers)
{ {
qWarning() << "getGroupPeerNames: Unexpected result"; qWarning() << "getGroupPeerNames: Unexpected result";
return names; return names;
} }
for (int i=0; i<nPeers; i++) for (size_t i=0; i<nPeers; i++)
names.push_back(CString::toString(namesArray[i], lengths[i])); names.push_back(CString::toString(namesArray[i], lengths[i]));
return names; return names;

View File

@ -102,7 +102,7 @@ QByteArray Core::getSaltFromFile(QString filename)
QByteArray data = file.read(TOX_PASS_ENCRYPTION_EXTRA_LENGTH); QByteArray data = file.read(TOX_PASS_ENCRYPTION_EXTRA_LENGTH);
file.close(); file.close();
uint8_t *salt = new uint8_t[TOX_PASS_SALT_LENGTH]; uint8_t salt[TOX_PASS_SALT_LENGTH];
if (!tox_get_salt(reinterpret_cast<uint8_t *>(data.data()), salt)) if (!tox_get_salt(reinterpret_cast<uint8_t *>(data.data()), salt))
{ {
qWarning() << "can't get salt from" << filename << "header"; qWarning() << "can't get salt from" << filename << "header";
@ -110,7 +110,6 @@ QByteArray Core::getSaltFromFile(QString filename)
} }
QByteArray res(reinterpret_cast<const char*>(salt), TOX_PASS_SALT_LENGTH); QByteArray res(reinterpret_cast<const char*>(salt), TOX_PASS_SALT_LENGTH);
delete[] salt;
return res; return res;
} }

View File

@ -122,6 +122,9 @@ QVector<VideoMode> v4l2::getDeviceModes(QString devName)
case V4L2_FRMSIZE_TYPE_STEPWISE: case V4L2_FRMSIZE_TYPE_STEPWISE:
mode.width = vfse.stepwise.max_width; mode.width = vfse.stepwise.max_width;
mode.height = vfse.stepwise.max_height; mode.height = vfse.stepwise.max_height;
break;
default:
continue;
} }
QVector<unsigned short> rates = getDeviceModeFramerates(fd, mode.width, mode.height, vfd.pixelformat); QVector<unsigned short> rates = getDeviceModeFramerates(fd, mode.width, mode.height, vfd.pixelformat);
for (unsigned short rate : rates) for (unsigned short rate : rates)

View File

@ -99,8 +99,7 @@ void AboutUser::onRemoveHistoryClicked()
History* history = Nexus::getProfile()->getHistory(); History* history = Nexus::getProfile()->getHistory();
if (history) if (history)
history->removeFriendHistory(toxId.publicKey); history->removeFriendHistory(toxId.publicKey);
QMessageBox::StandardButton reply; QMessageBox::information(this,
reply = QMessageBox::information(this,
tr("History removed"), tr("History removed"),
tr("Chat history with %1 removed!").arg(ui->userName->text().toHtmlEscaped()), tr("Chat history with %1 removed!").arg(ui->userName->text().toHtmlEscaped()),
QMessageBox::Ok); QMessageBox::Ok);

View File

@ -83,7 +83,7 @@ void GroupWidget::contextMenuEvent(QContextMenuEvent* event)
if (contentDialog == nullptr || notAlone) if (contentDialog == nullptr || notAlone)
openChatWindow = menu.addAction(tr("Open chat in new window")); openChatWindow = menu.addAction(tr("Open chat in new window"));
if (contentDialog->hasGroupWidget(groupId, this)) if (contentDialog && contentDialog->hasGroupWidget(groupId, this))
removeChatWindow = menu.addAction(tr("Remove chat from this window")); removeChatWindow = menu.addAction(tr("Remove chat from this window"));
menu.addSeparator(); menu.addSeparator();

View File

@ -116,7 +116,7 @@ void NotificationScrollArea::resizeEvent(QResizeEvent *event)
void NotificationScrollArea::findNextWidget() void NotificationScrollArea::findNextWidget()
{ {
int value; int value = 0;
GenericChatroomWidget* next = nullptr; GenericChatroomWidget* next = nullptr;
QHash<GenericChatroomWidget*, Visibility>::iterator i = trackedWidgets.begin(); QHash<GenericChatroomWidget*, Visibility>::iterator i = trackedWidgets.begin();
@ -151,7 +151,7 @@ void NotificationScrollArea::findNextWidget()
void NotificationScrollArea::findPreviousWidget() void NotificationScrollArea::findPreviousWidget()
{ {
int value; int value = 0;
GenericChatroomWidget* next = nullptr; GenericChatroomWidget* next = nullptr;
QHash<GenericChatroomWidget*, Visibility>::iterator i = trackedWidgets.begin(); QHash<GenericChatroomWidget*, Visibility>::iterator i = trackedWidgets.begin();

View File

@ -1486,7 +1486,6 @@ void Widget::onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t Cha
} }
else if (change == TOX_CHAT_CHANGE_PEER_NAME) // core overwrites old name before telling us it changed... else if (change == TOX_CHAT_CHANGE_PEER_NAME) // core overwrites old name before telling us it changed...
{ {
qDebug() << "UPDATING PEER";
g->updatePeer(peernumber, name); g->updatePeer(peernumber, name);
} }
} }