Skip to content

Commit fd1d235

Browse files
authored
Fix various warnings (#436)
* Fix Wreorder warnings * Fix various unused variable/parameter warnings * Fix Wparentheses warnings * Fix Wignored-qualifiers warning * Fix uninitialized variable warnings * Fix Wshadow warnings * Fix Wsign-compare warnings * Fix miscellaneous warnings
1 parent f0f59d9 commit fd1d235

21 files changed

+158
-114
lines changed

src/libprojectM/FileScanner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void FileScanner::scanPosix(ScanCallback cb) {
145145
fileSystem = fts_open(dirList, FTS_LOGICAL|FTS_NOCHDIR|FTS_NOSTAT, &fts_compare);
146146
if (fileSystem == NULL) {
147147
std::string s;
148-
for (int i = 0; i < _rootDirs.size(); i++)
148+
for (std::size_t i = 0; i < _rootDirs.size(); i++)
149149
s += _rootDirs[i] + ' ';
150150
handleDirectoryError(s);
151151

src/libprojectM/KeyHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ void projectM::default_key_handler( projectMEvent event, projectMKeycode keycode
154154
if (isTextInputActive()) break; // don't handle this key if search menu is up.
155155
if (renderer->showmenu) {
156156
int downPreset = m_presetPos->lastIndex() + (renderer->textMenuPageSize / 2.0f); // jump down by page size / 2
157-
if (downPreset >= (m_presetLoader->size() - 1)) // handle upper boundary
157+
if (static_cast<std::size_t>(downPreset) >= (m_presetLoader->size() - 1)) // handle upper boundary
158158
downPreset = 0;
159159
selectPreset(downPreset); // jump down menu half a page.
160160
}

src/libprojectM/MilkdropPresetFactory/Expr.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ llvm::Value *PrefunExpr::_llvm(JitContext &jitx)
161161
class PrefunExprOne : public PrefunExpr
162162
{
163163
public:
164-
PrefunExprOne(Func *function, Expr **expr_list_) : PrefunExpr(function,expr_list_) {}
164+
PrefunExprOne(Func *fun, Expr **expr_list_) : PrefunExpr(fun,expr_list_) {}
165165
float eval ( int mesh_i, int mesh_j )
166166
{
167167
float val = expr_list[0]->eval ( mesh_i, mesh_j );
@@ -260,7 +260,7 @@ class IfEqualExpr : public PrefunExpr
260260
class IfExpr : public PrefunExpr
261261
{
262262
public:
263-
IfExpr(Func *function, Expr **expr_list_) : PrefunExpr(function,expr_list_) {}
263+
IfExpr(Func *fun, Expr **expr_list_) : PrefunExpr(fun,expr_list_) {}
264264

265265
float eval ( int mesh_i, int mesh_j )
266266
{
@@ -322,7 +322,7 @@ class IfExpr : public PrefunExpr
322322
class SinExpr : public PrefunExpr
323323
{
324324
public:
325-
SinExpr(Func *function, Expr **expr_list_) : PrefunExpr(function,expr_list_) {}
325+
SinExpr(Func *fun, Expr **expr_list_) : PrefunExpr(fun,expr_list_) {}
326326
float eval ( int mesh_i, int mesh_j ) override
327327
{
328328
float val = expr_list[0]->eval ( mesh_i, mesh_j );
@@ -334,7 +334,7 @@ class SinExpr : public PrefunExpr
334334
class CosExpr : public PrefunExpr
335335
{
336336
public:
337-
CosExpr(Func *function, Expr **expr_list_) : PrefunExpr(function,expr_list_) {}
337+
CosExpr(Func *fun, Expr **expr_list_) : PrefunExpr(fun,expr_list_) {}
338338
float eval ( int mesh_i, int mesh_j ) override
339339
{
340340
float val = expr_list[0]->eval ( mesh_i, mesh_j );
@@ -346,7 +346,7 @@ class CosExpr : public PrefunExpr
346346
class LogExpr : public PrefunExpr
347347
{
348348
public:
349-
LogExpr(Func *function, Expr **expr_list_) : PrefunExpr(function,expr_list_) {}
349+
LogExpr(Func *fun, Expr **expr_list_) : PrefunExpr(fun,expr_list_) {}
350350
float eval ( int mesh_i, int mesh_j ) override
351351
{
352352
float val = expr_list[0]->eval( mesh_i, mesh_j );

src/libprojectM/Renderer/MilkdropWaveform.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ void MilkdropWaveform::WaveformMath(RenderContext &context)
356356
break;
357357

358358
case DoubleLine://dual waveforms
359-
359+
{
360360

361361
wave_x_temp=-2*0.4142f*(fabs(fabs(mystery)-.5f)-.5f);
362362

@@ -384,6 +384,8 @@ void MilkdropWaveform::WaveformMath(RenderContext &context)
384384
}
385385

386386
break;
387-
387+
}
388+
case last:
389+
break;
388390
}
389391
}

src/libprojectM/Renderer/Renderer.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ void Renderer::RenderTouch(const Pipeline& pipeline, const PipelineContext& pipe
389389
{
390390
Pipeline pipelineTouch;
391391
MilkdropWaveform wave;
392-
for(int x = 0; x < waveformList.size(); x++){
392+
for(std::size_t x = 0; x < waveformList.size(); x++){
393393
pipelineTouch.drawables.push_back(&wave);
394394
wave = waveformList[x];
395395

@@ -701,7 +701,7 @@ bool Renderer::timeCheck(const milliseconds currentTime, const milliseconds last
701701
}
702702

703703
// If we touched on the renderer where there is an existing waveform.
704-
bool Renderer::touchedWaveform(float x, float y, int i)
704+
bool Renderer::touchedWaveform(float x, float y, std::size_t i)
705705
{
706706
if (waveformList[i].x > (x-0.05f) && waveformList[i].x < (x+0.05f) // if x +- 0.5f
707707
&& ((waveformList[i].y > (y-0.05f) && waveformList[i].y < (y+0.05f)) // and y +- 0.5f
@@ -717,7 +717,7 @@ bool Renderer::touchedWaveform(float x, float y, int i)
717717
void Renderer::touch(float x, float y, int pressure, int type = 0)
718718
{
719719

720-
for (int i = 0; i < waveformList.size(); i++) {
720+
for (std::size_t i = 0; i < waveformList.size(); i++) {
721721
if (touchedWaveform(x, y, i))
722722
{
723723
// if we touched an existing waveform with left click, drag it and don't continue with adding another.
@@ -767,7 +767,7 @@ void Renderer::touchDrag(float x, float y, int pressure)
767767
{
768768
// if we left clicked & held in the approximate position of a waveform, snap to it and adjust x / y to simulate dragging.
769769
// For lines we don't worry about the x axis.
770-
for (int i = 0; i < waveformList.size(); i++) {
770+
for (std::size_t i = 0; i < waveformList.size(); i++) {
771771
if (touchedWaveform(x, y, i))
772772
{
773773
waveformList[i].x = x;
@@ -782,7 +782,7 @@ void Renderer::touchDestroy(float x, float y)
782782
{
783783
// if we right clicked approximately on the position of the waveform, then remove it from the waveform list.
784784
// For lines we don't worry about the x axis.
785-
for (int i = 0; i < waveformList.size(); i++) {
785+
for (std::size_t i = 0; i < waveformList.size(); i++) {
786786
if (touchedWaveform(x, y, i))
787787
{
788788
waveformList.erase(waveformList.begin() + i);

src/libprojectM/Renderer/Renderer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class Renderer
170170
void touchDrag(float x, float y, int pressure);
171171
void touchDestroy(float x, float y);
172172
void touchDestroyAll();
173-
bool touchedWaveform(float x, float y, int i);
173+
bool touchedWaveform(float x, float y, std::size_t i);
174174

175175
void setToastMessage(const std::string& theValue);
176176
void setSearchText(const std::string& theValue);

src/libprojectM/event.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ typedef enum {
145145

146146
typedef enum {
147147
/** Modifiers */
148+
PROJECTM_KMOD_NONE = -1,
148149
PROJECTM_KMOD_LSHIFT,
149150
PROJECTM_KMOD_RSHIFT,
150151
PROJECTM_KMOD_CAPS,

src/libprojectM/projectM.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void projectM::projectM_resetTextures()
114114

115115

116116
projectM::projectM ( std::string config_file, int flags) :
117-
_pcm(0), beatDetect ( 0 ), renderer ( 0 ), _pipelineContext(new PipelineContext()), _pipelineContext2(new PipelineContext()), m_presetPos(0),
117+
renderer ( 0 ), _pcm(0), beatDetect ( 0 ), _pipelineContext(new PipelineContext()), _pipelineContext2(new PipelineContext()), m_presetPos(0),
118118
timeKeeper(NULL), m_flags(flags), _matcher(NULL), _merger(NULL)
119119
{
120120
readConfig(config_file);
@@ -124,7 +124,7 @@ projectM::projectM ( std::string config_file, int flags) :
124124
}
125125

126126
projectM::projectM(Settings settings, int flags):
127-
_pcm(0), beatDetect ( 0 ), renderer ( 0 ), _pipelineContext(new PipelineContext()), _pipelineContext2(new PipelineContext()), m_presetPos(0),
127+
renderer ( 0 ), _pcm(0), beatDetect ( 0 ), _pipelineContext(new PipelineContext()), _pipelineContext2(new PipelineContext()), m_presetPos(0),
128128
timeKeeper(NULL), m_flags(flags), _matcher(NULL), _merger(NULL)
129129
{
130130
readSettings(settings);
@@ -900,7 +900,7 @@ void projectM::selectPrevious(const bool hardCut) {
900900
renderer->m_activePresetID--;
901901
selectPresetByName(renderer->m_presetList[renderer->m_activePresetID-1].name,true);
902902
}
903-
} else if (settings().shuffleEnabled && presetHistory.size() >= 1 && presetHistory.back() != m_presetLoader->size() && !renderer->showmenu) { // if randomly browsing presets, "previous" should return to last random preset not the index--. Avoid returning to size() because that's the idle:// preset.
903+
} else if (settings().shuffleEnabled && presetHistory.size() >= 1 && static_cast<std::size_t>(presetHistory.back()) != m_presetLoader->size() && !renderer->showmenu) { // if randomly browsing presets, "previous" should return to last random preset not the index--. Avoid returning to size() because that's the idle:// preset.
904904
presetFuture.push_back(m_presetPos->lastIndex());
905905
selectPreset(presetHistory.back());
906906
presetHistory.pop_back();
@@ -922,7 +922,7 @@ void projectM::selectNext(const bool hardCut) {
922922
if (isTextInputActive() && renderer->m_presetList.size() >= 1) // if search is active and there are search results
923923
{
924924
// if search menu is down, next is based on search terms.
925-
if (renderer->m_activePresetID >= renderer->m_presetList.size()) {
925+
if (static_cast<std::size_t>(renderer->m_activePresetID) >= renderer->m_presetList.size()) {
926926
// loop to top of page is at bottom
927927
renderer->m_activePresetID = 1;
928928
selectPresetByName(renderer->m_presetList[0].name,true);
@@ -931,7 +931,7 @@ void projectM::selectNext(const bool hardCut) {
931931
// otherwise move forward
932932
selectPresetByName(renderer->m_presetList[renderer->m_activePresetID].name,true);
933933
}
934-
} else if (settings().shuffleEnabled && presetFuture.size() >= 1 && presetFuture.front() != m_presetLoader->size() && !renderer->showmenu) { // if shuffling and we have future presets already stashed then let's go forward rather than truely move randomly.
934+
} else if (settings().shuffleEnabled && presetFuture.size() >= 1 && static_cast<std::size_t>(presetFuture.front()) != m_presetLoader->size() && !renderer->showmenu) { // if shuffling and we have future presets already stashed then let's go forward rather than truely move randomly.
935935
presetHistory.push_back(m_presetPos->lastIndex());
936936
selectPreset(presetFuture.back());
937937
presetFuture.pop_back();
@@ -1133,7 +1133,7 @@ void projectM::toggleSearchText()
11331133
}
11341134

11351135
// get index from search results based on preset name
1136-
const unsigned int projectM::getSearchIndex(std::string &name) const
1136+
unsigned int projectM::getSearchIndex(std::string &name) const
11371137
{
11381138
for (auto& it : renderer->m_presetList) {
11391139
if (it.name == name) return it.id;

src/libprojectM/projectM.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,13 @@ class DLLEXPORT projectM
294294
}
295295

296296
/// Occurs when active preset has switched. Switched to index is returned
297-
virtual void presetSwitchedEvent(bool isHardCut, size_t index) const {};
298-
virtual void shuffleEnabledValueChanged(bool isEnabled) const {};
299-
virtual void presetSwitchFailedEvent(bool hardCut, unsigned int index, const std::string & message) const {};
297+
virtual void presetSwitchedEvent(bool /*isHardCut*/, size_t /*index*/) const {};
298+
virtual void shuffleEnabledValueChanged(bool /*isEnabled*/) const {};
299+
virtual void presetSwitchFailedEvent(bool /*hardCut*/, unsigned int /*index*/, const std::string & /*message*/) const {};
300300

301301

302302
/// Occurs whenever preset rating has changed via changePresetRating() method
303-
virtual void presetRatingChanged(unsigned int index, int rating, PresetRatingType ratingType) const {};
303+
virtual void presetRatingChanged(unsigned int /*index*/, int /*rating*/, PresetRatingType /*ratingType*/) const {};
304304

305305

306306
inline PCM * pcm() {
@@ -315,7 +315,7 @@ class DLLEXPORT projectM
315315
std::vector<int> presetFuture;
316316

317317
/// Get the preset index given a name
318-
const unsigned int getSearchIndex(std::string &name) const;
318+
unsigned int getSearchIndex(std::string &name) const;
319319

320320
void selectPrevious(const bool);
321321
void selectNext(const bool);

src/projectM-jack/qprojectM-jack.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,9 @@ class ProjectMApplication : public QApplication {
8888
std::string read_config()
8989
{
9090

91-
int n;
92-
9391
char num[512];
94-
FILE *in;
95-
FILE *out;
92+
FILE *f_in;
93+
FILE *f_out;
9694

9795
char * home;
9896
char projectM_home[1024];
@@ -113,10 +111,10 @@ std::string read_config()
113111
projectM_home[strlen(home)+strlen("/.projectM/config.inp")]='\0';
114112

115113

116-
if ((in = fopen(projectM_home, "r")) != 0)
114+
if ((f_in = fopen(projectM_home, "r")) != 0)
117115
{
118116
printf("reading ~/.projectM/config.inp \n");
119-
fclose(in);
117+
fclose(f_in);
120118
return std::string(projectM_home);
121119
}
122120
else
@@ -132,24 +130,24 @@ std::string read_config()
132130
strcpy(projectM_home+strlen(home), "/.projectM/config.inp");
133131
projectM_home[strlen(home)+strlen("/.projectM/config.inp")]='\0';
134132

135-
if((out = fopen(projectM_home,"w"))!=0)
133+
if((f_out = fopen(projectM_home,"w"))!=0)
136134
{
137135

138-
if ((in = fopen(projectM_config, "r")) != 0)
136+
if ((f_in = fopen(projectM_config, "r")) != 0)
139137
{
140138

141-
while(fgets(num,80,in)!=NULL)
139+
while(fgets(num,80,f_in)!=NULL)
142140
{
143-
fputs(num,out);
141+
fputs(num,f_out);
144142
}
145-
fclose(in);
146-
fclose(out);
143+
fclose(f_in);
144+
fclose(f_out);
147145

148146

149-
if ((in = fopen(projectM_home, "r")) != 0)
147+
if ((f_in = fopen(projectM_home, "r")) != 0)
150148
{
151149
printf("created ~/.projectM/config.inp successfully\n");
152-
fclose(in);
150+
fclose(f_in);
153151
return std::string(projectM_home);
154152
}
155153
else{printf("This shouldn't happen, using implementation defaults\n");abort();}
@@ -159,9 +157,9 @@ std::string read_config()
159157
else
160158
{
161159
printf("Cannot create ~/.projectM/config.inp, using default config file\n");
162-
if ((in = fopen(projectM_config, "r")) != 0)
160+
if ((f_in = fopen(projectM_config, "r")) != 0)
163161
{ printf("Successfully opened default config file\n");
164-
fclose(in);
162+
fclose(f_in);
165163
return std::string(projectM_config);}
166164
else{ printf("Using implementation defaults, your system is really messed up, I'm surprised we even got this far\n"); abort();}
167165

@@ -176,6 +174,7 @@ std::string read_config()
176174
int
177175
process (jack_nframes_t nframes, void *arg)
178176
{
177+
Q_UNUSED(arg);
179178

180179
jack_default_audio_sample_t *in;
181180

@@ -191,6 +190,7 @@ process (jack_nframes_t nframes, void *arg)
191190

192191
void jack_shutdown (void *arg)
193192
{
193+
Q_UNUSED(arg);
194194
exit (1);
195195
}
196196

@@ -201,7 +201,6 @@ int main (int argc, char **argv) {
201201
jack_options_t options = JackNullOption;
202202
jack_status_t status;
203203
int i;
204-
char projectM_data[1024];
205204

206205
// Start a new application
207206
ProjectMApplication app(argc, argv);

0 commit comments

Comments
 (0)