From: Soeren Apel Date: Mon, 6 Jan 2020 20:22:31 +0000 (+0100) Subject: clang-tidy and clazy proposals X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=feda6c6bbde575242cf01c769c0ecd3e89f9f7a0;p=pulseview.git clang-tidy and clazy proposals --- diff --git a/pv/data/decode/decoder.cpp b/pv/data/decode/decoder.cpp index 9792ace4..0f12fec8 100644 --- a/pv/data/decode/decoder.cpp +++ b/pv/data/decode/decoder.cpp @@ -69,7 +69,7 @@ Decoder::Decoder(const srd_decoder *const dec) : for (const GSList *rl = srd_decoder_->annotation_rows; rl; rl = rl->next) { const srd_decoder_annotation_row *const srd_row = (srd_decoder_annotation_row *)rl->data; assert(srd_row); - rows_.push_back({i++, this, srd_row}); + rows_.emplace_back(i++, this, srd_row); // FIXME PV can crash from .at() if a PD's ann classes are defined incorrectly for (const GSList *cl = srd_row->ann_classes; cl; cl = cl->next) @@ -78,7 +78,7 @@ Decoder::Decoder(const srd_decoder *const dec) : if (rows_.empty()) { // Make sure there is a row for PDs without row declarations - rows_.push_back({0, this}); + rows_.emplace_back(0, this); for (AnnotationClass& c : ann_classes_) c.row = &(rows_.back()); diff --git a/pv/data/decodesignal.cpp b/pv/data/decodesignal.cpp index 831c8e7f..ce38fbe3 100644 --- a/pv/data/decodesignal.cpp +++ b/pv/data/decodesignal.cpp @@ -35,7 +35,6 @@ using std::forward_list; using std::lock_guard; -using std::make_pair; using std::make_shared; using std::min; using std::out_of_range; @@ -1363,7 +1362,7 @@ void DecodeSignal::create_decode_segment() segments_.emplace_back(DecodeSegment()); // Add annotation classes - for (const shared_ptr dec : stack_) + for (const shared_ptr& dec : stack_) for (Row* row : dec->get_rows()) segments_.back().annotation_rows.emplace(row, RowData(row)); diff --git a/pv/data/decodesignal.hpp b/pv/data/decodesignal.hpp index f8994adb..c59b20b8 100644 --- a/pv/data/decodesignal.hpp +++ b/pv/data/decodesignal.hpp @@ -42,7 +42,6 @@ using std::condition_variable; using std::deque; using std::map; using std::mutex; -using std::pair; using std::vector; using std::shared_ptr; diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 2823adc0..799f10d4 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -146,7 +146,7 @@ shared_ptr MainWindow::add_view(views::ViewType type, // Only use the view type in the name if it's not the main view QString title; if (main_bar) - title = QString("%1 (%2)").arg(session.name()).arg(views::ViewTypeNames[type]); + title = QString("%1 (%2)").arg(session.name(), views::ViewTypeNames[type]); else title = session.name(); diff --git a/pv/views/decoder_output/QHexView.hpp b/pv/views/decoder_output/QHexView.hpp index 71b06cdd..e3c182a7 100644 --- a/pv/views/decoder_output/QHexView.hpp +++ b/pv/views/decoder_output/QHexView.hpp @@ -50,7 +50,7 @@ public: }; public: - QHexView(QWidget *parent = 0); + QHexView(QWidget *parent = nullptr); void set_mode(Mode m); void set_data(const DecodeBinaryClass* data); diff --git a/pv/views/decoder_output/view.cpp b/pv/views/decoder_output/view.cpp index 325fa716..f22f6c5d 100644 --- a/pv/views/decoder_output/view.cpp +++ b/pv/views/decoder_output/view.cpp @@ -41,11 +41,8 @@ using pv::data::DecodeSignal; using pv::data::SignalBase; using pv::data::decode::Decoder; -using pv::util::TimeUnit; using pv::util::Timestamp; -using std::dynamic_pointer_cast; -using std::numeric_limits; using std::shared_ptr; namespace pv { @@ -135,10 +132,6 @@ View::View(Session &session, bool is_main_view, QMainWindow *parent) : reset_view_state(); } -View::~View() -{ -} - ViewType View::get_type() const { return ViewTypeDecoderOutput; diff --git a/pv/views/decoder_output/view.hpp b/pv/views/decoder_output/view.hpp index a6362ede..16d35e82 100644 --- a/pv/views/decoder_output/view.hpp +++ b/pv/views/decoder_output/view.hpp @@ -57,8 +57,6 @@ class View : public ViewBase public: explicit View(Session &session, bool is_main_view=false, QMainWindow *parent = nullptr); - ~View(); - virtual ViewType get_type() const; /** diff --git a/pv/views/trace/decodetrace.cpp b/pv/views/trace/decodetrace.cpp index f9b7158e..bb0843a5 100644 --- a/pv/views/trace/decodetrace.cpp +++ b/pv/views/trace/decodetrace.cpp @@ -67,7 +67,6 @@ using std::make_pair; using std::max; using std::min; using std::numeric_limits; -using std::out_of_range; using std::pair; using std::shared_ptr; using std::tie; diff --git a/pv/views/trace/view.cpp b/pv/views/trace/view.cpp index ea1c290c..7a68c6e9 100644 --- a/pv/views/trace/view.cpp +++ b/pv/views/trace/view.cpp @@ -307,7 +307,7 @@ shared_ptr View::get_signal_by_signalbase(shared_ptr b { shared_ptr ret_val; - for (const shared_ptr s : signals_) + for (const shared_ptr& s : signals_) if (s->base() == base) { ret_val = s; break; diff --git a/pv/widgets/flowlayout.cpp b/pv/widgets/flowlayout.cpp index 31ba7fed..74c5036d 100644 --- a/pv/widgets/flowlayout.cpp +++ b/pv/widgets/flowlayout.cpp @@ -102,7 +102,7 @@ QLayoutItem *FlowLayout::takeAt(int index) if ((index >= 0) && (index < itemList.size())) return itemList.takeAt(index); else - return 0; + return nullptr; } Qt::Orientations FlowLayout::expandingDirections() const @@ -206,7 +206,7 @@ int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const if (parent->isWidgetType()) { QWidget *pw = qobject_cast(parent); - return pw->style()->pixelMetric(pm, 0, pw); + return pw->style()->pixelMetric(pm, nullptr, pw); } else return static_cast(parent)->spacing(); }