13
0

Fix some clang-scan warnings

This commit is contained in:
Robin Gareus 2020-01-27 03:31:49 +01:00
parent cf4d7387d2
commit fc7dd5115d
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
5 changed files with 15 additions and 15 deletions

View File

@ -76,6 +76,8 @@ EventRingBuffer<Time>::peek (uint8_t* buf, size_t size)
return false;
}
assert (vec.len[0] > 0 || vec.len[1] > 0);
if (vec.len[0] > 0) {
memcpy (buf, vec.buf[0], std::min (vec.len[0], size));
}

View File

@ -455,40 +455,34 @@ MidiModel::NoteDiffCommand::marshal_note(const NotePtr note)
Evoral::Sequence<MidiModel::TimeType>::NotePtr
MidiModel::NoteDiffCommand::unmarshal_note (XMLNode *xml_note)
{
Evoral::event_id_t id;
Evoral::event_id_t id = -1;
if (!xml_note->get_property ("id", id)) {
error << "note information missing ID value" << endmsg;
id = -1;
}
uint8_t note;
uint8_t note = 127;
if (!xml_note->get_property("note", note)) {
warning << "note information missing note value" << endmsg;
note = 127;
}
uint8_t channel;
uint8_t channel = 0;
if (!xml_note->get_property("channel", channel)) {
warning << "note information missing channel" << endmsg;
channel = 0;
}
MidiModel::TimeType time;
MidiModel::TimeType time = MidiModel::TimeType();
if (!xml_note->get_property("time", time)) {
warning << "note information missing time" << endmsg;
time = MidiModel::TimeType();
}
MidiModel::TimeType length;
MidiModel::TimeType length = MidiModel::TimeType(1);
if (!xml_note->get_property("length", length)) {
warning << "note information missing length" << endmsg;
length = MidiModel::TimeType(1);
}
uint8_t velocity;
uint8_t velocity = 127;
if (!xml_note->get_property("velocity", velocity)) {
warning << "note information missing velocity" << endmsg;
velocity = 127;
}
NotePtr note_ptr(new Evoral::Note<TimeType>(channel, time, length, note, velocity));

View File

@ -147,7 +147,8 @@ MidiRingBuffer<T>::skip_to(samplepos_t start)
while (this->read_space() >= prefix_size) {
uint8_t peekbuf[prefix_size];
this->peek (peekbuf, prefix_size);
bool r = this->peek (peekbuf, prefix_size);
assert (r);
ev_time = *(reinterpret_cast<T*>((uintptr_t)peekbuf));
ev_size = *(reinterpret_cast<uint32_t*>((uintptr_t)(peekbuf + sizeof(T) + sizeof (Evoral::EventType))));
@ -163,7 +164,7 @@ MidiRingBuffer<T>::skip_to(samplepos_t start)
this->increment_read_ptr (prefix_size);
uint8_t status;
bool r = this->peek (&status, sizeof(uint8_t));
r = this->peek (&status, sizeof(uint8_t));
assert (r); // If this failed, buffer is corrupt, all hope is lost
++count;

View File

@ -3407,11 +3407,12 @@ TempoMap::gui_stretch_tempo (TempoSection* ts, const samplepos_t sample, const s
if (ts_copy->clamped()) {
TempoSection* next_t = next_tempo_section_locked (future_map, ts_copy);
TempoSection* prev_to_ts_copy = previous_tempo_section_locked (future_map, ts_copy);
assert (prev_to_ts_copy);
/* the change in samples is the result of changing the slope of at most 2 previous tempo sections.
* constant to constant is straightforward, as the tempo prev to ts_copy has constant slope.
*/
double contribution = 0.0;
if (next_t && prev_to_ts_copy && prev_to_ts_copy->type() == TempoSection::Ramp) {
if (next_t && prev_to_ts_copy->type() == TempoSection::Ramp) {
contribution = (ts_copy->pulse() - prev_to_ts_copy->pulse()) / (double) (next_t->pulse() - prev_to_ts_copy->pulse());
}
samplepos_t const fr_off = end_sample - sample;

View File

@ -18,6 +18,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@ -392,6 +393,7 @@ TruePeakdsp::process (float const *d, int n)
float x = 0;
float v;
assert (_buf);
float *b = _buf;
while (n--) {
v = fabsf(*b++);