Skip to content

Commit

Permalink
clang tidy rule
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeevdv committed Dec 21, 2021
1 parent 6b2cbaf commit 561437f
Show file tree
Hide file tree
Showing 41 changed files with 238 additions and 212 deletions.
2 changes: 2 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ FixNamespaceComments: false
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
IndentWidth: 4
PointerAlignment: Left
ReferenceAlignment: Left
3 changes: 2 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Checks: "-*,\
readability-braces-around-statements\
readability-braces-around-statements,\
cppcoreguidelines-init-variables
"

WarningsAsErrors: "*"
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ endif()
add_executable(falltergeist main.cpp ${SOURCES} ${_additional_includes})

set_target_properties(falltergeist PROPERTIES
CXX_STANDARD 14
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
Expand Down
2 changes: 1 addition & 1 deletion src/Audio/Mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace Falltergeist
throw Exception(Mix_GetError());
}
logger->info() << message + "[OK]" << std::endl;
int frequency, channels;
int frequency = 0, channels = 0;
Mix_QuerySpec(&frequency, &_format, &channels);
}

Expand Down
2 changes: 1 addition & 1 deletion src/CrossPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ namespace Falltergeist
}
endmntent(mtab);
#elif defined (BSD)
struct statfs *mntbuf;
struct statfs *mntbuf = nullptr;
int mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
for ( int i = 0; i < mntsize; i++ ) {
std::string directory = ((struct statfs *)&mntbuf[i])->f_mntonname;
Expand Down
8 changes: 4 additions & 4 deletions src/Format/Acm/Decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ namespace Falltergeist
void Decoder::_sub4d3fcc(short *memory, int *buffer, int sbSize,
int blocks)
{
int row0, row1, row2 = 0, row3 = 0, db0, db1;
int i;
int row0 = 0, row1 = 0, row2 = 0, row3 = 0, db0 = 0, db1 = 0;
int i = 0;
int sbSize2 = sbSize * 2, sbSize3 = sbSize * 3;
if (blocks == 2)
{
Expand Down Expand Up @@ -151,8 +151,8 @@ namespace Falltergeist
void Decoder::_sub4d420c(int *memory, int *buffer, int sbSize,
int blocks)
{
int row0, row1, row2 = 0, row3 = 0, db0, db1;
int i;
int row0 = 0, row1 = 0, row2 = 0, row3 = 0, db0 = 0, db1 = 0;
int i = 0;
int sbSize2 = sbSize * 2, sbSize3 = sbSize * 3;
if (blocks == 4)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Format/Acm/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Falltergeist
_stream >> hdr.channels;
_stream >> hdr.rate;

int16_t tmpword;
int16_t tmpword = 0;
_stream.readBytes((uint8_t*)&tmpword, 2);
_subblocks = (int32_t) (tmpword >> 4);
_levels = (int32_t) (tmpword&15);
Expand Down
4 changes: 2 additions & 2 deletions src/Format/Acm/Unpacker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace Falltergeist
{
while (bits > _availBits)
{
unsigned char one_byte;
unsigned char one_byte = 0;
if (_bufferBitOffset == UNPACKER_BUFFER_SIZE)
{
auto remains = stream->bytesRemains();
Expand Down Expand Up @@ -129,7 +129,7 @@ namespace Falltergeist
_blockPtr = block;
int pwr = _getBits(4) & 0xF, val = _getBits(16) & 0xFFFF,
count = 1 << pwr, v = 0;
int i;
int i = 0;
for (i = 0; i < count; i++)
{
_buffMiddle[i] = (short) v;
Expand Down
16 changes: 8 additions & 8 deletions src/Format/Dat/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ namespace Falltergeist
throw Exception("File::_initialize() - can't open stream: " + filename());
}

unsigned int FileSize;
unsigned int filesTreeSize;
unsigned int filesTotalNumber;
unsigned int FileSize = 0;
unsigned int filesTreeSize = 0;
unsigned int filesTotalNumber = 0;

// reading data size from dat file
setPosition(size() - 4);
Expand Down Expand Up @@ -145,11 +145,11 @@ namespace Falltergeist

File& File::operator>>(Entry& entry)
{
uint32_t filenameSize;
uint8_t compressed;
uint32_t unpackedSize;
uint32_t packedSize;
uint32_t dataOffset;
uint32_t filenameSize = 0;
uint8_t compressed = 0;
uint32_t unpackedSize = 0;
uint32_t packedSize = 0;
uint32_t dataOffset = 0;

*this >> filenameSize;

Expand Down
6 changes: 3 additions & 3 deletions src/Format/Dat/Stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ namespace Falltergeist

uint32_t Stream::uint32()
{
uint32_t value;
uint32_t value = 0;
*this >> value;
return value;
}
Expand All @@ -186,7 +186,7 @@ namespace Falltergeist

uint16_t Stream::uint16()
{
uint16_t value;
uint16_t value = 0;
*this >> value;
return value;
}
Expand All @@ -198,7 +198,7 @@ namespace Falltergeist

uint8_t Stream::uint8()
{
uint8_t value;
uint8_t value = 0;
*this >> value;
return value;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Format/Gam/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Falltergeist
stream.setPosition(0);

unsigned int i = 0;
unsigned char ch;
unsigned char ch = 0;
std::string line;
while (i != stream.size())
{
Expand Down
4 changes: 2 additions & 2 deletions src/Format/Lip/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ namespace Falltergeist

for (uint32_t i=0; i < _phonemesCount; i++)
{
uint8_t phoneme;
uint8_t phoneme = 0;
stream >> phoneme;
_phonemes.push_back(phoneme);
}

for (uint32_t i=0; i < _markersCount; i++)
{
uint32_t stype, smarker;
uint32_t stype = 0, smarker = 0;
stream >> stype >> smarker;
_markerSamples.push_back(smarker);
_markerTimestamps.push_back(smarker*1000 / 22050 /2); //ms
Expand Down
2 changes: 1 addition & 1 deletion src/Format/Lst/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Falltergeist
stream.setPosition(0);

std::string line;
unsigned char ch;
unsigned char ch = 0;
for (unsigned int i = 0; i != stream.size(); ++i)
{
stream >> ch;
Expand Down
11 changes: 6 additions & 5 deletions src/Format/Map/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,12 @@ namespace Falltergeist
object->setFrmTypeId((FID & 0x0F000000) >> 24);
object->setObjectID3((FID & 0xF0000000) >> 28);
break;
case OBJECT_TYPE::SCENERY:
case OBJECT_TYPE::SCENERY: {
object->setObjectSubtypeId(callback(PID)->subtypeId());
uint32_t elevhex; // elev+hex
uint32_t hex;
uint32_t elev;
int32_t map;
uint32_t elevhex = 0; // elev+hex
uint32_t hex = 0;
uint32_t elev = 0;
int32_t map = 0;
switch((SCENERY_TYPE)object->objectSubtypeId())
{
case SCENERY_TYPE::LADDER_TOP:
Expand Down Expand Up @@ -314,6 +314,7 @@ namespace Falltergeist
throw Exception("File::_readObject() - unknown scenery type");
}
break;
}
case OBJECT_TYPE::WALL:
break;
case OBJECT_TYPE::TILE:
Expand Down
2 changes: 1 addition & 1 deletion src/Format/Mve/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Falltergeist
const int16_t MVE_HDRCONST1 = 0x001A;
const int16_t MVE_HDRCONST2 = 0x0100;
const int16_t MVE_HDRCONST3 = 0x1133;
int16_t check1, check2, check3;
int16_t check1 = 0, check2 = 0, check3 = 0;

char head[20];
_stream.readBytes((uint8_t*)head,20);
Expand Down
2 changes: 1 addition & 1 deletion src/Format/Pal/Color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ namespace Falltergeist

Color::operator unsigned int() const
{
uint8_t k;
uint8_t k = 0;
if (_nomod) {
k = 1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Format/Sve/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Falltergeist

std::string line;

unsigned char ch;
unsigned char ch = 0;
for (unsigned int i = 0; i != stream.size(); ++i)
{
stream >> ch;
Expand Down
4 changes: 2 additions & 2 deletions src/Game/Helper/EggHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace Falltergeist
}

// calculate if dude egg intersects with object
Hexagon *dudeHex;
Hexagon *dudeHex = nullptr;
if (dude->movementQueue()->size()) {
dudeHex = dude->movementQueue()->back();
} else {
Expand All @@ -44,7 +44,7 @@ namespace Falltergeist
auto dudePos = dudeHex->position();

bool noBlockTrans = false;
bool transparent;
bool transparent = false;

switch (object->lightOrientation()) {
case Orientation::EW:
Expand Down
2 changes: 1 addition & 1 deletion src/Graphics/IndexBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Falltergeist {
_indexes = indexes;
_count = count;

unsigned int usage;
unsigned int usage = GL_NONE;
switch (usagePattern) {
case UsagePattern::DynamicDraw:
usage = GL_DYNAMIC_DRAW;
Expand Down
6 changes: 3 additions & 3 deletions src/Graphics/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ namespace Falltergeist {
logger->info() << "[RENDERER] " << "Extensions: " << std::endl;

if (_renderpath == RenderPath::OGL32) {
GLint count;
GLint count = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &count);

for (GLint i = 0; i < count; i++) {
Expand Down Expand Up @@ -295,8 +295,8 @@ namespace Falltergeist {

void Renderer::screenshot() {
std::string filename;
Uint32 rmask, gmask, bmask, amask;
SDL_Surface *output;
Uint32 rmask = 0, gmask = 0, bmask = 0, amask = 0;
SDL_Surface *output = nullptr;

int iter = 0;
do {
Expand Down
10 changes: 5 additions & 5 deletions src/Graphics/Shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ namespace Falltergeist
glShaderSource(shader, 1, &src, NULL);
glCompileShader(shader);

GLint status;
GLint status = 0;
glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
if (!status)
{
GLint len;
GLint len = 0;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &len);
GLchar *log = (GLchar *) malloc(len);
glGetShaderInfoLog(shader, len, NULL, log);
Expand Down Expand Up @@ -95,12 +95,12 @@ namespace Falltergeist
}
glLinkProgram(_progId);

GLint status;
GLint status = 0;
glGetProgramiv(_progId, GL_LINK_STATUS, &status);

if (!status)
{
GLint len;
GLint len = 0;
glGetProgramiv(_progId, GL_INFO_LOG_LENGTH, &len);
GLchar *log = (GLchar *) malloc(len);
glGetProgramInfoLog(_progId, len, NULL, log);
Expand All @@ -125,7 +125,7 @@ namespace Falltergeist

void Shader::use() const
{
GLint cur;
GLint cur = 0;
GL_CHECK(glGetIntegerv(GL_CURRENT_PROGRAM, &cur));
if ((GLuint)cur!=_progId)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Graphics/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ namespace Falltergeist {
return;
}
*/
GLint curunit;
GLint curtexture;
GLint curunit = 0;
GLint curtexture = 0;

if (_textureID > 0) {
GL_CHECK(glGetIntegerv(GL_ACTIVE_TEXTURE, &curunit));
Expand Down
2 changes: 1 addition & 1 deletion src/Graphics/VertexArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace Falltergeist {
for (auto &attribute : bufferLayout.attributes()) {
GL_CHECK(glEnableVertexAttribArray(attribute.index()));

unsigned int glType;
unsigned int glType = GL_NONE;
switch (attribute.type()) {
case VertexBufferAttribute::Type::Float:
glType = GL_FLOAT;
Expand Down
2 changes: 1 addition & 1 deletion src/Graphics/VertexBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Falltergeist {
_data = data;
_size = size;

unsigned int usage;
unsigned int usage = GL_NONE;
switch (usagePattern) {
case UsagePattern::DynamicDraw:
usage = GL_DYNAMIC_DRAW;
Expand Down
14 changes: 8 additions & 6 deletions src/Ini/Parser.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <math.h>

#include <algorithm>
#include <functional>
#include <sstream>
Expand Down Expand Up @@ -66,7 +68,7 @@ namespace Falltergeist

bool Parser::_parseBool(std::string &name, std::string &line, std::shared_ptr<File> ini)
{
bool value;
bool value = false;
if (_tryBool(line, &value))
{
Logger::debug("INI") << "boolean value found for property `" << name << "`: " <<
Expand Down Expand Up @@ -200,8 +202,8 @@ namespace Falltergeist

bool Parser::_parseDecimal(std::string &name, std::string &line, std::shared_ptr<File> ini)
{
int intval;
double doubleval;
int intval = 0;
double doubleval = 0.0;
int ret = _tryDecimal(line, &intval, &doubleval);
if (ret!=0)
{
Expand All @@ -226,7 +228,7 @@ namespace Falltergeist

bool Parser::_parseArrayBool(std::vector<Value> &vec, std::string val)
{
bool value;
bool value = 0;
if (_tryBool(val,&value))
{
Logger::debug("INI") << "boolean value found for property `" << "`: " <<
Expand All @@ -241,8 +243,8 @@ namespace Falltergeist

bool Parser::_parseArrayDecimal(std::vector<Value> &vec, std::string val)
{
int intval;
double doubleval;
int intval = 0;
double doubleval = 0.0;
int ret = _tryDecimal(val, &intval, &doubleval);
if (ret!=0)
{
Expand Down
Loading

0 comments on commit 561437f

Please sign in to comment.