From a503e6404eeed99e249e4c8c7fd4e15e24468286 Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Thu, 29 Jun 2023 14:49:45 +0800 Subject: [PATCH] Disable many warning messages --- CMakeLists.txt | 1 - DSView/main.cpp | 6 ++ DSView/pv/appcontrol.cpp | 2 +- DSView/pv/config/appconfig.cpp | 2 + DSView/pv/data/decode/annotation.cpp | 7 +- DSView/pv/data/decode/annotation.h | 4 - DSView/pv/data/decode/annotationrestable.cpp | 8 +- DSView/pv/data/decode/row.cpp | 7 ++ DSView/pv/data/decode/row.h | 2 + DSView/pv/data/decoderstack.cpp | 13 ++- DSView/pv/data/dsosnapshot.cpp | 8 +- DSView/pv/data/logicsnapshot.cpp | 8 +- DSView/pv/dialogs/applicationpardlg.cpp | 3 +- DSView/pv/dialogs/decoderoptionsdlg.cpp | 5 +- DSView/pv/dialogs/deviceoptions.cpp | 9 +- DSView/pv/dialogs/protocolexp.cpp | 4 +- DSView/pv/dock/dsotriggerdock.cpp | 6 +- DSView/pv/dock/measuredock.cpp | 10 +-- DSView/pv/dock/protocoldock.cpp | 6 +- DSView/pv/dock/searchcombobox.cpp | 4 + DSView/pv/dock/triggerdock.cpp | 2 +- DSView/pv/mainwindow.cpp | 6 +- DSView/pv/prop/binding/deviceoptions.cpp | 11 +-- DSView/pv/sigsession.cpp | 2 +- DSView/pv/sigsession.h | 2 +- DSView/pv/storesession.cpp | 14 +-- DSView/pv/toolbars/samplingbar.cpp | 2 - DSView/pv/toolbars/samplingbar.h | 16 ++-- DSView/pv/view/decodetrace.cpp | 2 + DSView/pv/view/devmode.cpp | 6 -- DSView/pv/view/dsldial.cpp | 9 +- DSView/pv/view/dsosignal.cpp | 12 +-- DSView/pv/view/dsosignal.h | 3 - DSView/pv/view/groupsignal.cpp | 3 + DSView/pv/view/groupsignal.h | 12 +-- DSView/pv/view/viewport.cpp | 2 - DSView/pv/widgets/decodergroupbox.cpp | 6 +- common/ds_types.h | 35 ++++++++ libsigrok4DSL/hardware/DSL/dscope.c | 21 ++--- libsigrok4DSL/hardware/DSL/dsl.c | 39 +++----- libsigrok4DSL/hardware/DSL/dsl.h | 2 +- libsigrok4DSL/hardware/DSL/dslogic.c | 35 +++----- libsigrok4DSL/hardware/demo/demo.c | 84 ++++++++--------- libsigrok4DSL/hardware/demo/demo.h | 6 -- libsigrok4DSL/hwdriver.c | 12 +-- libsigrok4DSL/input/in_vcd.c | 8 +- libsigrok4DSL/lib_main.c | 94 ++++++++++++-------- libsigrok4DSL/libsigrok-internal.h | 7 +- libsigrok4DSL/libsigrok.h | 6 +- libsigrok4DSL/output/gnuplot.c | 2 +- libsigrok4DSL/output/output.c | 4 +- libsigrok4DSL/output/srzip.c | 14 +-- libsigrok4DSL/session.c | 7 +- libsigrok4DSL/session_driver.c | 35 ++++---- libsigrok4DSL/strutil.c | 62 ++++++------- libsigrok4DSL/tests/lib.c | 4 +- libsigrok4DSL/trigger.c | 6 ++ libsigrokdecode4DSL/decoder.c | 9 +- libsigrokdecode4DSL/type_decoder.c | 23 +++-- 59 files changed, 358 insertions(+), 382 deletions(-) create mode 100644 common/ds_types.h diff --git a/CMakeLists.txt b/CMakeLists.txt index f3b1c926..2b882e3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -270,7 +270,6 @@ set(DSView_SOURCES DSView/pv/dock/measuredock.cpp DSView/pv/dock/searchdock.cpp DSView/pv/toolbars/logobar.cpp - DSView/pv/view/groupsignal.cpp DSView/pv/dialogs/about.cpp DSView/pv/dialogs/search.cpp DSView/pv/data/dsosnapshot.cpp diff --git a/DSView/main.cpp b/DSView/main.cpp index 13b8f20d..faad0d9e 100644 --- a/DSView/main.cpp +++ b/DSView/main.cpp @@ -215,6 +215,12 @@ bool bHighScale = true; QDateTime dateTime = QDateTime::currentDateTime(); std::string strTime = dateTime .toString("yyyy-MM-dd hh:mm:ss").toStdString(); dsv_info("%s", strTime.c_str()); + + int bit_width = sizeof(long); + if (bit_width != 8){ + dsv_err("Can only run on 64 bit systems"); + return 0; + } //init core if (!control->Init()){ diff --git a/DSView/pv/appcontrol.cpp b/DSView/pv/appcontrol.cpp index eb40ad33..0e1fec53 100644 --- a/DSView/pv/appcontrol.cpp +++ b/DSView/pv/appcontrol.cpp @@ -48,7 +48,7 @@ AppControl::AppControl(AppControl &o) AppControl::~AppControl() { - DESTROY_OBJECT(_session); + // DESTROY_OBJECT(_session); } AppControl* AppControl::Instance() diff --git a/DSView/pv/config/appconfig.cpp b/DSView/pv/config/appconfig.cpp index de5bd99b..99141b89 100644 --- a/DSView/pv/config/appconfig.cpp +++ b/DSView/pv/config/appconfig.cpp @@ -253,6 +253,7 @@ static void _saveHistory(UserHistory &o, QSettings &st) st.endGroup(); } +/* //------font static void _loadFont(FontOptions &o, QSettings &st) { @@ -291,6 +292,7 @@ static void _saveFont(FontOptions &o, QSettings &st) st.endGroup(); } +*/ //------------AppConfig diff --git a/DSView/pv/data/decode/annotation.cpp b/DSView/pv/data/decode/annotation.cpp index cf2ca6dc..8574136d 100644 --- a/DSView/pv/data/decode/annotation.cpp +++ b/DSView/pv/data/decode/annotation.cpp @@ -109,14 +109,9 @@ Annotation::Annotation() _end_sample = 0; _resIndex = -1; } - -Annotation::Annotation(Annotation &o) -{ -} Annotation::~Annotation() -{ - +{ } const std::vector& Annotation::annotations() const diff --git a/DSView/pv/data/decode/annotation.h b/DSView/pv/data/decode/annotation.h index 2037d283..a5b0e440 100644 --- a/DSView/pv/data/decode/annotation.h +++ b/DSView/pv/data/decode/annotation.h @@ -45,10 +45,6 @@ public: Annotation(); ~Annotation(); -private: - /* disable copy construct */ - Annotation(Annotation &o); - public: inline uint64_t start_sample() const{ return _start_sample; diff --git a/DSView/pv/data/decode/annotationrestable.cpp b/DSView/pv/data/decode/annotationrestable.cpp index e4698ec9..6f2ec96a 100644 --- a/DSView/pv/data/decode/annotationrestable.cpp +++ b/DSView/pv/data/decode/annotationrestable.cpp @@ -285,7 +285,7 @@ const char* AnnotationResTable::format_numberic(const char *hex_str, int fmt) if (sub_wr != sub_buf){ *sub_wr = 0; const char *sub_str = format_to_string(sub_buf, fmt); - int sublen = strlen(sub_str); + unsigned int sublen = (unsigned int)strlen(sub_str); if ((all_wr - all_buf) + sublen > CONVERT_STR_MAX_LEN){ printf("convert error,write buffer is full!\n"); @@ -312,12 +312,12 @@ const char* AnnotationResTable::format_numberic(const char *hex_str, int fmt) { *sub_wr = 0; const char *sub_str = format_to_string(sub_buf, fmt); - int sublen = strlen(sub_str); + unsigned int sublen = (unsigned int)strlen(sub_str); if ((all_wr - all_buf) + sublen > CONVERT_STR_MAX_LEN) { - printf("convert error,write buffer is full!\n"); - return hex_str; + printf("convert error,write buffer is full!\n"); + return hex_str; } strncpy(all_wr, sub_str, sublen); diff --git a/DSView/pv/data/decode/row.cpp b/DSView/pv/data/decode/row.cpp index a1e7d8b0..13f24191 100644 --- a/DSView/pv/data/decode/row.cpp +++ b/DSView/pv/data/decode/row.cpp @@ -49,6 +49,13 @@ Row::Row(const Row &o) _order = o._order; } +bool Row::operator=(const Row &o) +{ + _decoder = o._decoder; + _row = o._row; + _order = o._order; +} + QString Row::title() const { if (_decoder && _decoder->name && _row && _row->desc) diff --git a/DSView/pv/data/decode/row.h b/DSView/pv/data/decode/row.h index 323c865b..ce236908 100644 --- a/DSView/pv/data/decode/row.h +++ b/DSView/pv/data/decode/row.h @@ -45,6 +45,8 @@ public: Row(const Row &o); + bool operator=(const Row &o); + public: inline const srd_decoder* decoder() const{ diff --git a/DSView/pv/data/decoderstack.cpp b/DSView/pv/data/decoderstack.cpp index 8f03933b..c1bd4169 100644 --- a/DSView/pv/data/decoderstack.cpp +++ b/DSView/pv/data/decoderstack.cpp @@ -200,10 +200,9 @@ void DecoderStack::build_row() } // Map out all the classes - for (const GSList *ll = ann_row->ann_classes; - ll; ll = ll->next) - _class_rows[make_pair(decc, - GPOINTER_TO_INT(ll->data))] = row; + for (const GSList *ll = ann_row->ann_classes; ll; ll = ll->next){ + _class_rows[make_pair(decc, GPOINTER_TO_INT(ll->data))] = Row(row); + } order++; } @@ -552,7 +551,7 @@ void DecoderStack::decode_data(const uint64_t decode_start, const uint64_t decod if (end_index >= align_sample_count){ end_index = align_sample_count - 1; - dsv_info("Reset the decode end sample, new:%llu, old:%llu", end_index, decode_end); + dsv_info("Reset the decode end sample, new:%lu, old:%lu", end_index, decode_end); } } } @@ -661,7 +660,7 @@ void DecoderStack::decode_data(const uint64_t decode_start, const uint64_t decod } } - dsv_info("%s%llu", "send to decoder times: ", entry_cnt); + dsv_info("%s%lu", "send to decoder times: ", entry_cnt); if (error != NULL) g_free(error); @@ -717,7 +716,7 @@ void DecoderStack::execute_decode_stack() decode_end = max(dec->decode_end(), decode_end); } - dsv_info("decoder start sample:%llu, end sample:%llu, count:%llu", decode_start, decode_end, decode_end - decode_start + 1); + dsv_info("decoder start sample:%lu, end sample:%lu, count:%lu", decode_start, decode_end, decode_end - decode_start + 1); // Start the session srd_session_metadata_set(session, SRD_CONF_SAMPLERATE, diff --git a/DSView/pv/data/dsosnapshot.cpp b/DSView/pv/data/dsosnapshot.cpp index 69ad0bee..71120de5 100644 --- a/DSView/pv/data/dsosnapshot.cpp +++ b/DSView/pv/data/dsosnapshot.cpp @@ -215,8 +215,6 @@ void DsoSnapshot::append_payload(const sr_datafeed_dso &dso) { std::lock_guard lock(_mutex); - //dsv_info("write sample_count:%llu", dso.num_samples); - if (_channel_num > 0 && dso.num_samples > 0) { append_data(dso.data, dso.num_samples, _instant); @@ -241,7 +239,7 @@ void DsoSnapshot::append_data(void *data, uint64_t samples, bool instant) assert(_sample_count <= _total_sample_count); - for (int ch = 0; ch < _channel_num; ch++) + for (unsigned int ch = 0; ch < _channel_num; ch++) { uint8_t *src = (uint8_t*)data + ch; uint8_t *dest = _ch_data[ch]; @@ -250,7 +248,7 @@ void DsoSnapshot::append_data(void *data, uint64_t samples, bool instant) dest += old_sample_count; } - for (int i = 0; i < samples; i++) + for (uint64_t i = 0; i < samples; i++) { *dest++ = *src; src += _channel_num; @@ -511,7 +509,7 @@ bool DsoSnapshot::get_max_min_value(uint8_t &maxv, uint8_t &minv, int chan_index return false; } - if (chan_index < 0 || chan_index >= _ch_data.size()){ + if (chan_index < 0 || chan_index >= (int)_ch_data.size()){ assert(false); } diff --git a/DSView/pv/data/logicsnapshot.cpp b/DSView/pv/data/logicsnapshot.cpp index 435c0773..e4e5d35d 100644 --- a/DSView/pv/data/logicsnapshot.cpp +++ b/DSView/pv/data/logicsnapshot.cpp @@ -454,7 +454,7 @@ void LogicSnapshot::capture_ended() if (offset > 0) { - for (int chan=0; chan<_channel_num; chan++) + for (unsigned int chan=0; chan<_channel_num; chan++) { if (_ch_data[chan][index0].lbp[index1] == NULL){ dsv_err("ERROR:LogicSnapshot::capture_ended(),buffer is null."); @@ -763,7 +763,7 @@ bool LogicSnapshot::get_nxt_edge_self(uint64_t &index, bool last_sample, uint64_ bool edge_hit = false; // linear search for the next transition on the root level - for (int64_t i = root_index; !edge_hit && (index <= end) && i < (int64_t)_ch_data[order].size(); i++) + for (uint64_t i = root_index; !edge_hit && (index <= end) && i < (uint64_t)_ch_data[order].size(); i++) { uint64_t cur_mask = (~0ULL << root_pos); @@ -1423,7 +1423,7 @@ void LogicSnapshot::move_first_node_to_last() struct RootNode rn = _ch_data[i][0]; _ch_data[i].erase(_ch_data[i].begin()); - for (int x=0; x 0); for (int i = 0; i < (int)_channel_num; i++) diff --git a/DSView/pv/dialogs/applicationpardlg.cpp b/DSView/pv/dialogs/applicationpardlg.cpp index abd3621e..d2cc9fe7 100644 --- a/DSView/pv/dialogs/applicationpardlg.cpp +++ b/DSView/pv/dialogs/applicationpardlg.cpp @@ -110,8 +110,7 @@ bool ApplicationParamDlg::ShowDlg(QWidget *parent) lay->setSpacing(8); //show config - AppConfig &app = AppConfig::Instance(); - int mode = AppControl::Instance()->GetSession()->get_device()->get_work_mode(); + AppConfig &app = AppConfig::Instance(); QCheckBox *ck_quickScroll = new QCheckBox(); ck_quickScroll->setChecked(app.appOptions.quickScroll); diff --git a/DSView/pv/dialogs/decoderoptionsdlg.cpp b/DSView/pv/dialogs/decoderoptionsdlg.cpp index 133eed39..127a8a29 100644 --- a/DSView/pv/dialogs/decoderoptionsdlg.cpp +++ b/DSView/pv/dialogs/decoderoptionsdlg.cpp @@ -477,10 +477,11 @@ void DecoderOptionsDlg::create_decoder_form( decoder_form, parent, font); - if (group->_content_width > _content_width) + if (group->_content_width > _content_width){ _content_width = group->_content_width; + } - form->addRow(group); + form->addRow(group); } void DecoderOptionsDlg::commit_probes() diff --git a/DSView/pv/dialogs/deviceoptions.cpp b/DSView/pv/dialogs/deviceoptions.cpp index 86eca57f..0e2f923e 100644 --- a/DSView/pv/dialogs/deviceoptions.cpp +++ b/DSView/pv/dialogs/deviceoptions.cpp @@ -176,8 +176,10 @@ DeviceOptions::~DeviceOptions() void DeviceOptions::ChannelChecked(int index, QObject *object) { - QCheckBox* sc = dynamic_cast(object); - channel_checkbox_clicked(sc); + (void)index; + + QCheckBox* sc = dynamic_cast(object); + channel_checkbox_clicked(sc); } void DeviceOptions::accept() @@ -607,7 +609,6 @@ void DeviceOptions::channel_checkbox_clicked(QCheckBox *sc) if (sc != NULL) { QGridLayout *const layout = (QGridLayout *)sc->property("Layout").value(); int i = layout->count(); - bool bMap = false; int ck_index = -1; int i_dex = 0; @@ -633,7 +634,7 @@ void DeviceOptions::channel_checkbox_clicked(QCheckBox *sc) if (w->objectName() == "map-enable"){ QCheckBox *map_ckbox = dynamic_cast(w); - bMap = map_ckbox->isChecked(); + map_ckbox->isChecked(); } if (w->property("Enable").isNull()) { diff --git a/DSView/pv/dialogs/protocolexp.cpp b/DSView/pv/dialogs/protocolexp.cpp index 6fdebac9..80a9e784 100644 --- a/DSView/pv/dialogs/protocolexp.cpp +++ b/DSView/pv/dialogs/protocolexp.cpp @@ -221,8 +221,8 @@ void ProtocolExp::save_proc() if ((*i).second) { if (index == row_index) - { - row = (*i).first; + { + row = Row((*i).first); break; } row_index++; diff --git a/DSView/pv/dock/dsotriggerdock.cpp b/DSView/pv/dock/dsotriggerdock.cpp index 6fe99753..ed4fd478 100644 --- a/DSView/pv/dock/dsotriggerdock.cpp +++ b/DSView/pv/dock/dsotriggerdock.cpp @@ -212,11 +212,7 @@ void DsoTriggerDock::reStyle() void DsoTriggerDock::paintEvent(QPaintEvent *e) { - (void*)e; -// QStyleOption opt; -// opt.init(this); -// QPainter p(this); -// style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); + (void)e; } void DsoTriggerDock::auto_trig(int index) diff --git a/DSView/pv/dock/measuredock.cpp b/DSView/pv/dock/measuredock.cpp index d05d2d55..016bd99e 100644 --- a/DSView/pv/dock/measuredock.cpp +++ b/DSView/pv/dock/measuredock.cpp @@ -586,7 +586,7 @@ void MeasureDock::update_dist() for (auto &inf : _dist_row_list) { if (inf.cursor1 != -1) { - if (inf.cursor1 > cursor_list.size()) { + if (inf.cursor1 > (int)cursor_list.size()) { inf.start_bt->setText(""); set_cursor_btn_color(inf.start_bt); inf.cursor1 = -1; @@ -594,7 +594,7 @@ void MeasureDock::update_dist() } if (inf.cursor2 != -1) { - if (inf.cursor2 > cursor_list.size()) { + if (inf.cursor2 > (int)cursor_list.size()) { inf.end_bt->setText(""); set_cursor_btn_color(inf.end_bt); inf.cursor2 = -1; @@ -623,14 +623,14 @@ void MeasureDock::update_edge() for (auto &inf : _edge_row_list) { if (inf.cursor1 != -1) { - if (inf.cursor1 > cursor_list.size()) { + if (inf.cursor1 > (int)cursor_list.size()) { inf.start_bt->setText(""); set_cursor_btn_color(inf.start_bt); inf.cursor1 = -1; } } if (inf.cursor2 != -1) { - if (inf.cursor2 > cursor_list.size()) { + if (inf.cursor2 > (int)cursor_list.size()) { inf.end_bt->setText(""); set_cursor_btn_color(inf.end_bt); inf.cursor2 = -1; @@ -642,8 +642,6 @@ void MeasureDock::update_edge() uint64_t rising_edges; uint64_t falling_edges; - const auto &sigs = _session->get_signals(); - for(auto s : _session->get_signals()) { if (s->signal_type() == SR_CHANNEL_LOGIC && s->enabled() diff --git a/DSView/pv/dock/protocoldock.cpp b/DSView/pv/dock/protocoldock.cpp index 07878f6c..eeb58903 100644 --- a/DSView/pv/dock/protocoldock.cpp +++ b/DSView/pv/dock/protocoldock.cpp @@ -454,7 +454,7 @@ void ProtocolDock::del_all_protocol() void ProtocolDock::decoded_progress(int progress) { const auto &decode_sigs = _session->get_decode_signals(); - int index = 0; + unsigned int index = 0; for(auto d : decode_sigs) { int pg = d->get_progress(); @@ -933,7 +933,7 @@ bool ProtocolDock::protocol_sort_callback(const DecoderInfoItem *o1, const Decod strncpy(buf, id, sizeof(buf)-1); char *rd = buf; char *start = NULL; - int len = 0; + unsigned int len = 0; while (*rd && len - 1 < sizeof(buf)) { @@ -1004,6 +1004,8 @@ bool ProtocolDock::protocol_sort_callback(const DecoderInfoItem *o1, const Decod void ProtocolDock::OnItemClick(void *sender, void *data_handle) { + (void)sender; + if (data_handle != NULL){ DecoderInfoItem *info = (DecoderInfoItem*)data_handle; srd_decoder *dec = (srd_decoder *)(info->_data_handle); diff --git a/DSView/pv/dock/searchcombobox.cpp b/DSView/pv/dock/searchcombobox.cpp index 5f50e7f4..5aa7fb38 100644 --- a/DSView/pv/dock/searchcombobox.cpp +++ b/DSView/pv/dock/searchcombobox.cpp @@ -40,6 +40,8 @@ ComboButtonItem::ComboButtonItem(QWidget *parent, ISearchItemClick *click, void void ComboButtonItem::mousePressEvent(QMouseEvent *e) { + (void)e; + if (_click != NULL){ _click->OnItemClick(this, _data_handle); } @@ -165,6 +167,8 @@ void SearchComboBox::AddDataItem(QString id, QString name, void *data_handle) void SearchComboBox::OnItemClick(void *sender, void *data_handle) { + (void)sender; + if (data_handle != NULL && _item_click){ SearchDataItem *item = (SearchDataItem*)data_handle; this->close(); diff --git a/DSView/pv/dock/triggerdock.cpp b/DSView/pv/dock/triggerdock.cpp index 3e238bf1..6a9b29c1 100644 --- a/DSView/pv/dock/triggerdock.cpp +++ b/DSView/pv/dock/triggerdock.cpp @@ -1031,7 +1031,7 @@ void TriggerDock::on_serial_value_changed(const QString &v) } char tmp[10]; - sprintf(tmp, "%02X", val); + sprintf(tmp, "%02lX", val); _serial_hex_lineEdit->setText(QString(tmp)); } } diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp index dca9918b..63e12660 100644 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -374,7 +374,6 @@ namespace pv QString title; QString details; QString ch_status = ""; - uint64_t error_pattern; switch (_session->get_error()) { @@ -533,6 +532,11 @@ namespace pv int w = parentWidget()->frameGeometry().width(); int h = parentWidget()->frameGeometry().height(); + (void)h; + (void)w; + (void)x; + (void)y; + QDesktopWidget *desktop = QApplication::desktop(); int curMonitor = desktop->screenNumber(this); diff --git a/DSView/pv/prop/binding/deviceoptions.cpp b/DSView/pv/prop/binding/deviceoptions.cpp index b1cb5078..4fe6b22e 100644 --- a/DSView/pv/prop/binding/deviceoptions.cpp +++ b/DSView/pv/prop/binding/deviceoptions.cpp @@ -71,7 +71,7 @@ DeviceOptions::DeviceOptions() gvar_list = _device_agent->get_config_list(NULL, key); const QString name(info->name); - char *label_char = info->name; + const char *label_char = info->name; QString label(label_char); switch(key) @@ -306,8 +306,9 @@ QString DeviceOptions::print_vdiv(GVariant *const gvar) void DeviceOptions::bind_bandwidths(const QString &name, const QString label, int key, GVariant *const gvar_list, boost::function printer) { - bool bw_limit; - GVariant *gvar_tmp; + (void)printer; + + bool bw_limit = false; GVariant *gvar; std::vector< pair > values; struct sr_list_item *plist; @@ -316,11 +317,11 @@ void DeviceOptions::bind_bandwidths(const QString &name, const QString label, in plist = (struct sr_list_item*)g_variant_get_uint64(gvar_list); assert(plist); - bw_limit = false; _device_agent->get_config_bool(SR_CONF_BANDWIDTH, bw_limit); - if (!bw_limit) + if (bw_limit == false){ return; + } while (plist && plist->id >= 0) { diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index 1e67bbe2..1c7e4e40 100644 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -1027,7 +1027,7 @@ namespace pv make_channels_view_index(start_view_dex); if (_device_agent.get_work_mode() == LOGIC){ - for (int i=0; iset_view_index(view_indexs[i]); } } diff --git a/DSView/pv/sigsession.h b/DSView/pv/sigsession.h index b07483d3..cec63819 100644 --- a/DSView/pv/sigsession.h +++ b/DSView/pv/sigsession.h @@ -181,7 +181,7 @@ public: inline bool re_start(){ if (_is_working) stop_capture(); - start_capture(_is_instant); + return start_capture(_is_instant); } inline QDateTime get_session_time(){ diff --git a/DSView/pv/storesession.cpp b/DSView/pv/storesession.cpp index 1cace161..7a0c1ed1 100644 --- a/DSView/pv/storesession.cpp +++ b/DSView/pv/storesession.cpp @@ -226,15 +226,6 @@ void StoreSession::save_logic(pv::data::LogicSnapshot *logic_snapshot) _unit_count = logic_snapshot->get_ring_sample_count() / 8 * to_save_probes; num = logic_snapshot->get_block_num(); - /* - dsv_info("total-bytes:%llu, total-sample:%llu, loop-offset:%llu, blocks:%d", - _unit_count, - logic_snapshot->get_ring_sample_count(), - logic_snapshot->get_loop_offset(), - num - ); - */ - for(auto s : _session->get_signals()) { int ch_type = s->get_type(); @@ -275,8 +266,6 @@ void StoreSession::save_logic(pv::data::LogicSnapshot *logic_snapshot) } _units_stored += size; - //dsv_info("read-bytes:%llu, block-size:%llu, block-index:%d-%d", _units_stored, size, ch_index, i); - if (_units_stored > _unit_count){ dsv_err("Read block data error!"); assert(false); @@ -308,7 +297,7 @@ void StoreSession::save_logic(pv::data::LogicSnapshot *logic_snapshot) void StoreSession::save_analog(pv::data::AnalogSnapshot *analog_snapshot) { char chunk_name[20] = {0}; - int num; + int num = 0; int ret = SR_ERR; int ch_type = -1; @@ -476,7 +465,6 @@ bool StoreSession::meta_gen(data::Snapshot *snapshot, std::string &str) int probecnt; char *s; struct sr_status status; - const sr_dev_inst *sdi = NULL; char meta[300] = {0}; sprintf(meta, "%s", "[version]\n"); str += meta; diff --git a/DSView/pv/toolbars/samplingbar.cpp b/DSView/pv/toolbars/samplingbar.cpp index 7be29bcb..d525f342 100644 --- a/DSView/pv/toolbars/samplingbar.cpp +++ b/DSView/pv/toolbars/samplingbar.cpp @@ -632,7 +632,6 @@ namespace pv if (_updating_sample_count) return; - GVariant *gvar; double duration; uint64_t v; @@ -730,7 +729,6 @@ namespace pv .value(); const uint64_t sample_limit = _device_agent->get_sample_limit(); - GVariant *gvar; uint64_t max_sample_rate; if (_device_agent->get_config_uint64(SR_CONF_MAX_DSO_SAMPLERATE, max_sample_rate) == false) diff --git a/DSView/pv/toolbars/samplingbar.h b/DSView/pv/toolbars/samplingbar.h index 01b5b02e..2b9441cf 100644 --- a/DSView/pv/toolbars/samplingbar.h +++ b/DSView/pv/toolbars/samplingbar.h @@ -141,15 +141,11 @@ namespace pv private: SigSession *_session; - DsComboBox _device_selector; - DsComboBox _sample_count; - DsComboBox _sample_rate; - bool _updating_sample_rate; - bool _updating_sample_count; - bool _updating_device_list; - QToolButton _device_type; - QToolButton _configure_button; + DsComboBox _device_selector; + QToolButton _configure_button; + DsComboBox _sample_count; + DsComboBox _sample_rate; QToolButton _run_stop_button; QToolButton _instant_button; QToolButton _mode_button; @@ -169,6 +165,10 @@ namespace pv int _last_device_index; bool _is_run_as_instant; view::View *_view; + + bool _updating_sample_rate; + bool _updating_sample_count; + bool _updating_device_list; }; } // namespace toolbars diff --git a/DSView/pv/view/decodetrace.cpp b/DSView/pv/view/decodetrace.cpp index f1c2d10b..1b1e47cb 100644 --- a/DSView/pv/view/decodetrace.cpp +++ b/DSView/pv/view/decodetrace.cpp @@ -651,6 +651,8 @@ void* DecodeTrace::get_key_handel() //to show decoder's property setting dialog bool DecodeTrace::create_popup(bool isnew) { + (void)isnew; + int ret = false; //setting have changed flag while (true) diff --git a/DSView/pv/view/devmode.cpp b/DSView/pv/view/devmode.cpp index 5bb9bb2d..015936f3 100644 --- a/DSView/pv/view/devmode.cpp +++ b/DSView/pv/view/devmode.cpp @@ -126,11 +126,7 @@ void DevMode::set_device() _close_button->setIcon(QIcon()); _close_button->setDisabled(true); - AppConfig &app = AppConfig::Instance(); - int lan = app.frameOptions.language; - QString iconPath = GetIconPath() + "/"; - auto dev_mode_list = _device_agent->get_device_mode_list(); for (const GSList *l = dev_mode_list; l; l = l->next) @@ -204,8 +200,6 @@ void DevMode::on_mode_change() } QString iconPath = GetIconPath(); - AppConfig &app = AppConfig::Instance(); - int lan = app.frameOptions.language; for(auto i = _mode_list.begin();i != _mode_list.end(); i++) { diff --git a/DSView/pv/view/dsldial.cpp b/DSView/pv/view/dsldial.cpp index e53b9df3..fcafb836 100644 --- a/DSView/pv/view/dsldial.cpp +++ b/DSView/pv/view/dsldial.cpp @@ -88,9 +88,6 @@ void dslDial::paint(QPainter &p, QRectF dialRect, QColor dialColor, const QPoint } //tr pText = QString::number(displayValue) + _unit[displayIndex] + "/div"; -// QFontMetrics fm(p.font()); -// const QRectF valueRect = QRectF(dialRect.left(), dialRect.top()-fm.height()-10, dialRect.width(), fm.height()); -// p.drawText(valueRect, Qt::AlignCenter, pText); // draw +/- if (dialRect.contains(pt) && pt.x() > dialRect.center().x()) { @@ -109,8 +106,6 @@ void dslDial::paint(QPainter &p, QRectF dialRect, QColor dialColor, const QPoint inc ? 10 : -10, hoverRect.width()/2 + 4); p.restore(); } - - (void*)0; } void dslDial::set_sel(uint64_t sel) @@ -158,9 +153,9 @@ uint64_t dslDial::get_max() uint64_t dslDial::get_value() { - this->_div = this->_div; + this->_div = this->_div; - if (_sel < 0 || _sel >= _value.count()){ + if (_sel >= (uint64_t)_value.count()){ assert(false); } diff --git a/DSView/pv/view/dsosignal.cpp b/DSView/pv/view/dsosignal.cpp index bb31c1cd..6bd12cb0 100644 --- a/DSView/pv/view/dsosignal.cpp +++ b/DSView/pv/view/dsosignal.cpp @@ -110,16 +110,6 @@ DsoSignal::DsoSignal(data::DsoSnapshot *data, load_settings(); } -DsoSignal::DsoSignal(const DsoSignal &o) -:Signal(NULL) -{ -} - -DsoSignal::DsoSignal(DsoSignal &o) -:Signal(NULL) -{ -} - DsoSignal::~DsoSignal() { DESTROY_OBJECT(_vDial); @@ -971,6 +961,8 @@ void DsoSignal::paint_trace(QPainter &p, int zeroY, int left, const int64_t start, const int64_t end, int hw_offset, const double pixels_offset, const double samples_per_pixel, uint64_t num_channels) { + (void)num_channels; + const int64_t sample_count = end - start + 1; if (sample_count > 0) { diff --git a/DSView/pv/view/dsosignal.h b/DSView/pv/view/dsosignal.h index 2aedb72d..9d516dfa 100644 --- a/DSView/pv/view/dsosignal.h +++ b/DSView/pv/view/dsosignal.h @@ -81,9 +81,6 @@ private: static const uint16_t MS_RectMargin = 10; static const uint16_t MS_RectHeight = 25; - DsoSignal(const DsoSignal &o); - DsoSignal(DsoSignal &o); - public: DsoSignal(pv::data::DsoSnapshot *data, sr_channel *probe); diff --git a/DSView/pv/view/groupsignal.cpp b/DSView/pv/view/groupsignal.cpp index a6a17537..ac8458e9 100644 --- a/DSView/pv/view/groupsignal.cpp +++ b/DSView/pv/view/groupsignal.cpp @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +/* #include "../dsvdef.h" #include "groupsignal.h" #include "view.h" @@ -95,3 +96,5 @@ QRectF GroupSignal::get_rect(GroupSetRegions type, int y, int right) } // namespace view } // namespace pv + +*/ diff --git a/DSView/pv/view/groupsignal.h b/DSView/pv/view/groupsignal.h index 1d9ce830..2984bfa7 100644 --- a/DSView/pv/view/groupsignal.h +++ b/DSView/pv/view/groupsignal.h @@ -23,6 +23,7 @@ #ifndef DSVIEW_SV_GROUPSIGNAL_H #define DSVIEW_SV_GROUPSIGNAL_H +/* #include "signal.h" #include @@ -50,21 +51,12 @@ public: virtual ~GroupSignal(); - /** - * Returns true if the trace is visible and enabled. - */ bool enabled(); pv::data::SignalData* data(); void set_scale(float scale); - /** - * Paints the signal with a QPainter - * @param p the QPainter to paint into. - * @param left the x-coordinate of the left edge of the signal. - * @param right the x-coordinate of the right edge of the signal. - **/ void paint_mid(QPainter &p, int left, int right, QColor fore, QColor back); QRectF get_rect(GroupSetRegions type, int y, int right); @@ -88,4 +80,6 @@ private: } // namespace view } // namespace pv +*/ + #endif // DSVIEW_PV_GROUPSIGNAL_H diff --git a/DSView/pv/view/viewport.cpp b/DSView/pv/view/viewport.cpp index f57a38eb..9b375e77 100644 --- a/DSView/pv/view/viewport.cpp +++ b/DSView/pv/view/viewport.cpp @@ -485,8 +485,6 @@ void Viewport::paintProgress(QPainter &p, QColor fore, QColor back) using pv::view::Signal; - const uint64_t sample_limits = _view.session().cur_samplelimits(); - double progress = 0; int progress100 = 0; int captured_progress = 0; diff --git a/DSView/pv/widgets/decodergroupbox.cpp b/DSView/pv/widgets/decodergroupbox.cpp index d1b78f5a..6bb35e63 100644 --- a/DSView/pv/widgets/decodergroupbox.cpp +++ b/DSView/pv/widgets/decodergroupbox.cpp @@ -63,7 +63,6 @@ DecoderGroupBox::DecoderGroupBox(data::DecoderStack *decoder_stack, const srd_decoder *const d = _dec->decoder(); assert(d); - const bool have_probes = (d->channels || d->opt_channels) != 0; _index = 0; for(auto dec : _decoder_stack->stack()) { @@ -120,8 +119,9 @@ DecoderGroupBox::~DecoderGroupBox() } bool DecoderGroupBox::eventFilter(QObject *o, QEvent *e) -{ - +{ + (void)e; + (void)o; return false; } diff --git a/common/ds_types.h b/common/ds_types.h new file mode 100644 index 00000000..342739e9 --- /dev/null +++ b/common/ds_types.h @@ -0,0 +1,35 @@ +/* + * This file is part of the DSView project. + * DSView is based on PulseView. + * + * Copyright (C) 2023 DreamSourceLab + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* +* example: +* xlog_context *ctx = xlog_new(); +* xlog_writer *wr = xlog_create_writer(ctx, "module name"); +* xlog_err(wr, "count:%d", 100); +* xlog_free(ctx); //free the context, all writer will can't to use +*/ + +#ifndef _DS_TYPES_H +#define _DS_TYPES_H + +typedef unsigned long u64_t; + +#endif \ No newline at end of file diff --git a/libsigrok4DSL/hardware/DSL/dscope.c b/libsigrok4DSL/hardware/DSL/dscope.c index d418eb13..1c5a5d34 100644 --- a/libsigrok4DSL/hardware/DSL/dscope.c +++ b/libsigrok4DSL/hardware/DSL/dscope.c @@ -54,7 +54,7 @@ static const struct sr_list_item bandwidth_list[] = { {-1, NULL}, }; -static struct lang_text_map_item lang_text_map[] = +static const struct lang_text_map_item lang_text_map[] = { {SR_CONF_OPERATION_MODE, DS_OP_NORMAL, "Normal", "正常"}, {SR_CONF_OPERATION_MODE, DS_OP_INTEST, "Internal Test", "内部测试"}, @@ -1219,7 +1219,6 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, struct sr_channel_group *cg ) { struct DSL_context *devc; - const char *stropt; int ret, num_probes; struct sr_usb_dev_inst *usb; struct libusb_device_handle *hdl; @@ -1731,13 +1730,10 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { - struct DSL_context *devc; - assert(sdi); assert(sdi->priv); (void)cg; - devc = sdi->priv; if (dsl_config_list(key, data, sdi, cg) == SR_OK) return SR_OK; @@ -1888,14 +1884,7 @@ static int dev_destroy(struct sr_dev_inst *sdi) static int cleanup(void) { - int ret; - struct drv_context *drvc; - - if (!(drvc = di->priv)) - return SR_OK; - - g_free(drvc); - di->priv = NULL; + safe_free(di->priv); return SR_OK; } @@ -2143,11 +2132,13 @@ static int dev_status_get(const struct sr_dev_inst *sdi, struct sr_status *statu SR_PRIV int sr_dscope_option_value_to_code(const struct sr_dev_inst *sdi, int config_id, const char *value) { int num; - + + (void)sdi; assert(sdi); num = sizeof(lang_text_map) / sizeof(lang_text_map[0]); - return sr_option_value_to_code(config_id, value, &lang_text_map, num); + return sr_option_value_to_code(config_id, value, + (const struct lang_text_map_item*)lang_text_map, num); } SR_PRIV struct sr_dev_driver DSCope_driver_info = { diff --git a/libsigrok4DSL/hardware/DSL/dsl.c b/libsigrok4DSL/hardware/DSL/dsl.c index 0be467c1..68687b1b 100644 --- a/libsigrok4DSL/hardware/DSL/dsl.c +++ b/libsigrok4DSL/hardware/DSL/dsl.c @@ -51,7 +51,7 @@ static const uint8_t probeCoupling[] = { SR_AC_COUPLING, }; -const char *probeMapUnits[] = { +static const char *probeMapUnits[] = { "V", "A", "℃", @@ -68,17 +68,6 @@ static const char *probe_names[] = { "24", "25", "26", "27", "28", "29", "30", "31", NULL, }; - -static const gboolean default_ms_en[] = { - FALSE, /* DSO_MS_BEGIN */ - TRUE, /* DSO_MS_FREQ */ - FALSE, /* DSO_MS_PERD */ - TRUE, /* DSO_MS_VMAX */ - TRUE, /* DSO_MS_VMIN */ - FALSE, /* DSO_MS_VRMS */ - FALSE, /* DSO_MS_VMEA */ - FALSE, /* DSO_MS_VP2P */ -}; SR_PRIV void dsl_probe_init(struct sr_dev_inst *sdi) { @@ -201,7 +190,7 @@ SR_PRIV const GSList *dsl_mode_list(const struct sr_dev_inst *sdi) devc = sdi->priv; for (i = 0; i < ARRAY_SIZE(sr_mode_list); i++) { if (devc->profile->dev_caps.mode_caps & (1 << i)) - l = g_slist_append(l, &sr_mode_list[i]); + l = g_slist_append(l, (gpointer)&sr_mode_list[i]); } return l; @@ -313,19 +302,15 @@ SR_PRIV gboolean dsl_check_conf_profile(libusb_device *dev) static int hw_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi) { - libusb_device **devlist; + (void)di; + libusb_device *dev_handel=NULL; struct sr_usb_dev_inst *usb; - struct libusb_device_descriptor des; - struct DSL_context *devc; - struct drv_context *drvc; struct version_info vi; - int ret, skip, i, device_count; + int ret; struct ctl_rd_cmd rd_cmd; uint8_t rd_cmd_data[2]; - drvc = di->priv; - devc = sdi->priv; usb = sdi->conn; if (usb->usb_dev == NULL){ @@ -1783,6 +1768,8 @@ SR_PRIV int dsl_config_list(int key, GVariant **data, const struct sr_dev_inst * int i; (void)cg; + assert(sdi->priv); + devc = sdi->priv; switch (key) { @@ -2322,8 +2309,8 @@ static void receive_transfer(struct libusb_transfer *transfer) if (devc->abort) devc->status = DSL_STOP; - sr_detail("%llu: receive_transfer(): status %d; timeout %d; received %d bytes.", - g_get_monotonic_time(), transfer->status, transfer->timeout, transfer->actual_length); + sr_detail("%lu: receive_transfer(): status %d; timeout %d; received %d bytes.", + (u64_t)g_get_monotonic_time(), transfer->status, transfer->timeout, transfer->actual_length); switch (transfer->status) { case LIBUSB_TRANSFER_COMPLETED: @@ -2454,8 +2441,8 @@ static void receive_header(struct libusb_transfer *transfer) devc->status = DSL_ERROR; if (!devc->abort && transfer->status == LIBUSB_TRANSFER_COMPLETED && trigger_pos->check_id == TRIG_CHECKID) { - sr_info("%llu: receive_trigger_pos(): status %d; timeout %d; received %d bytes.", - g_get_monotonic_time(), transfer->status, transfer->timeout, transfer->actual_length); + sr_info("%lu: receive_trigger_pos(): status %d; timeout %d; received %d bytes.", + (u64_t)g_get_monotonic_time(), transfer->status, transfer->timeout, transfer->actual_length); remain_cnt = trigger_pos->remain_cnt_h; remain_cnt = (remain_cnt << 32) + trigger_pos->remain_cnt_l; if (transfer->actual_length == dsl_header_size(devc)) { @@ -2559,7 +2546,7 @@ SR_PRIV int dsl_start_transfers(const struct sr_dev_inst *sdi) } -SR_PRIV int dsl_destroy_device(const struct sr_dev_inst *sdi) +SR_PRIV int dsl_destroy_device(struct sr_dev_inst *sdi) { assert(sdi); @@ -2588,7 +2575,7 @@ SR_PRIV int sr_option_value_to_code(int config_id, const char *value, const stru assert(array); assert(value); - p = array; + p = (struct lang_text_map_item*)array; for (i = 0; i < num; i++){ if (p->config_id == config_id){ diff --git a/libsigrok4DSL/hardware/DSL/dsl.h b/libsigrok4DSL/hardware/DSL/dsl.h index d0f3ef7f..b960b372 100644 --- a/libsigrok4DSL/hardware/DSL/dsl.h +++ b/libsigrok4DSL/hardware/DSL/dsl.h @@ -1359,7 +1359,7 @@ SR_PRIV unsigned int dsl_get_timeout(const struct sr_dev_inst *sdi); SR_PRIV int dsl_start_transfers(const struct sr_dev_inst *sdi); SR_PRIV int dsl_header_size(const struct DSL_context *devc); -SR_PRIV int dsl_destroy_device(const struct sr_dev_inst *sdi); +SR_PRIV int dsl_destroy_device(struct sr_dev_inst *sdi); SR_PRIV int dsl_secuCheck(const struct sr_dev_inst *sdi, uint16_t* encryption, int steps); diff --git a/libsigrok4DSL/hardware/DSL/dslogic.c b/libsigrok4DSL/hardware/DSL/dslogic.c index 166737b8..a335bd67 100644 --- a/libsigrok4DSL/hardware/DSL/dslogic.c +++ b/libsigrok4DSL/hardware/DSL/dslogic.c @@ -77,7 +77,7 @@ static const struct sr_list_item filter_list[] = { #define CHANNEL_MODE_LIST_LEN 25 static struct sr_list_item channel_mode_list[CHANNEL_MODE_LIST_LEN]; -static struct lang_text_map_item lang_text_map[] = +static const struct lang_text_map_item lang_text_map[] = { {SR_CONF_OPERATION_MODE, LO_OP_BUFFER, "Buffer Mode", "Buffer模式"}, {SR_CONF_OPERATION_MODE, LO_OP_STREAM, "Stream Mode", "Stream模式"}, @@ -95,7 +95,7 @@ static struct lang_text_map_item lang_text_map[] = {SR_CONF_FILTER, SR_FILTER_1T, "1 Sample Clock", "1个采样周期"}, }; -static struct sr_list_item channel_mode_cn_map[] = { +static const struct sr_list_item channel_mode_cn_map[] = { {DSL_STREAM20x16, "使用16个通道(最大采样率 20MHz)"}, {DSL_STREAM25x12, "使用12个通道(最大采样率 25MHz)"}, {DSL_STREAM50x6, "使用6个通道(最大采样率 50MHz)"}, @@ -194,9 +194,6 @@ static const int32_t sessions_pro[] = { SR_CONF_TRIGGER_MARGIN, }; - -static uint16_t opmodes_show_count = 3; - SR_PRIV struct sr_dev_driver DSLogic_driver_info; static struct sr_dev_driver *di = &DSLogic_driver_info; @@ -1047,8 +1044,8 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, if (sdi->mode == LOGIC) { for (i = 0; i < ARRAY_SIZE(channel_modes); i++) { if (devc->profile->dev_caps.channels & (1 << i)) { - if (channel_modes[i].id == nv) { - devc->ch_mode = nv; + if ((int)channel_modes[i].id == nv) { + devc->ch_mode = (enum DSL_CHANNEL_ID)nv; break; } } @@ -1186,7 +1183,6 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { struct DSL_context *devc; - GVariantBuilder gvb; unsigned int i; int num; @@ -1310,16 +1306,8 @@ static int dev_destroy(struct sr_dev_inst *sdi) } static int cleanup(void) -{ - int ret; - struct drv_context *drvc; - - if (!(drvc = di->priv)) - return SR_OK; - - g_free(drvc); - di->priv = NULL; - +{ + safe_free(di->priv); return SR_OK; } @@ -1544,11 +1532,10 @@ static int dev_status_get(const struct sr_dev_inst *sdi, struct sr_status *statu SR_PRIV int sr_dslogic_option_value_to_code(const struct sr_dev_inst *sdi, int config_id, const char *value) { int num; - int i; - int n; + unsigned int i; struct DSL_context *devc; - char *list_text; - char *cn_name; + const char *list_text; + const char *cn_name; assert(sdi); assert(sdi->priv); @@ -1569,7 +1556,7 @@ SR_PRIV int sr_dslogic_option_value_to_code(const struct sr_dev_inst *sdi, int c return channel_modes[i].id; if (i < ARRAY_SIZE(channel_mode_cn_map)){ - if (channel_modes[i].id != channel_mode_cn_map[i].id) + if ((int)channel_modes[i].id != channel_mode_cn_map[i].id) assert(0); cn_name = channel_mode_cn_map[i].name; @@ -1584,7 +1571,7 @@ SR_PRIV int sr_dslogic_option_value_to_code(const struct sr_dev_inst *sdi, int c } num = sizeof(lang_text_map) / sizeof(lang_text_map[0]); - return sr_option_value_to_code(config_id, value, &lang_text_map, num); + return sr_option_value_to_code(config_id, value, &lang_text_map[0], num); } SR_PRIV struct sr_dev_driver DSLogic_driver_info = { diff --git a/libsigrok4DSL/hardware/demo/demo.c b/libsigrok4DSL/hardware/demo/demo.c index 3a45fdc9..12decbad 100644 --- a/libsigrok4DSL/hardware/demo/demo.c +++ b/libsigrok4DSL/hardware/demo/demo.c @@ -45,8 +45,6 @@ static uint64_t samplecounts_file[1]; static GTimer *packet_interval = NULL; static GTimer *run_time = NULL; static int max_probe_num = 0; -static int64_t analog_count = 0; -static gboolean channel_mode_change = FALSE; static uint64_t packet_num; static void *logic_post_buf = NULL; @@ -73,7 +71,7 @@ static struct demo_mode_pattern demo_pattern_array[3]; static int b_load_directory = 0; static char* demo_mode_names[3] = {"logic", "dso", "analog"}; -static struct DEMO_channels logic_channel_modes[] = { +static const struct DEMO_channels logic_channel_modes[] = { {DEMO_LOGIC125x16, LOGIC, SR_CHANNEL_LOGIC, 16, 1, SR_MHZ(1), SR_Mn(1), SR_KHZ(50), SR_MHZ(125), "Use 16 Channels (Max 125MHz)"}, {DEMO_LOGIC250x12, LOGIC, SR_CHANNEL_LOGIC, 12, 1, SR_MHZ(1), SR_Mn(1), @@ -86,7 +84,7 @@ static struct DEMO_channels logic_channel_modes[] = { static struct sr_list_item logic_channel_mode_list[ARRAY_SIZE(logic_channel_modes)+1]; -static struct DEMO_channels channel_modes[] = { +static const struct DEMO_channels channel_modes[] = { // LA Stream {DEMO_LOGIC100x16, LOGIC, SR_CHANNEL_LOGIC, 16, 1, SR_MHZ(1), SR_Mn(1), SR_KHZ(50), SR_GHZ(1), "Use 16 Channels (Max 20MHz)"}, @@ -413,7 +411,7 @@ static int get_pattern_mode_from_file(const char *sub_dir, struct demo_mode_patt char dir_path_buf[500]; int str_len; char *dir_path = dir_path_buf; - char *file_path = NULL; + const char *file_path = NULL; char short_name[50]; int i; int num; @@ -492,11 +490,10 @@ static void scan_dsl_file(struct sr_dev_inst *sdi) static int reset_dsl_path(struct sr_dev_inst *sdi, uint8_t pattern_mode) { struct demo_mode_pattern *info = NULL; - if(sdi->path != NULL) - safe_free(sdi->path); - char file_path[500]; + safe_free(sdi->path); + strcpy(file_path, DS_USR_PATH); strcat(file_path,"/demo/"); @@ -566,6 +563,7 @@ static int init_random_data(struct session_vdev *vdev) int cur_probe = 0; int probe_count[LOGIC_MAX_PROBE_NUM] = {0}; uint8_t probe_status[LOGIC_MAX_PROBE_NUM] = {LOGIC_HIGH_LEVEL}; + uint64_t i; assert(vdev->data_buf); @@ -578,7 +576,7 @@ static int init_random_data(struct session_vdev *vdev) probe_count[i] = rand()%SR_KB(1); } - for(int i = 0 ; i < vdev->data_buf_len ;i++) + for(i = 0 ; i < vdev->data_buf_len ;i++) { if(i % 8 == 0 && i != 0) { @@ -622,7 +620,6 @@ static GSList *hw_scan(GSList *options) struct sr_dev_inst *sdi; struct session_vdev *vdev; GSList *devices; - char str[500]; (void)options; devices = NULL; @@ -658,14 +655,14 @@ static GSList *hw_scan(GSList *options) static const GSList *hw_dev_mode_list(const struct sr_dev_inst *sdi) { - // struct demo_context *devc; + (void)sdi; + GSList *l = NULL; unsigned int i; for (i = 0; i < ARRAY_SIZE(sr_mode_list); i++) { - // if (devc->profile->dev_caps.mode_caps & (1 << i)) if (supported_Demo[0].dev_caps.mode_caps & (1 << i)) - l = g_slist_append(l, &sr_mode_list[i]); + l = g_slist_append(l, (gpointer)&sr_mode_list[i]); } return l; @@ -755,7 +752,7 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, { (void)cg; - char *patter_name = NULL; + const char *patter_name = NULL; assert(sdi); assert(sdi->priv); @@ -920,11 +917,11 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, { case SR_CONF_SAMPLERATE: vdev->samplerate = g_variant_get_uint64(data); - sr_dbg("Setting samplerate to %llu.", vdev->samplerate); + sr_dbg("Setting samplerate to %lu.", (u64_t)vdev->samplerate); break; case SR_CONF_LIMIT_SAMPLES: vdev->total_samples = g_variant_get_uint64(data); - sr_dbg("Setting limit samples to %llu.", vdev->total_samples); + sr_dbg("Setting limit samples to %lu.", (u64_t)vdev->total_samples); break; case SR_CONF_LIMIT_MSEC: break; @@ -1035,7 +1032,7 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, g_timer_start(run_time); vdev->timebase_change = TRUE; } - sr_dbg("Setting timebase to %llu.", vdev->timebase); + sr_dbg("Setting timebase to %lu.", (u64_t)vdev->timebase); break; case SR_CONF_PROBE_COUPLING: if(sdi->mode != LOGIC) @@ -1082,11 +1079,10 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, break; case SR_CONF_PROBE_MAP_MAX: ch->map_max = g_variant_get_double(data); - if(sdi->mode == ANALOG) break; case SR_CONF_NUM_BLOCKS: vdev->num_blocks = g_variant_get_uint64(data); - sr_dbg("Setting block number to %llu.", vdev->num_blocks); + sr_dbg("Setting block number to %d.", vdev->num_blocks); break; case SR_CONF_CAPTURE_NUM_PROBES: vdev->num_probes = g_variant_get_uint64(data); @@ -1104,10 +1100,10 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, { for(i = 0 ; i < ARRAY_SIZE(logic_channel_modes);i++) { - if(logic_channel_modes[i].id == nv) + if(logic_channel_modes[i].id == (enum DEMO_CHANNEL_ID)nv) { vdev->logic_ch_mode_index = i; - vdev->logic_ch_mode = nv; + vdev->logic_ch_mode = (enum DEMO_CHANNEL_ID)nv; load_virtual_device_session(sdi); vdev->channel_mode_change = TRUE; break; @@ -1136,6 +1132,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, GVariant *gvar; GVariantBuilder gvb; struct demo_mode_pattern *info = NULL; + unsigned int i; (void)sdi; struct session_vdev *vdev = sdi->priv; @@ -1167,7 +1164,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, break; case SR_CONF_PATTERN_MODE: info = &demo_pattern_array[sdi->mode]; - *data = g_variant_new_strv(info->patterns, info->count); + *data = g_variant_new_strv((const char* const*)info->patterns, info->count); break; case SR_CONF_MAX_HEIGHT: *data = g_variant_new_strv(maxHeights, ARRAY_SIZE(maxHeights)); @@ -1196,16 +1193,14 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, case SR_CONF_CHANNEL_MODE: if(sdi->mode == LOGIC&& vdev->sample_generator == PATTERN_RANDOM) { - for(int i = 0;ipriv; vdev->enabled_probes = 0; - packet.status = SR_PKT_OK; - vdev->cur_block = 0; sr_info("mode:%d, generator:%d", sdi->mode, vdev->sample_generator); @@ -1273,8 +1264,8 @@ static int hw_dev_acquisition_start(struct sr_dev_inst *sdi, if (NULL == vdev->archive) { sr_err("Failed to open session file '%s': " - "zip error %d\n", - sdi->path, ret); + "zip error", + sdi->path); return SR_ERR; } } @@ -1583,7 +1574,7 @@ static int receive_data_logic_decoder(int fd, int revents, const struct sr_dev_i char szFilePath[15]; int bToEnd; int read_chan_index; - uint8_t chan_num; + int chan_num; uint8_t *p_wr; uint8_t *p_rd; uint8_t byte_align; @@ -1796,7 +1787,7 @@ static int receive_data_logic_decoder(int fd, int revents, const struct sr_dev_i } } - if (pack_buffer->post_len >= byte_align * chan_num) + if (pack_buffer->post_len >= (uint64_t)(byte_align * chan_num)) { packet.type = SR_DF_LOGIC; packet.payload = &logic; @@ -2483,7 +2474,7 @@ static int load_virtual_device_session(struct sr_dev_inst *sdi) struct sr_channel *probe; int i, j; uint64_t tmp_u64; - char **sections, **keys, *metafile, *val,*probe_name; + char **sections, **keys, *metafile, *val; int mode = LOGIC; int channel_type = SR_CHANNEL_LOGIC; struct session_vdev * vdev = sdi->priv; @@ -2624,9 +2615,8 @@ static int load_virtual_device_session(struct sr_dev_inst *sdi) sr_dev_probes_free(sdi); for (int i = 0; i < vdev->num_probes; i++) - { - probe_name = probe_names[i]; - if (!(probe = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, probe_name))) + { + if (!(probe = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE, probe_names[i]))) { sr_err("%s: create channel failed", __func__); sr_dev_inst_free(sdi); @@ -2645,9 +2635,8 @@ static int load_virtual_device_session(struct sr_dev_inst *sdi) sr_dev_probes_free(sdi); for (int i = 0; i < DSO_DEFAULT_NUM_PROBE; i++) - { - probe_name = probe_names[i]; - if (!(probe = sr_channel_new(i, SR_CHANNEL_DSO, TRUE, probe_name))) + { + if (!(probe = sr_channel_new(i, SR_CHANNEL_DSO, TRUE, probe_names[i]))) { sr_err("%s: create channel failed", __func__); sr_dev_inst_free(sdi); @@ -2672,9 +2661,8 @@ static int load_virtual_device_session(struct sr_dev_inst *sdi) sr_dev_probes_free(sdi); for (int i = 0; i < ANALOG_DEFAULT_NUM_PROBE; i++) - { - probe_name = probe_names[i]; - if (!(probe = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE, probe_name))) + { + if (!(probe = sr_channel_new(i, SR_CHANNEL_ANALOG, TRUE, probe_names[i]))) { sr_err("%s: create channel failed", __func__); sr_dev_inst_free(sdi); diff --git a/libsigrok4DSL/hardware/demo/demo.h b/libsigrok4DSL/hardware/demo/demo.h index 7667ec03..dfdc727a 100644 --- a/libsigrok4DSL/hardware/demo/demo.h +++ b/libsigrok4DSL/hardware/demo/demo.h @@ -431,10 +431,6 @@ static int vdev_init(struct sr_dev_inst* sdi); static void dso_status_update(struct session_vdev *vdev); -static int get_logic_probe_type_index_by_probe_type(int probe_type); - -static int logic_adjust_probe(struct sr_dev_inst *sdi, int num_probes); - static void logic_adjust_samplerate(struct session_vdev * vdev); static int init_analog_random_data(struct session_vdev * vdev); @@ -499,8 +495,6 @@ static void send_error_packet(const struct sr_dev_inst *cb_sdi, struct session_v static int close_archive(struct session_vdev *vdev); -static int hw_cleanup(); - static int dso_wavelength_updata(struct session_vdev *vdev); diff --git a/libsigrok4DSL/hwdriver.c b/libsigrok4DSL/hwdriver.c index 59cc5df5..d9d7c32a 100644 --- a/libsigrok4DSL/hwdriver.c +++ b/libsigrok4DSL/hwdriver.c @@ -82,7 +82,7 @@ static struct sr_config_info sr_config_info_data[] = { {SR_CONF_PROBE_MAP_UNIT, SR_T_CHAR,"Map Unit"}, {SR_CONF_PROBE_MAP_MIN, SR_T_FLOAT,"Map Min"}, {SR_CONF_PROBE_MAP_MAX, SR_T_FLOAT,"Map Max"}, - {0, 0, NULL, NULL}, + {0, 0, NULL}, }; @@ -114,15 +114,9 @@ static struct sr_dev_driver *drivers_list[] = { */ SR_PRIV struct sr_dev_driver **sr_driver_list(void) { - return drivers_list; } -SR_API int ds_map_lang_text_id(int conf_id, int item_id, char *text) -{ - - return -1; -} /** * Initialize a hardware driver. @@ -403,7 +397,7 @@ SR_PRIV int ds_scan_all_device_list(libusb_context *usb_ctx,struct libusb_device if (devlist == NULL){ sr_info("%s: Failed to call libusb_get_device_list(), it returns a null list.", __func__); - return NULL; + return SR_ERR_CALL_STATUS; } for (i = 0; devlist[i]; i++) @@ -417,7 +411,7 @@ SR_PRIV int ds_scan_all_device_list(libusb_context *usb_ctx,struct libusb_device if (des.idVendor == DS_VENDOR_ID){ if (wr >= size){ sr_err("ds_scan_all_device_list(), buffer length is too short."); - assert(0); + break; } list_buf[wr] = devlist[i]; diff --git a/libsigrok4DSL/input/in_vcd.c b/libsigrok4DSL/input/in_vcd.c index ffce2b37..a939e8a9 100644 --- a/libsigrok4DSL/input/in_vcd.c +++ b/libsigrok4DSL/input/in_vcd.c @@ -236,11 +236,11 @@ static gboolean parse_header(FILE *file, struct context *ctx) if (q % p != 0) { /* Does not happen unless time value is non-standard */ - sr_warn("Inexact rounding of samplerate, %llu / %llu to %llu Hz.", - q, p, ctx->samplerate); + sr_warn("Inexact rounding of samplerate, %lu / %lu to %lu Hz.", + (u64_t)q, (u64_t)p, (u64_t)ctx->samplerate); } - sr_dbg("Samplerate: %llu", ctx->samplerate); + sr_dbg("Samplerate: %lu", (u64_t)ctx->samplerate); } else { @@ -476,7 +476,7 @@ static void parse_contents(FILE *file, const struct sr_dev_inst *sdi, struct con prev_timestamp = timestamp - ctx->compress; } - sr_dbg("New timestamp: %llu", timestamp); + sr_dbg("New timestamp: %lu", (u64_t)timestamp); /* Generate samples from prev_timestamp up to timestamp - 1. */ send_samples(sdi, prev_values, timestamp - prev_timestamp); diff --git a/libsigrok4DSL/lib_main.c b/libsigrok4DSL/lib_main.c index 52e0b302..f09fa4e6 100644 --- a/libsigrok4DSL/lib_main.c +++ b/libsigrok4DSL/lib_main.c @@ -28,10 +28,8 @@ #ifdef _WIN32 #include -#define _sleep(m) Sleep((m)) #else #include -#define _sleep(m) usleep((m)*1000) #endif #define MAX_DEVCIE_LIST_LENGTH 20 @@ -51,7 +49,7 @@ struct sr_lib_context { dslib_event_callback_t event_callback; struct sr_context *sr_ctx; - GList *device_list; // All device instance, sr_dev_inst* type + GSList *device_list; // All device instance, sr_dev_inst* type pthread_mutex_t mutext; int lib_exit_flag; int attach_event_flag; @@ -73,11 +71,11 @@ struct sr_lib_context }; static void hotplug_event_listen_callback(struct libusb_context *ctx, struct libusb_device *dev, int event); -static void usb_hotplug_process_proc(); +static gpointer usb_hotplug_process_proc(gpointer data); static void destroy_device_instance(struct sr_dev_inst *dev); static void close_device_instance(struct sr_dev_inst *dev); static int open_device_instance(struct sr_dev_inst *dev); -static void collect_run_proc(); +static gpointer collect_run_proc(gpointer data); static void post_event_async(int event); static void send_event(int event); static void make_demo_device_to_list(); @@ -173,13 +171,14 @@ SR_API int ds_lib_init() sr_listen_hotplug(lib_ctx.sr_ctx, hotplug_event_listen_callback); /** Start usb hotplug thread */ - lib_ctx.hotplug_thread = g_thread_new("hotplug_proc", usb_hotplug_process_proc, NULL); + lib_ctx.hotplug_thread = g_thread_new("hotplug_proc", usb_hotplug_process_proc, (gpointer)0); return SR_OK; } #ifndef _WIN32 SR_PRIV int lib_extern_init(struct sr_context *ctx){ + (void)ctx; return SR_OK; } #endif @@ -286,10 +285,10 @@ SR_API void ds_set_datafeed_callback(ds_datafeed_callback_t cb) SR_API int ds_get_device_list(struct ds_device_base_info **out_list, int *out_count) { int num; - struct ds_device_base_info *array = NULL; struct ds_device_base_info *p = NULL; GSList *l; struct sr_dev_inst *dev; + void *buf = NULL; if (out_list == NULL) { @@ -306,21 +305,21 @@ SR_API int ds_get_device_list(struct ds_device_base_info **out_list, int *out_co return SR_OK; } - array = (struct ds_device_info *)malloc(sizeof(struct ds_device_base_info) * (num + 1)); - if (array == NULL) + buf = malloc(sizeof(struct ds_device_base_info) * (num + 1)); + if (buf == NULL) { sr_err("%s,ERROR:failed to alloc memory.", __func__); pthread_mutex_unlock(&lib_ctx.mutext); return SR_ERR_MALLOC; } - p = array; + p = (struct ds_device_base_info*)buf; for (l = lib_ctx.device_list; l; l = l->next) { dev = l->data; p->handle = dev->handle; - strncpy(p->name, dev->name, sizeof(p->name) - 1); + strncpy(p->name, (const char*)dev->name, sizeof(p->name) - 1); p++; } @@ -334,7 +333,7 @@ SR_API int ds_get_device_list(struct ds_device_base_info **out_list, int *out_co pthread_mutex_unlock(&lib_ctx.mutext); - *out_list = array; + *out_list = (struct ds_device_base_info*)buf; return SR_OK; } @@ -460,8 +459,8 @@ SR_API int ds_active_device_by_index(int index) { GSList *l; struct sr_dev_inst *dev; - ds_device_handle handle = NULL; - ds_device_handle lst_handle = NULL; + ds_device_handle handle = NULL_HANDLE; + ds_device_handle lst_handle = NULL_HANDLE; int i = 0; pthread_mutex_lock(&lib_ctx.mutext); @@ -486,7 +485,7 @@ SR_API int ds_active_device_by_index(int index) handle = lst_handle; // Get the last one. } - if (handle == NULL) + if (handle == NULL_HANDLE) { sr_err("ds_active_device_by_index(), index is error!"); return SR_ERR_CALL_STATUS; @@ -501,8 +500,10 @@ SR_API int ds_active_device_by_index(int index) SR_API int ds_get_actived_device_index() { int dex = -1; - GSList *l; + GSList *l = NULL; int i = 0; + + (void)l; if (lib_ctx.actived_device_instance == NULL) { @@ -570,7 +571,6 @@ SR_API int ds_device_from_file(const char *file_path) */ SR_API const GSList *ds_get_actived_device_mode_list() { - GSList *l; struct sr_dev_inst *dev; dev = lib_ctx.actived_device_instance; @@ -677,7 +677,7 @@ SR_API int ds_get_actived_device_info(struct ds_device_full_info *fill_info) p->dev_type = dev->dev_type; p->di = dev; p->actived_times = dev->actived_times; - strncpy(p->name, dev->name, sizeof(p->name) - 1); + strncpy(p->name, (const char*)dev->name, sizeof(p->name) - 1); if (dev->driver && dev->driver->name) { @@ -765,13 +765,15 @@ SR_API int ds_start_collect() } - lib_ctx.collect_thread = g_thread_new("collect_run_proc", collect_run_proc, NULL); + lib_ctx.collect_thread = g_thread_new("collect_proc", collect_run_proc, (gpointer)0); return SR_OK; } -static void collect_run_proc() +static gpointer collect_run_proc(gpointer data) { + (void)data; + int ret; struct sr_dev_inst *di; int bError; @@ -825,6 +827,8 @@ END: send_event(DS_EV_COLLECT_TASK_END); // Normal end. lib_ctx.is_stop_by_detached = 0; + + return NULL; } /** @@ -957,8 +961,8 @@ SR_API int ds_set_actived_device_config(const struct sr_channel *ch, return sr_config_set( lib_ctx.actived_device_instance, - ch, - cg, + (struct sr_channel*)ch, + (struct sr_channel_group*)cg, key, data); } @@ -984,7 +988,7 @@ SR_API const struct sr_config_info *ds_get_actived_device_config_info(int key) if (lib_ctx.actived_device_instance == NULL) { sr_err("Have no actived device."); - return SR_ERR_CALL_STATUS; + return NULL; } return sr_config_info_get(key); @@ -1199,7 +1203,7 @@ static int update_device_handle(struct libusb_device *old_dev, struct libusb_dev usb_dev_info->usb_dev = new_dev; usb_dev_info->bus = bus; usb_dev_info->address = address; - dev->handle = new_dev; + dev->handle = (ds_device_handle)new_dev; bFind = 1; // Reopen the device by transaction. @@ -1228,6 +1232,8 @@ static void hotplug_event_listen_callback(struct libusb_context *ctx, struct lib { int bDone = 0; + (void)ctx; + if (dev == NULL){ if (event == USB_EV_HOTPLUG_ATTACH) dev = get_new_attached_usb_device(); @@ -1312,7 +1318,7 @@ static void hotplug_event_listen_callback(struct libusb_context *ctx, struct lib static void process_attach_event(int isEvent) { struct sr_dev_driver **drivers; - GList *dev_list; + GSList *dev_list; GSList *l; struct sr_dev_driver *dr; int num = 0; @@ -1359,7 +1365,6 @@ static void process_detach_event() { GSList *l; struct sr_dev_inst *dev; - struct sr_dev_driver *driver_ins; libusb_device *ev_dev; int ev; int bFind; @@ -1411,8 +1416,10 @@ static void process_detach_event() } } -static void usb_hotplug_process_proc() +static gpointer usb_hotplug_process_proc(gpointer data) { + (void)data; + sr_info("Hotplug thread start!"); int cur_trans_id = 0; @@ -1431,7 +1438,7 @@ static void usb_hotplug_process_proc() lib_ctx.detach_event_flag = 0; } - _sleep(100); + xsleep(100); if (lib_ctx.is_waitting_reconnect) { @@ -1467,17 +1474,19 @@ static void usb_hotplug_process_proc() // Wait all callback thread end. while (lib_ctx.callback_thread_count > 0) { - _sleep(100); + xsleep(100); } sr_info("Hotplug thread end!"); + + return NULL; } static void make_demo_device_to_list() { struct sr_dev_driver **drivers; struct sr_dev_driver *dr; - GList *dev_list; + GSList *dev_list; GSList *l; drivers = sr_driver_list(); @@ -1553,16 +1562,18 @@ static int open_device_instance(struct sr_dev_inst *dev) return SR_ERR_CALL_STATUS; } -static void post_event_proc(int event) +static gpointer post_event_proc(gpointer event) { if (lib_ctx.event_callback != NULL) { - lib_ctx.event_callback(event); + lib_ctx.event_callback((int)((unsigned long)event)); } pthread_mutex_lock(&lib_ctx.mutext); lib_ctx.callback_thread_count--; pthread_mutex_unlock(&lib_ctx.mutext); + + return NULL; } static void post_event_async(int event) @@ -1571,7 +1582,7 @@ static void post_event_async(int event) lib_ctx.callback_thread_count++; pthread_mutex_unlock(&lib_ctx.mutext); - g_thread_new("callback_thread", post_event_proc, event); + g_thread_new("callback_thread", post_event_proc, (gpointer)((unsigned long)event)); } static void send_event(int event) @@ -1587,14 +1598,14 @@ static struct libusb_device* get_new_attached_usb_device() struct libusb_device* array[MAX_DEVCIE_LIST_LENGTH]; int num; int i; - GList *l; + GSList *l; int bFind; struct libusb_device* dev; struct sr_dev_inst *dev_ins; dev = NULL; num = 0; - ds_scan_all_device_list(lib_ctx.sr_ctx->libusb_ctx, &array, MAX_DEVCIE_LIST_LENGTH, &num); + ds_scan_all_device_list(lib_ctx.sr_ctx->libusb_ctx, (struct libusb_device **)array, MAX_DEVCIE_LIST_LENGTH, &num); pthread_mutex_lock(&lib_ctx.mutext); @@ -1629,14 +1640,14 @@ static struct libusb_device* get_new_detached_usb_device() struct libusb_device* array[MAX_DEVCIE_LIST_LENGTH]; int num; int i; - GList *l; + GSList *l; int bFind; struct libusb_device* dev; struct sr_dev_inst *dev_ins; dev = NULL; num = 0; - ds_scan_all_device_list(lib_ctx.sr_ctx->libusb_ctx, &array, MAX_DEVCIE_LIST_LENGTH, &num); + ds_scan_all_device_list(lib_ctx.sr_ctx->libusb_ctx, (struct libusb_device **)array, MAX_DEVCIE_LIST_LENGTH, &num); pthread_mutex_lock(&lib_ctx.mutext); @@ -1677,6 +1688,15 @@ SR_PRIV int post_message_callback(int msg) return SR_OK; } +SR_PRIV void xsleep(int ms) +{ +#ifdef _WIN32 + Sleep(ms); +#else + usleep(ms * 1000); +#endif +} + /**-------------------private function end---------------*/ SR_PRIV void ds_set_last_error(int error) diff --git a/libsigrok4DSL/libsigrok-internal.h b/libsigrok4DSL/libsigrok-internal.h index 054e38da..1b9b30be 100644 --- a/libsigrok4DSL/libsigrok-internal.h +++ b/libsigrok4DSL/libsigrok-internal.h @@ -22,6 +22,7 @@ //#include #include +#include #include "config.h" /* Needed for HAVE_LIBUSB_1_0 and others. */ #include #include "libsigrok.h" @@ -95,8 +96,8 @@ enum sr_dev_driver_type struct lang_text_map_item{ int config_id; int id; - char *en_name; - char *cn_name; + const char *en_name; + const char *cn_name; }; struct sr_dev_driver { @@ -421,6 +422,8 @@ SR_PRIV int lib_extern_init(struct sr_context *ctx); SR_PRIV int post_message_callback(int msg); +SR_PRIV void xsleep(int ms); + /*--- hwdriver.c ------------------------------------------------------------*/ SR_PRIV int sr_config_get(const struct sr_dev_driver *driver, diff --git a/libsigrok4DSL/libsigrok.h b/libsigrok4DSL/libsigrok.h index 837be677..1163499c 100644 --- a/libsigrok4DSL/libsigrok.h +++ b/libsigrok4DSL/libsigrok.h @@ -689,7 +689,7 @@ struct sr_channel { /** Structure for groups of channels that have common properties. */ struct sr_channel_group { /** Name of the channel group. */ - char *name; + const char *name; /** List of sr_channel structs of the channels belonging to this group. */ GSList *channels; /** Private data for driver use. */ @@ -704,7 +704,7 @@ struct sr_config { struct sr_config_info { int key; int datatype; - char *name; + const char *name; }; struct sr_status { @@ -763,7 +763,7 @@ struct sr_status { struct sr_list_item{ int id; - char *name; + const char *name; }; enum sr_config_option_id diff --git a/libsigrok4DSL/output/gnuplot.c b/libsigrok4DSL/output/gnuplot.c index 1260d009..0874869d 100644 --- a/libsigrok4DSL/output/gnuplot.c +++ b/libsigrok4DSL/output/gnuplot.c @@ -212,7 +212,7 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p memcpy(ctx->prevsample, sample, logic->unitsize); /* The first column is a counter (needed for gnuplot). */ - g_string_append_printf(*out, "%llu\t", ctx->samplecount-1); + g_string_append_printf(*out, "%lu\t", (u64_t)ctx->samplecount-1); /* The next columns are the values of all channels. */ for (p = 0; p < ctx->num_enabled_channels; p++) { diff --git a/libsigrok4DSL/output/output.c b/libsigrok4DSL/output/output.c index 455514c3..c8cc69ad 100644 --- a/libsigrok4DSL/output/output.c +++ b/libsigrok4DSL/output/output.c @@ -250,7 +250,7 @@ SR_API void sr_output_options_free(const struct sr_option **options) * * @since 0.4.0 */ -SR_API const struct sr_output *sr_output_new(const struct sr_output_module *omod, +SR_API const struct sr_output* sr_output_new(const struct sr_output_module *omod, GHashTable *options, const struct sr_dev_inst *sdi) { struct sr_output *op; @@ -264,7 +264,7 @@ SR_API const struct sr_output *sr_output_new(const struct sr_output_module *omod op = malloc(sizeof(struct sr_output)); if (op == NULL){ sr_err("%s,ERROR:failed to alloc memory.", __func__); - return SR_ERR; + return NULL; } memset(op, 0, sizeof(struct sr_output)); diff --git a/libsigrok4DSL/output/srzip.c b/libsigrok4DSL/output/srzip.c index 2f0d8bca..34e9b1ef 100755 --- a/libsigrok4DSL/output/srzip.c +++ b/libsigrok4DSL/output/srzip.c @@ -72,7 +72,8 @@ static int init(struct sr_output *o, GHashTable *options) /* add zip inner file */ -static int add_file_from_buffer(zipFile zipArchive, zip_fileinfo *zi, const char *innerFile, const char *buffer, unsigned int buferSize) +static int add_file_from_buffer(zipFile zipArchive, zip_fileinfo *zi, const char *innerFile, + const char *buffer, unsigned int buferSize) { assert(buffer); assert(innerFile); @@ -126,10 +127,9 @@ static int create_archive(const struct sr_output *o) GKeyFile *meta; GVariant *gvar; GSList *l; - int tmpfile, ret; const char *devgroup; size_t ch_nr; - char version[1], metafile[32]; + char version[1]; char *s = NULL; int logic_channels = 0; int enabled_logic_channels = 0; @@ -227,7 +227,7 @@ static int create_archive(const struct sr_output *o) /* append data to archive */ -static int append_archive_data(const struct sr_output *o, unsigned char *buf, +static int append_archive_data(const struct sr_output *o, const char *buf, int unitsize, int length) { struct out_context *outc; @@ -247,8 +247,10 @@ static int append_archive_data(const struct sr_output *o, unsigned char *buf, } outc->chunk_index++; - snprintf(chunkname, 15, "logic-1-%d", outc->chunk_index); - add_file_from_buffer(outc->zipArchive, &outc->zi, chunkname, buf, length); + snprintf(chunkname, 19, "logic-1-%d", (short)outc->chunk_index); + + add_file_from_buffer(outc->zipArchive, &outc->zi, + (const char*)chunkname, buf, length); return SR_OK; } diff --git a/libsigrok4DSL/session.c b/libsigrok4DSL/session.c index a6a2c66b..1d0abcac 100644 --- a/libsigrok4DSL/session.c +++ b/libsigrok4DSL/session.c @@ -265,6 +265,8 @@ SR_PRIV int sr_session_stop(void) * * @param packet The packet to show debugging information for. */ + +/* static void datafeed_dump(const struct sr_datafeed_packet *packet) { const struct sr_datafeed_logic *logic; @@ -288,8 +290,8 @@ static void datafeed_dump(const struct sr_datafeed_packet *packet) break; case SR_DF_LOGIC: logic = packet->payload; - sr_dbg("bus: Received SR_DF_LOGIC packet (%llu bytes).", - logic->length); + sr_dbg("bus: Received SR_DF_LOGIC packet (%lu bytes).", + (u64_t)logic->length); break; case SR_DF_DSO: dso = packet->payload; @@ -318,6 +320,7 @@ static void datafeed_dump(const struct sr_datafeed_packet *packet) break; } } +*/ /** * Add an event source for a file descriptor. diff --git a/libsigrok4DSL/session_driver.c b/libsigrok4DSL/session_driver.c index fc6c5f57..ce71d037 100644 --- a/libsigrok4DSL/session_driver.c +++ b/libsigrok4DSL/session_driver.c @@ -167,7 +167,7 @@ static const char *probeMapUnits[] = { static void free_temp_buffer(struct session_vdev *vdev); -static int trans_data(struct sr_dev_inst *sdi) +static int trans_data(const struct sr_dev_inst *sdi) { // translate for old format struct session_vdev *vdev = sdi->priv; @@ -242,7 +242,6 @@ static int receive_data(int fd, int revents, const struct sr_dev_inst *sdi) struct sr_datafeed_logic logic; struct sr_datafeed_dso dso; struct sr_datafeed_analog analog; - GSList *l; int ret; char file_name[32]; struct sr_channel *probe = NULL; @@ -423,7 +422,6 @@ static int receive_data_logic_dso_v2(int fd, int revents, const struct sr_dev_in int ret; char file_name[32]; - int channel; int ch_index, malloc_chan_index; struct session_packet_buffer *pack_buffer; unz_file_info64 fileInfo; @@ -488,7 +486,7 @@ static int receive_data_logic_dso_v2(int fd, int revents, const struct sr_dev_in } pack_buffer = vdev->packet_buffer; - pack_buffer->post_write_len; + pack_buffer->post_write_len = 0; pack_buffer->block_buf_len = 0; pack_buffer->block_data_len = 0; pack_buffer->block_read_len = 0; @@ -663,7 +661,7 @@ static int receive_data_logic_dso_v2(int fd, int revents, const struct sr_dev_in } // Send back. - if (pack_buffer->post_write_len >= byte_align * chan_num) + if (pack_buffer->post_write_len >= (uint64_t)(byte_align * chan_num)) { if (sdi->mode == LOGIC) { @@ -723,7 +721,7 @@ static const GSList *dev_mode_list(const struct sr_dev_inst *sdi) for (i = 0; i < ARRAY_SIZE(sr_mode_list); i++) { if (sdi->mode == sr_mode_list[i].mode) - l = g_slist_append(l, &sr_mode_list[i]); + l = g_slist_append(l, (gpointer)&sr_mode_list[i]); } return l; @@ -1074,19 +1072,19 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, case SR_CONF_SAMPLERATE: vdev->samplerate = g_variant_get_uint64(data); samplerates[0] = vdev->samplerate; - sr_dbg("Setting samplerate to %llu.", vdev->samplerate); + sr_dbg("Setting samplerate to %lu.", (u64_t)vdev->samplerate); break; case SR_CONF_TIMEBASE: vdev->timebase = g_variant_get_uint64(data); - sr_dbg("Setting timebase to %llu.", vdev->timebase); + sr_dbg("Setting timebase to %lu.", (u64_t)vdev->timebase); break; case SR_CONF_MAX_TIMEBASE: vdev->max_timebase = g_variant_get_uint64(data); - sr_dbg("Setting max timebase to %llu.", vdev->max_timebase); + sr_dbg("Setting max timebase to %lu.", (u64_t)vdev->max_timebase); break; case SR_CONF_MIN_TIMEBASE: vdev->min_timebase = g_variant_get_uint64(data); - sr_dbg("Setting min timebase to %llu.", vdev->min_timebase); + sr_dbg("Setting min timebase to %lu.", (u64_t)vdev->min_timebase); break; case SR_CONF_UNIT_BITS: vdev->unit_bits = g_variant_get_byte(data); @@ -1107,19 +1105,19 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi, case SR_CONF_LIMIT_SAMPLES: vdev->total_samples = g_variant_get_uint64(data); samplecounts[0] = vdev->total_samples; - sr_dbg("Setting limit samples to %llu.", vdev->total_samples); + sr_dbg("Setting limit samples to %lu.", (u64_t)vdev->total_samples); break; case SR_CONF_TRIGGER_TIME: vdev->trig_time = g_variant_get_int64(data); - sr_dbg("Setting trigger time to %llu.", vdev->trig_time); + sr_dbg("Setting trigger time to %lu.", (u64_t)vdev->trig_time); break; case SR_CONF_TRIGGER_POS: vdev->trig_pos = g_variant_get_uint64(data); - sr_dbg("Setting trigger position to %llu.", vdev->trig_pos); + sr_dbg("Setting trigger position to %lu.", (u64_t)vdev->trig_pos); break; case SR_CONF_NUM_BLOCKS: vdev->num_blocks = g_variant_get_uint64(data); - sr_dbg("Setting block number to %llu.", vdev->num_blocks); + sr_dbg("Setting block number to %lu.", (u64_t)vdev->num_blocks); break; case SR_CONF_CAPTURE_NUM_PROBES: vdev->num_probes = g_variant_get_uint64(data); @@ -1361,7 +1359,6 @@ static int dev_acquisition_start(struct sr_dev_inst *sdi, void *cb_data) struct session_vdev *vdev; struct sr_datafeed_packet packet; - int ret; GSList *l; struct sr_channel *probe; @@ -1394,8 +1391,8 @@ static int dev_acquisition_start(struct sr_dev_inst *sdi, void *cb_data) if (NULL == vdev->archive) { sr_err("Failed to open session file '%s': " - "zip error %d\n", - sdi->path, ret); + "zip error", + sdi->path); return SR_ERR; } @@ -1563,7 +1560,7 @@ SR_PRIV int sr_new_virtual_device(const char *filename, struct sr_dev_inst **out sdi->dev_type = DEV_TYPE_FILELOG; get_file_short_name(filename, short_name, sizeof(short_name) - 1); - strncpy(sdi->name, short_name, sizeof(short_name) - 1); + strncpy(sdi->name, (char*)short_name, sizeof(short_name) - 1); sdi->path = g_strdup(filename); *out_di = sdi; @@ -1579,7 +1576,7 @@ static int sr_load_virtual_device_session(struct sr_dev_inst *sdi) unz_file_info64 fileInfo; struct sr_channel *probe; - int ret, devcnt, i, j; + int devcnt, i, j; uint16_t probenum; uint64_t tmp_u64, total_probes, enabled_probes; uint16_t p; diff --git a/libsigrok4DSL/strutil.c b/libsigrok4DSL/strutil.c index 18839792..38dc691c 100644 --- a/libsigrok4DSL/strutil.c +++ b/libsigrok4DSL/strutil.c @@ -62,24 +62,24 @@ SR_API char *sr_si_string_u64(uint64_t x, const char *unit) unit = ""; if ((x >= SR_GHZ(1)) && (x % SR_GHZ(1) == 0)) { - return g_strdup_printf("%llu G%s", x / SR_GHZ(1), unit); + return g_strdup_printf("%lu G%s", (u64_t)(x / SR_GHZ(1)), unit); } else if ((x >= SR_GHZ(1)) && (x % SR_GHZ(1) != 0)) { - return g_strdup_printf("%llu.%llu G%s", - x / SR_GHZ(1), x % SR_GHZ(1), unit); + return g_strdup_printf("%lu.%lu G%s", + (u64_t)(x / SR_GHZ(1)), (u64_t)(x % SR_GHZ(1)), unit); } else if ((x >= SR_MHZ(1)) && (x % SR_MHZ(1) == 0)) { - return g_strdup_printf("%llu M%s", - x / SR_MHZ(1), unit); + return g_strdup_printf("%lu M%s", + (u64_t)(x / SR_MHZ(1)), unit); } else if ((x >= SR_MHZ(1)) && (x % SR_MHZ(1) != 0)) { - return g_strdup_printf("%llu.%llu M%s", - x / SR_MHZ(1), x % SR_MHZ(1), unit); + return g_strdup_printf("%lu.%lu M%s", + (u64_t)(x / SR_MHZ(1)), (u64_t)(x % SR_MHZ(1)), unit); } else if ((x >= SR_KHZ(1)) && (x % SR_KHZ(1) == 0)) { - return g_strdup_printf("%llu k%s", - x / SR_KHZ(1), unit); + return g_strdup_printf("%lu k%s", + (u64_t)(x / SR_KHZ(1)), unit); } else if ((x >= SR_KHZ(1)) && (x % SR_KHZ(1) != 0)) { - return g_strdup_printf("%llu.%llu K%s", - x / SR_KHZ(1), x % SR_KHZ(1), unit); + return g_strdup_printf("%lu.%lu K%s", + (u64_t)(x / SR_KHZ(1)), (u64_t)(x % SR_KHZ(1)), unit); } else { - return g_strdup_printf("%llu %s", x, unit); + return g_strdup_printf("%lu %s", (u64_t)x, unit); } sr_err("%s: Error creating SI units string.", __func__); @@ -107,24 +107,24 @@ SR_API char *sr_iec_string_u64(uint64_t x, const char *unit) unit = ""; if ((x >= SR_GB(1)) && (x % SR_GB(1) == 0)) { - return g_strdup_printf("%llu G%s", x / SR_GB(1), unit); + return g_strdup_printf("%lu G%s", (u64_t)(x / SR_GB(1)), unit); } else if ((x >= SR_GB(1)) && (x % SR_GB(1) != 0)) { - return g_strdup_printf("%llu.%llu G%s", - x / SR_GB(1), x % SR_GB(1), unit); + return g_strdup_printf("%lu.%lu G%s", + (u64_t)(x / SR_GB(1)), (u64_t)(x % SR_GB(1)), unit); } else if ((x >= SR_MB(1)) && (x % SR_MB(1) == 0)) { - return g_strdup_printf("%llu M%s", - x / SR_MB(1), unit); + return g_strdup_printf("%lu M%s", + (u64_t)(x / SR_MB(1)), unit); } else if ((x >= SR_MB(1)) && (x % SR_MB(1) != 0)) { - return g_strdup_printf("%llu.%llu M%s", - x / SR_MB(1), x % SR_MB(1), unit); + return g_strdup_printf("%lu.%lu M%s", + (u64_t)(x / SR_MB(1)), (u64_t)(x % SR_MB(1)), unit); } else if ((x >= SR_KB(1)) && (x % SR_KB(1) == 0)) { - return g_strdup_printf("%llu k%s", - x / SR_KB(1), unit); + return g_strdup_printf("%lu k%s", + (u64_t)(x / SR_KB(1)), unit); } else if ((x >= SR_KB(1)) && (x % SR_KB(1) != 0)) { - return g_strdup_printf("%llu.%llu K%s", - x / SR_KB(1), x % SR_KB(1), unit); + return g_strdup_printf("%lu.%lu K%s", + (u64_t)(x / SR_KB(1)), (u64_t)(x % SR_KB(1)), unit); } else { - return g_strdup_printf("%llu %s", x, unit); + return g_strdup_printf("%lu %s", (u64_t)x, unit); } sr_err("%s: Error creating SI units string.", __func__); @@ -188,13 +188,13 @@ SR_API char *sr_period_string(uint64_t frequency) } if (frequency >= SR_GHZ(1)) - r = snprintf(o, 30, "%llu ns", frequency / 1000000000); + r = snprintf(o, 30, "%lu ns", (u64_t)(frequency / 1000000000)); else if (frequency >= SR_MHZ(1)) - r = snprintf(o, 30, "%llu us", frequency / 1000000); + r = snprintf(o, 30, "%lu us", (u64_t)(frequency / 1000000)); else if (frequency >= SR_KHZ(1)) - r = snprintf(o, 30, "%llu ms", frequency / 1000); + r = snprintf(o, 30, "%lu ms", (u64_t)(frequency / 1000)); else - r = snprintf(o, 30, "%llu s", frequency); + r = snprintf(o, 30, "%lu s", (u64_t)frequency); if (r < 0) { /* Something went wrong... */ @@ -241,7 +241,7 @@ SR_API char *sr_time_string(uint64_t time) else if (time >= SR_US(1)) r = snprintf(o, 30, "%0.2lf us", time * 1.0 / SR_US(1)); else - r = snprintf(o, 30, "%llu ns", time); + r = snprintf(o, 30, "%lu ns", (u64_t)time); if (r < 0) { /* Something went wrong... */ @@ -277,9 +277,9 @@ SR_API char *sr_voltage_string(uint64_t v_p, uint64_t v_q) } if (v_q == 1000) - r = snprintf(o, 30, "%llumV", v_p); + r = snprintf(o, 30, "%lumV", (u64_t)v_p); else if (v_q == 1) - r = snprintf(o, 30, "%lluV", v_p); + r = snprintf(o, 30, "%luV", (u64_t)v_p); else r = snprintf(o, 30, "%gV", (float)v_p / (float)v_q); diff --git a/libsigrok4DSL/tests/lib.c b/libsigrok4DSL/tests/lib.c index 296f7b08..2fbc9d4d 100644 --- a/libsigrok4DSL/tests/lib.c +++ b/libsigrok4DSL/tests/lib.c @@ -117,6 +117,6 @@ void srtest_check_samplerate(struct sr_context *sr_ctx, const char *drivername, srtest_driver_init(sr_ctx, driver);; srtest_set_samplerate(driver, samplerate); s = srtest_get_samplerate(driver); - fail_unless(s == samplerate, "%s: Incorrect samplerate: %llu.", - drivername, s); + fail_unless(s == samplerate, "%s: Incorrect samplerate: %lu.", + drivername, (u64_t)s); } diff --git a/libsigrok4DSL/trigger.c b/libsigrok4DSL/trigger.c index 4a25e190..91ed3dd6 100644 --- a/libsigrok4DSL/trigger.c +++ b/libsigrok4DSL/trigger.c @@ -119,6 +119,8 @@ SR_API int ds_trigger_stage_set_value(uint16_t stage, uint16_t probes, char *tri } SR_API int ds_trigger_stage_set_logic(uint16_t stage, uint16_t probes, unsigned char trigger_logic) { + (void)probes; + assert(stage < TriggerStages); assert(probes <= MaxTriggerProbes); @@ -133,6 +135,8 @@ SR_API int ds_trigger_stage_set_logic(uint16_t stage, uint16_t probes, unsigned } SR_API int ds_trigger_stage_set_inv(uint16_t stage, uint16_t probes, unsigned char trigger0_inv, unsigned char trigger1_inv) { + (void)probes; + assert(stage < TriggerStages); assert(probes <= MaxTriggerProbes); @@ -148,6 +152,8 @@ SR_API int ds_trigger_stage_set_inv(uint16_t stage, uint16_t probes, unsigned ch } SR_API int ds_trigger_stage_set_count(uint16_t stage, uint16_t probes, uint32_t trigger0_count, uint32_t trigger1_count) { + (void)probes; + assert(stage < TriggerStages); assert(probes <= MaxTriggerProbes); diff --git a/libsigrokdecode4DSL/decoder.c b/libsigrokdecode4DSL/decoder.c index 7504a83a..aaca65c2 100644 --- a/libsigrokdecode4DSL/decoder.c +++ b/libsigrokdecode4DSL/decoder.c @@ -732,7 +732,7 @@ SRD_API int srd_decoder_load(const char *module_name) struct srd_decoder *d; long apiver; int is_subclass; - const char *fail_txt; + const char *fail_txt = NULL; PyGILState_STATE gstate; if (!srd_check_init()) @@ -920,8 +920,10 @@ except_out: fail_txt = NULL; err_out: - if (fail_txt) + if (fail_txt != NULL){ srd_err("Failed to load decoder %s: %s", module_name, fail_txt); + } + decoder_free(d); PyGILState_Release(gstate); @@ -1102,7 +1104,6 @@ static void srd_decoder_load_all_path(char *path) { GDir *dir; const gchar *direntry; - int ldst = 0; assert(path); @@ -1119,7 +1120,7 @@ static void srd_decoder_load_all_path(char *path) */ while ((direntry = g_dir_read_name(dir)) != NULL) { /* The directory name is the module name (e.g. "i2c"). */ - ldst = srd_decoder_load(direntry); + srd_decoder_load(direntry); } g_dir_close(dir); } diff --git a/libsigrokdecode4DSL/type_decoder.c b/libsigrokdecode4DSL/type_decoder.c index a5b4a0e4..26685840 100644 --- a/libsigrokdecode4DSL/type_decoder.c +++ b/libsigrokdecode4DSL/type_decoder.c @@ -57,11 +57,10 @@ static void release_annotation(struct srd_proto_data_annotation *pda) static int py_parse_ann_data(PyObject *list_obj, char ***out_strv, int list_size, char *hex_str_buf, long long *numberic_value) { - PyObject *py_item, *py_bytes; + PyObject *py_bytes; char **strv, *str; PyGILState_STATE gstate; int ret = SRD_ERR_PYTHON; - int ijmp = 0; int text_num = 0; PyObject* text_items[10]; PyObject *py_tmp; @@ -183,7 +182,7 @@ static int convert_annotation(struct srd_decoder_inst *di, PyObject *obj, { PyObject *py_tmp; struct srd_proto_data_annotation *pda; - unsigned int ann_class; + int ann_class; char **ann_text; gpointer ann_type_ptr; PyGILState_STATE gstate; @@ -219,12 +218,8 @@ static int convert_annotation(struct srd_decoder_inst *di, PyObject *obj, goto err; } ann_class = PyLong_AsLong(py_tmp); -// if (!(pdo = g_slist_nth_data(di->decoder->annotations, ann_class))) { -// srd_err("Protocol decoder %s submitted data to unregistered " -// "annotation class %d.", di->decoder->name, ann_class); -// return SRD_ERR_PYTHON; -// } - if (ann_class >= g_slist_length(di->decoder->ann_types) || ann_class < 0) { + + if ((ann_class >= (int)g_slist_length(di->decoder->ann_types)) || ann_class < 0) { srd_err("Protocol decoder %s submitted data to unregistered " "annotation class %d.", di->decoder->name, ann_class); goto err; @@ -684,7 +679,7 @@ static PyObject *Decoder_register(PyObject *self, PyObject *args, if (pdo == NULL){ PyGILState_Release(gstate); srd_err("%s,ERROR:failed to alloc memory.", __func__); - return SRD_ERR; + return NULL; } memset(pdo, 0, sizeof(struct srd_pd_output)); @@ -1017,7 +1012,7 @@ static int set_skip_condition(struct srd_decoder_inst *di, uint64_t count) assert(di); struct srd_term *term; - GSList *term_list; + GSList *term_list = NULL; condition_list_free(di); @@ -1033,7 +1028,9 @@ static int set_skip_condition(struct srd_decoder_inst *di, uint64_t count) srd_err("%s,ERROR:failed to alloc memory.", __func__); } - di->condition_list = g_slist_append(di->condition_list, term_list); + if (term_list != NULL){ + di->condition_list = g_slist_append(di->condition_list, term_list); + } return SRD_OK; } @@ -1282,7 +1279,7 @@ static PyMethodDef Decoder_methods[] = { { "put", Decoder_put, METH_VARARGS, "Accepts a dictionary with the following keys: startsample, endsample, data" }, - { "register", (PyCFunction)Decoder_register, METH_VARARGS|METH_KEYWORDS, + { "register", (PyCFunction)((void*)&Decoder_register), METH_VARARGS|METH_KEYWORDS, "Register a new output stream" }, { "wait", Decoder_wait, METH_VARARGS,