Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang-tidy: Apply modernize-avoid-c-arrays everywhere #6564

Merged
merged 28 commits into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a32bd70
Phase 1: Apply modernize-avoid-c-arrays everywhere
sakertooth Nov 8, 2022
7f43461
Phase 2: Apply modernize-avoid-c-arrays everywhere
sakertooth Nov 8, 2022
ed16818
Changing code until it compiles on the GHA Part 1
sakertooth Nov 8, 2022
953d066
Fix compilation error in ProjectRenderer.cpp
sakertooth Nov 8, 2022
0370c6c
Fix -Wformat warnings in ProjectRenderer.cpp
sakertooth Nov 8, 2022
0c6c864
Fix compilation errors in PianoRoll.cpp
sakertooth Nov 9, 2022
abd4212
Include <array> header in LmmsStyle.cpp
sakertooth Nov 9, 2022
aa3c93b
Remove ifndef _MSC_VER preprocessor directive in Sf2Instrument::noteOn
sakertooth Nov 9, 2022
4aacc24
Revert changes made in DrumSynth.cpp
sakertooth Nov 9, 2022
fe69e03
Remove "indef __GNUC__" preprocessor in VstEffect::processAudioBuffer
sakertooth Nov 9, 2022
c60a893
Fix incorrect type deduction in plugins/Compressor/CompressorControlD…
sakertooth Nov 10, 2022
368dcf3
Change sizeof(buf) to buf.size() in src/core/midi/MidiAlsaRaw.cpp
sakertooth Nov 10, 2022
9a6d4c7
Revert changes that affected realtime safety
sakertooth Nov 12, 2022
8ed58e5
Use std::vector<sample_t> rather than std::unique_ptr<sample_t[]> in …
sakertooth Nov 12, 2022
f259a05
Transform C-style array to std::array in Compressor.cpp
sakertooth Nov 12, 2022
6e16b93
Use auto and omit template arguments for DataFile.cpp, InstrumentFunc…
sakertooth Nov 29, 2022
19260a4
Revert "Use auto and omit template arguments for DataFile.cpp, Instru…
sakertooth Nov 29, 2022
625688b
Move typeDescStruct into DataFile.cpp
sakertooth Dec 17, 2022
59d529c
Use std::array for s_initTable
sakertooth Dec 17, 2022
75c86f5
Use std::vector<int_sample_t> over std::unique_ptr
sakertooth Dec 17, 2022
41a623c
Replace sizeof with .size
sakertooth Dec 17, 2022
7088fe3
Use .size rather than sizeof in Lv2Proc
sakertooth Dec 17, 2022
6c38307
Replace auto with full type name
sakertooth Dec 17, 2022
cab2d68
Fix NUM_CHORD_TABLES being undefined
sakertooth Dec 17, 2022
ed30c21
Wrap typeDescStruct in an unnamed namespace
sakertooth Dec 17, 2022
918b7bb
Remove LMMS_EXPORT from typeDescStruct
sakertooth Dec 20, 2022
ff65206
Remove trailing whitespace
sakertooth Dec 23, 2022
00a0881
Update plugins/BassBooster/BassBooster.cpp
sakertooth Dec 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/DataFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class LMMS_EXPORT DataFile : public QDomDocument
Type m_type;
QString m_name;
} ;
static typeDescStruct s_types[TypeCount];
static std::array<typeDescStruct, TypeCount> s_types;

QString m_fileName; //!< The origin file name or "" if this DataFile didn't originate from a file
QDomElement m_content;
Expand Down
2 changes: 1 addition & 1 deletion include/InstrumentFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class InstrumentFunctionNoteStacking : public Model, public JournallingObject
ChordSemiTones m_semiTones;
};

static Init s_initTable[];
static std::vector<Init> s_initTable;

public:
static const ChordTable & getInstance()
Expand Down
2 changes: 1 addition & 1 deletion include/Oscillator.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ class LMMS_EXPORT Oscillator
static fftwf_plan s_fftPlan;
static fftwf_plan s_ifftPlan;
static fftwf_complex * s_specBuf;
static float s_sampleBuffer[OscillatorConstants::WAVETABLE_LENGTH];
static std::array<float, OscillatorConstants::WAVETABLE_LENGTH> s_sampleBuffer;

static void generateSawWaveTable(int bands, sample_t* table, int firstBand = 1);
static void generateTriangleWaveTable(int bands, sample_t* table, int firstBand = 1);
Expand Down
2 changes: 1 addition & 1 deletion include/PianoRoll.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ protected slots:
static QPixmap * s_toolOpen;
static QPixmap* s_toolKnife;

static PianoRollKeyTypes prKeyOrder[];
static std::array<PianoRollKeyTypes, 12> prKeyOrder;

static TextFloat * s_textFloat;

Expand Down
2 changes: 1 addition & 1 deletion include/ProjectRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class LMMS_EXPORT ProjectRenderer : public QThread

static QString getFileExtensionFromFormat( ExportFileFormats fmt );

static const FileEncodeDevice fileEncodeDevices[];
static const std::array<FileEncodeDevice, 5> fileEncodeDevices;

public slots:
void startProcessing();
Expand Down
2 changes: 1 addition & 1 deletion plugins/Amplifier/Amplifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ bool AmplifierEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames )
{
// qDebug( "offset %d, value %f", f, m_ampControls.m_volumeModel.value( f ) );

sample_t s[2] = { buf[f][0], buf[f][1] };
auto s = std::array{buf[f][0], buf[f][1]};

// vol knob
if( volBuf )
Expand Down
2 changes: 1 addition & 1 deletion plugins/BassBooster/BassBooster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ bool BassBoosterEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames
m_bbFX.leftFX().setGain( gain );
m_bbFX.rightFX().setGain( gain);

sample_t s[2] = { buf[f][0], buf[f][1] };
auto s = std::array {buf[f][0], buf[f][1]};
m_bbFX.nextSample( s[0], s[1] );

buf[f][0] = d * buf[f][0] + w * s[0];
Expand Down
4 changes: 2 additions & 2 deletions plugins/Bitcrush/Bitcrush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ const int OS_RATE = 5;
const float OS_RATIO = 1.0f / OS_RATE;
const float CUTOFF_RATIO = 0.353553391f;
const int SILENCEFRAMES = 10;
const float OS_RESAMPLE [5] = { 0.0001490062883964112, 0.1645978376763992, 0.6705063120704088,
0.1645978376763992, 0.0001490062883964112 };
const auto OS_RESAMPLE = std::array{0.0001490062883964112f, 0.1645978376763992f, 0.6705063120704088f,
0.1645978376763992f, 0.0001490062883964112f };

extern "C"
{
Expand Down
6 changes: 3 additions & 3 deletions plugins/Compressor/Compressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ bool CompressorEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames)

for(fpp_t f = 0; f < frames; ++f)
{
sample_t drySignal[2] = {buf[f][0], buf[f][1]};
auto drySignal = std::array{buf[f][0], buf[f][1]};
sample_t s[2] = {drySignal[0] * m_inGainVal, drySignal[1] * m_inGainVal};

// Calculate tilt filters, to bias the sidechain to the low or high frequencies
Expand Down Expand Up @@ -512,7 +512,7 @@ bool CompressorEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames)
m_inputBufLoc = 0;
}

const float temp[2] = {drySignal[0], drySignal[1]};
const auto temp = std::array{drySignal[0], drySignal[1]};
s[0] = m_inputBuf[0][m_inputBufLoc];
s[1] = m_inputBuf[1][m_inputBufLoc];

Expand All @@ -525,7 +525,7 @@ bool CompressorEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames)
s[1] = drySignal[1];
}

float delayedDrySignal[2] = {s[0], s[1]};
auto delayedDrySignal = std::array{s[0], s[1]};

if (midside)// Convert left/right to mid/side
{
Expand Down
4 changes: 2 additions & 2 deletions plugins/Compressor/CompressorControlDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,8 @@ void CompressorControlDialog::redrawKnee()
{
m_p.setPen(QPen(m_kneeColor2, 3));

float prevPoint[2] = {kneePoint1, kneePoint1};
float newPoint[2] = {0, 0};
auto prevPoint = std::array{kneePoint1, kneePoint1};
auto newPoint = std::array{0, 0};

// Draw knee curve using many straight lines.
for (int i = 0; i < COMP_KNEE_LINES; ++i)
Expand Down
2 changes: 1 addition & 1 deletion plugins/Delay/DelayEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ bool DelayEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames )
const float sr = Engine::audioEngine()->processingSampleRate();
const float d = dryLevel();
const float w = wetLevel();
sample_t dryS[2];
auto dryS = std::array<sample_t, 2>{};
float lPeak = 0.0;
float rPeak = 0.0;
float length = m_delayControls.m_delayTimeModel.value();
Expand Down
6 changes: 3 additions & 3 deletions plugins/DualFilter/DualFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ bool DualFilterEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames
const float mix1 = 1.0f - mix2;
const float gain1 = *gain1Ptr * 0.01f;
const float gain2 = *gain2Ptr * 0.01f;
sample_t s[2] = { 0.0f, 0.0f }; // mix
sample_t s1[2] = { buf[f][0], buf[f][1] }; // filter 1
sample_t s2[2] = { buf[f][0], buf[f][1] }; // filter 2
auto s = std::array{0.0f, 0.0f}; // mix
auto s1 = std::array{buf[f][0], buf[f][1]}; // filter 1
auto s2 = std::array{buf[f][0], buf[f][1]}; // filter 2

// update filter 1
if( enabled1 )
Expand Down
4 changes: 2 additions & 2 deletions plugins/DynamicsProcessor/DynamicsProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ bool DynProcEffect::processAudioBuffer( sampleFrame * _buf,
// variables for effect
int i = 0;

float sm_peak[2] = { 0.0f, 0.0f };
auto sm_peak = std::array{0.0f, 0.0f};
float gain;

double out_sum = 0.0;
Expand Down Expand Up @@ -143,7 +143,7 @@ bool DynProcEffect::processAudioBuffer( sampleFrame * _buf,

for( fpp_t f = 0; f < _frames; ++f )
{
double s[2] = { _buf[f][0], _buf[f][1] };
auto s = std::array{_buf[f][0], _buf[f][1]};

// apply input gain
s[0] *= inputGain;
Expand Down
2 changes: 1 addition & 1 deletion plugins/DynamicsProcessor/DynamicsProcessorControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void DynProcControls::saveSettings( QDomDocument & _doc,

void DynProcControls::setDefaultShape()
{
float shp [200] = { };
auto shp = std::array<float, 200>{};
for ( int i = 0; i<200; i++)
{
shp[i] = ((float)i + 1.0f) / 200.0f;
Expand Down
2 changes: 1 addition & 1 deletion plugins/Eq/EqEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ bool EqEffect::processAudioBuffer( sampleFrame *buf, const fpp_t frames )
//wet/dry controls
const float dry = dryLevel();
const float wet = wetLevel();
sample_t dryS[2];
auto dryS = std::array<sample_t, 2>{};
// setup sample exact controls
float hpRes = m_eqControls.m_hpResModel.value();
float lowShelfRes = m_eqControls.m_lowShelfResModel.value();
Expand Down
2 changes: 1 addition & 1 deletion plugins/Flanger/FlangerEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ bool FlangerEffect::processAudioBuffer( sampleFrame *buf, const fpp_t frames )
m_lfo->setOffset( m_flangerControls.m_lfoPhaseModel.value() / 180 * D_PI );
m_lDelay->setFeedback( m_flangerControls.m_feedbackModel.value() );
m_rDelay->setFeedback( m_flangerControls.m_feedbackModel.value() );
sample_t dryS[2];
auto dryS = std::array<sample_t, 2>{};
float leftLfo;
float rightLfo;
for( fpp_t f = 0; f < frames; ++f )
Expand Down
6 changes: 3 additions & 3 deletions plugins/FreeBoy/FreeBoy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ void FreeBoyInstrument::playNote( NotePlayHandle * _n,
data = 128;
papu->write_register( fakeClock(), 0xff1a, data );

int ch3voldata[4] = { 0, 3, 2, 1 };
auto ch3voldata = std::array{0, 3, 2, 1};
data = ch3voldata[(int)m_ch3VolumeModel.value()];
data = data<<5;
papu->write_register( fakeClock(), 0xff1c, data );
Expand Down Expand Up @@ -388,7 +388,7 @@ void FreeBoyInstrument::playNote( NotePlayHandle * _n,
int const buf_size = 2048;
int framesleft = frames;
int datalen = 0;
blip_sample_t buf [buf_size*2];
auto buf = std::array<blip_sample_t, buf_size * 2>{};
while( framesleft > 0 )
{
int avail = papu->samples_avail();
Expand All @@ -401,7 +401,7 @@ void FreeBoyInstrument::playNote( NotePlayHandle * _n,
datalen = framesleft>avail?avail:framesleft;
datalen = datalen>buf_size?buf_size:datalen;

long count = papu->read_samples( buf, datalen*2)/2;
long count = papu->read_samples(buf.data(), datalen * 2) / 2;

for( fpp_t frame = 0; frame < count; ++frame )
{
Expand Down
10 changes: 5 additions & 5 deletions plugins/GigPlayer/GigPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,8 @@ void GigInstrument::play( sampleFrame * _working_buffer )
}

// Load this note's data
sampleFrame sampleData[samples];
loadSample(sample, sampleData, samples);
auto sampleData = std::vector<sampleFrame>{static_cast<size_t>(samples)};
loadSample(sample, sampleData.data(), samples);

// Apply ADSR using a copy so if we don't use these samples when
// resampling, the ADSR doesn't get messed up
Expand All @@ -460,10 +460,10 @@ void GigInstrument::play( sampleFrame * _working_buffer )
// Output the data resampling if needed
if( resample == true )
{
sampleFrame convertBuf[frames];
auto convertBuf = std::vector<sampleFrame>{static_cast<size_t>(frames)};

// Only output if resampling is successful (note that "used" is output)
if (sample.convertSampleRate(*sampleData, *convertBuf, samples, frames, freq_factor, used))
if (sample.convertSampleRate(*sampleData.data(), *convertBuf.data(), samples, frames, freq_factor, used))
{
for( f_cnt_t i = 0; i < frames; ++i )
{
Expand Down Expand Up @@ -531,7 +531,7 @@ void GigInstrument::loadSample( GigSample& sample, sampleFrame* sampleData, f_cn
}

unsigned long allocationsize = samples * sample.sample->FrameSize;
int8_t buffer[allocationsize];
auto buffer = std::vector<int8_t>(allocationsize);

// Load the sample in different ways depending on if we're looping or not
if( loop == true && ( sample.pos >= loopStart || sample.pos + samples > loopStart ) )
Expand Down
2 changes: 1 addition & 1 deletion plugins/LadspaEffect/LadspaEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ void LadspaEffect::pluginInstantiation()

int inputch = 0;
int outputch = 0;
LADSPA_Data * inbuf [2];
std::array<LADSPA_Data*, 2> inbuf;
inbuf[0] = nullptr;
inbuf[1] = nullptr;
for( ch_cnt_t proc = 0; proc < processorCount(); proc++ )
Expand Down
14 changes: 7 additions & 7 deletions plugins/MidiExport/MidiExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks,


int nTracks = 0;
uint8_t buffer[BUFFER_SIZE];
auto buffer = std::array<uint8_t, BUFFER_SIZE>{};
uint32_t size;

for (const Track* track : tracks) if (track->type() == Track::InstrumentTrack) nTracks++;
for (const Track* track : patternStoreTracks) if (track->type() == Track::InstrumentTrack) nTracks++;

// midi header
MidiFile::MIDIHeader header(nTracks);
size = header.writeToBuffer(buffer);
midiout.writeRawData((char *)buffer, size);
size = header.writeToBuffer(buffer.data());
midiout.writeRawData((char *)buffer.data(), size);

std::vector<std::vector<std::pair<int,int>>> plists;

Expand Down Expand Up @@ -139,8 +139,8 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks,
}
processPatternNotes(midiClip, INT_MAX);
writeMidiClipToTrack(mtrack, midiClip);
size = mtrack.writeToBuffer(buffer);
midiout.writeRawData((char *)buffer, size);
size = mtrack.writeToBuffer(buffer.data());
midiout.writeRawData((char *)buffer.data(), size);
}

if (track->type() == Track::PatternTrack)
Expand Down Expand Up @@ -254,8 +254,8 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks,
++itr;
}
}
size = mtrack.writeToBuffer(buffer);
midiout.writeRawData((char *)buffer, size);
size = mtrack.writeToBuffer(buffer.data());
midiout.writeRawData((char *)buffer.data(), size);
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion plugins/MidiImport/MidiImport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ bool MidiImport::readSMF( TrackContainer* tc )
pd.setValue( 1 );

// 128 CC + Pitch Bend
smfMidiCC ccs[MIDI_CC_COUNT];
auto ccs = std::array<smfMidiCC, MIDI_CC_COUNT>{};

// channel to CC object for program changes
std::unordered_map<long, smfMidiCC> pcs;
Expand Down
4 changes: 2 additions & 2 deletions plugins/Monstro/Monstro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,8 @@ inline void MonstroSynth::updateModulators( float * env1, float * env2, float *
// frames played before
const f_cnt_t tfp = m_nph->totalFramesPlayed();

float * lfo [2];
float * env [2];
auto lfo = std::array<float*, 2>{};
auto env = std::array<float*, 2>{};
lfo[0] = lfo1;
lfo[1] = lfo2;
env[0] = env1;
Expand Down
12 changes: 6 additions & 6 deletions plugins/OpulenZ/OpulenZ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *m, void * )
QMutex OpulenzInstrument::emulatorMutex;

// Weird ordering of voice parameters
const unsigned int adlib_opadd[OPL2_VOICES] = {0x00, 0x01, 0x02, 0x08, 0x09, 0x0A, 0x10, 0x11, 0x12};
const auto adlib_opadd = std::array<unsigned int, OPL2_VOICES>{0x00, 0x01, 0x02, 0x08, 0x09, 0x0A, 0x10, 0x11, 0x12};

OpulenzInstrument::OpulenzInstrument( InstrumentTrack * _instrument_track ) :
Instrument( _instrument_track, &opulenz_plugin_descriptor ),
Expand Down Expand Up @@ -534,7 +534,7 @@ void OpulenzInstrument::loadGMPatch() {

// Update patch from the models to the chip emulation
void OpulenzInstrument::updatePatch() {
unsigned char inst[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
auto inst = std::array<unsigned char, 14>{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
inst[0] = ( op1_trem_mdl.value() ? 128 : 0 ) +
( op1_vib_mdl.value() ? 64 : 0 ) +
( op1_perc_mdl.value() ? 0 : 32 ) + // NB. This envelope mode is "perc", not "sus"
Expand Down Expand Up @@ -583,7 +583,7 @@ void OpulenzInstrument::updatePatch() {
#endif


loadPatch(inst);
loadPatch(inst.data());
}

// Load an SBI file into the knob models
Expand Down Expand Up @@ -782,19 +782,19 @@ void OpulenzInstrumentView::updateKnobHints()
{
// Envelope times in ms: t[0] = 0, t[n] = ( 1<<n ) * X, X = 0.11597 for A, 0.6311 for D/R
// Here some rounding has been applied.
const float attack_times[16] = {
const auto attack_times = std::array<float, 16>{
0.0, 0.2, 0.4, 0.9, 1.8, 3.7, 7.4,
15.0, 30.0, 60.0, 120.0, 240.0, 480.0,
950.0, 1900.0, 3800.0
};

const float dr_times[16] = {
const auto dr_times = std::array<float, 16>{
0.0, 1.2, 2.5, 5.0, 10.0, 20.0, 40.0,
80.0, 160.0, 320.0, 640.0, 1300.0, 2600.0,
5200.0, 10000.0, 20000.0
};

const int fmultipliers[16] = {
const auto fmultipliers = std::array<int, 16>{
-12, 0, 12, 19, 24, 28, 31, 34, 36, 38, 40, 40, 43, 43, 47, 47
};

Expand Down
6 changes: 3 additions & 3 deletions plugins/Organic/Organic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ void OrganicInstrument::playNote( NotePlayHandle * _n,

if( _n->totalFramesPlayed() == 0 || _n->m_pluginData == nullptr )
{
Oscillator * oscs_l[NUM_OSCILLATORS];
Oscillator * oscs_r[NUM_OSCILLATORS];
auto oscs_l = std::array<Oscillator*, NUM_OSCILLATORS>{};
auto oscs_r = std::array<Oscillator*, NUM_OSCILLATORS>{};

_n->m_pluginData = new oscPtr;

Expand Down Expand Up @@ -586,7 +586,7 @@ OscillatorObject::OscillatorObject( Model * _parent, int _index ) :
void OscillatorObject::oscButtonChanged()
{

static Oscillator::WaveShapes shapes[] =
static auto shapes = std::array
{
Oscillator::SineWave,
Oscillator::SawWave,
Expand Down
8 changes: 4 additions & 4 deletions plugins/Patman/Patman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,11 @@ PatmanInstrument::LoadErrors PatmanInstrument::loadPatch(
return( LoadOpen );
}

unsigned char header[239];
auto header = std::array<unsigned char, 239>{};

if( fread( header, 1, 239, fd ) != 239 ||
( memcmp( header, "GF1PATCH110\0ID#000002", 22 )
&& memcmp( header, "GF1PATCH100\0ID#000002", 22 ) ) )
if (fread(header.data(), 1, 239, fd ) != 239 ||
(memcmp(header.data(), "GF1PATCH110\0ID#000002", 22)
&& memcmp(header.data(), "GF1PATCH100\0ID#000002", 22)))
{
fclose( fd );
return( LoadNotGUS );
Expand Down
Loading