Reformat the code

This commit is contained in:
Anton Kochkov 2023-08-03 14:34:37 +08:00 committed by Anton Kochkov
parent 0d9851c1e0
commit 041118dbd7
21 changed files with 50 additions and 47 deletions

View File

@ -13,7 +13,7 @@
* @brief Attempt to connect to a parent console and configure outputs.
*/
#ifdef Q_OS_WIN
#include <windows.h>
# include <windows.h>
static void connectToConsole()
{
@ -67,9 +67,9 @@ int main(int argc, char *argv[])
#endif
QCoreApplication::setApplicationName("cutter");
// Importing settings after setting rename, needs separate handling in addition to regular version to version upgrade.
if (Cutter::shouldOfferSettingImport())
{
// Importing settings after setting rename, needs separate handling in addition to regular
// version to version upgrade.
if (Cutter::shouldOfferSettingImport()) {
Cutter::showSettingImportDialog(argc, argv);
}

View File

@ -16,8 +16,8 @@ static qreal GetDevicePixelRatio(qreal devicePixelRatio)
}
HighDpiPixmap::HighDpiPixmap(int width, int height, qreal devicePixelRatio)
: QPixmap(int(width *GetDevicePixelRatio(devicePixelRatio)),
int(height *GetDevicePixelRatio(devicePixelRatio)))
: QPixmap(int(width * GetDevicePixelRatio(devicePixelRatio)),
int(height * GetDevicePixelRatio(devicePixelRatio)))
{
setDevicePixelRatio(GetDevicePixelRatio(devicePixelRatio));
}

View File

@ -13,10 +13,10 @@
#ifdef CUTTER_ENABLE_PYTHON_BINDINGS
# include <shiboken.h>
# include <pyside.h>
#ifdef HAVE_PYSIDECLEANUP
// This header is introduced in PySide 6
# include <pysidecleanup.h>
#endif
# ifdef HAVE_PYSIDECLEANUP
// This header is introduced in PySide 6
# include <pysidecleanup.h>
# endif
# include <signalmanager.h>
#endif

View File

@ -7,7 +7,8 @@
namespace Cutter {
void initializeSettings();
/**
* @brief Check if Cutter should offer importing settings from version that can't be directly updated.
* @brief Check if Cutter should offer importing settings from version that can't be directly
* updated.
* @return True if this is first time running Cutter and r2 based Cutter <= 1.12 settings exist.
*/
bool shouldOfferSettingImport();

View File

@ -15,7 +15,6 @@
# undef max
#endif // Q_OS_WIN
// Global information for Cutter
#define APPNAME "Cutter"

View File

@ -1,2 +1 @@
#include "RizinCpp.h"

View File

@ -46,8 +46,7 @@ static inline auto fromOwned(RZ_OWN RzPVector *data)
return { data, {} };
}
static inline auto fromOwned(RZ_OWN RzList *data)
-> UniquePtrCP<decltype(data), &rz_list_free>
static inline auto fromOwned(RZ_OWN RzList *data) -> UniquePtrCP<decltype(data), &rz_list_free>
{
return { data, {} };
}

View File

@ -74,7 +74,7 @@ private:
QString fixedClass;
bool inputValid();
static QString convertRealNameToName(const QString& realName);
static QString convertRealNameToName(const QString &realName);
};
#endif // EDITMETHODDIALOG_H

View File

@ -49,8 +49,7 @@ void GlibcHeapBinsDialog::setChainInfo(int index)
RzHeapChunkListItem *item;
RzList *chunks = binsModel->getChunks(index);
QString chainInfo;
CutterRzListForeach(chunks, iter, RzHeapChunkListItem, item)
{
CutterRzListForeach (chunks, iter, RzHeapChunkListItem, item) {
chainInfo += "" + RzAddressString(item->addr);
}

View File

@ -287,7 +287,8 @@ void NewFileDialog::fillIOPluginsList()
{
ui->ioPlugin->clear();
ui->ioPlugin->addItem("file://");
ui->ioPlugin->setItemData(0, tr("Open a file without additional options/settings."), Qt::ToolTipRole);
ui->ioPlugin->setItemData(0, tr("Open a file without additional options/settings."),
Qt::ToolTipRole);
int index = 1;
QList<RzIOPluginDescription> ioPlugins = Core()->getRIOPluginDescriptions();

View File

@ -66,12 +66,14 @@ void TypesInteractionDialog::done(int r)
bool success;
if (!typeName.isEmpty()) {
success = rz_type_db_edit_base_type(
core->analysis->typedb, this->typeName.toUtf8().constData(),
ui->plainTextEdit->toPlainText().toUtf8().constData());
core->analysis->typedb, this->typeName.toUtf8().constData(),
ui->plainTextEdit->toPlainText().toUtf8().constData());
} else {
char *error_msg = NULL;
success = rz_type_parse_string_stateless(core->analysis->typedb->parser,
ui->plainTextEdit->toPlainText().toUtf8().constData(), &error_msg) == 0;
success = rz_type_parse_string_stateless(
core->analysis->typedb->parser,
ui->plainTextEdit->toPlainText().toUtf8().constData(), &error_msg)
== 0;
if (error_msg) {
RZ_LOG_ERROR("%s\n", error_msg);
rz_mem_free(error_msg);

View File

@ -22,8 +22,7 @@ void ColorThemeComboBox::updateFromConfig(bool interfaceThemeChanged)
clear();
for (const QString &theme : themes) {
if (ThemeWorker().isCustomTheme(theme)
|| !Configuration::relevantThemes[theme]
if (ThemeWorker().isCustomTheme(theme) || !Configuration::relevantThemes[theme]
|| (Configuration::cutterInterfaceThemesList()[curInterfaceThemeIndex].flag
& Configuration::relevantThemes[theme])) {
addItem(theme);

View File

@ -128,8 +128,8 @@ void ColorOptionDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o
painter->setPen(qApp->palette().text().color());
QFontMetrics fm2 = QFontMetrics(painter->font());
QString name = fm2.elidedText(optionInfoMap__[currCO.optionName].displayingtext,
Qt::ElideRight, optionNameRect.width());
QString name = fm2.elidedText(optionInfoMap__[currCO.optionName].displayingtext, Qt::ElideRight,
optionNameRect.width());
painter->drawText(optionNameRect, name);
QPainterPath roundedOptionRect;
@ -157,9 +157,9 @@ void ColorOptionDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o
painter->fillPath(roundedColorRect, currCO.color);
QFontMetrics fm3 = QFontMetrics(painter->font());
QString desc = fm3.elidedText(
currCO.optionName + ": " + optionInfoMap__[currCO.optionName].info, Qt::ElideRight,
descTextRect.width());
QString desc =
fm3.elidedText(currCO.optionName + ": " + optionInfoMap__[currCO.optionName].info,
Qt::ElideRight, descTextRect.width());
painter->setPen(qApp->palette().text().color());
painter->setBrush(qApp->palette().text());
painter->drawText(descTextRect, desc);

View File

@ -12,8 +12,7 @@ ComboQuickFilterView::ComboQuickFilterView(QWidget *parent)
connect(debounceTimer, &QTimer::timeout, this,
[this]() { emit filterTextChanged(ui->lineEdit->text()); });
connect(ui->lineEdit, &QLineEdit::textChanged, this,
[this]() { debounceTimer->start(150); });
connect(ui->lineEdit, &QLineEdit::textChanged, this, [this]() { debounceTimer->start(150); });
}
ComboQuickFilterView::~ComboQuickFilterView()

View File

@ -300,7 +300,7 @@ void DebugActions::onAttachedRemoteDebugger(bool successfully)
// TODO(#2829): Investigate why this is happening
if (remoteDialog == nullptr)
return;
if (!successfully) {
QMessageBox msgBox;
msgBox.setText(tr("Error connecting."));

View File

@ -234,9 +234,8 @@ QVariant FunctionModel::data(const QModelIndex &index, int role) const
QStringList summary {};
{
auto seeker = Core()->seekTemp(function.offset);
auto strings = fromOwnedCharPtr(
rz_core_print_disasm_strings(Core()->core(), RZ_CORE_DISASM_STRINGS_MODE_FUNCTION,
0, NULL));
auto strings = fromOwnedCharPtr(rz_core_print_disasm_strings(
Core()->core(), RZ_CORE_DISASM_STRINGS_MODE_FUNCTION, 0, NULL));
summary = strings.split('\n', CUTTER_QT_SKIP_EMPTY_PARTS);
}

View File

@ -36,8 +36,7 @@ void HeapBinsGraphView::loadCurrentGraph()
|| QString(heapBin->type) == QString("Tcache");
// store info about the chunks in a vector for easy access
CutterRzListForeach(heapBin->chunks, iter, RzHeapChunkListItem, item)
{
CutterRzListForeach (heapBin->chunks, iter, RzHeapChunkListItem, item) {
GraphHeapChunk graphHeapChunk;
graphHeapChunk.addr = item->addr;
RzHeapChunkSimple *chunkInfo = Core()->getHeapChunk(item->addr);

View File

@ -1407,8 +1407,8 @@ void HexWidget::w_writeRandom()
}
bool ok = false;
int nbytes = QInputDialog::getInt(this, tr("Write random bytes"), tr("Number of bytes:"), size, 1,
0x7FFFFFFF, 1, &ok);
int nbytes = QInputDialog::getInt(this, tr("Write random bytes"), tr("Number of bytes:"), size,
1, 0x7FFFFFFF, 1, &ok);
if (!ok) {
return;
}

View File

@ -248,19 +248,24 @@ void HexdumpWidget::updateParseWindow(RVA start_address, int size)
ut64 old_offset = core->offset;
rz_core_seek(core, start_address, true);
ut8 *block = core->block;
char *digest = rz_hash_cfg_calculate_small_block_string(core->hash, "md5", block, size, &digest_size, false);
char *digest = rz_hash_cfg_calculate_small_block_string(core->hash, "md5", block, size,
&digest_size, false);
ui->bytesMD5->setText(QString(digest));
free(digest);
digest = rz_hash_cfg_calculate_small_block_string(core->hash, "sha1", block, size, &digest_size, false);
digest = rz_hash_cfg_calculate_small_block_string(core->hash, "sha1", block, size,
&digest_size, false);
ui->bytesSHA1->setText(QString(digest));
free(digest);
digest = rz_hash_cfg_calculate_small_block_string(core->hash, "sha256", block, size, &digest_size, false);
digest = rz_hash_cfg_calculate_small_block_string(core->hash, "sha256", block, size,
&digest_size, false);
ui->bytesSHA256->setText(QString(digest));
free(digest);
digest = rz_hash_cfg_calculate_small_block_string(core->hash, "crc32", block, size, &digest_size, false);
digest = rz_hash_cfg_calculate_small_block_string(core->hash, "crc32", block, size,
&digest_size, false);
ui->bytesCRC32->setText(QString(digest));
free(digest);
digest = rz_hash_cfg_calculate_small_block_string(core->hash, "entropy", block, size, &digest_size, false);
digest = rz_hash_cfg_calculate_small_block_string(core->hash, "entropy", block, size,
&digest_size, false);
ui->bytesEntropy->setText(QString(digest));
free(digest);
rz_core_seek(core, old_offset, true);

View File

@ -55,7 +55,8 @@ public:
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
RVA address(const QModelIndex &index) const override;
QString name(const QModelIndex &index) const override;

View File

@ -140,7 +140,8 @@ void VisualNavbar::fetchStats()
if (to < from) {
return;
}
stats.reset(rz_core_analysis_get_stats(core, from, to, RZ_MAX(1, (to + 1 - from) / blocksCount)));
stats.reset(
rz_core_analysis_get_stats(core, from, to, RZ_MAX(1, (to + 1 - from) / blocksCount)));
}
enum class DataType : int { Empty, Code, String, Symbol, Count };