Fix PVS Studio reported errors (Closes: #425)

pull/3/head
Hleb Valoshka 2019-10-04 18:51:16 +03:00
parent e9ae3959eb
commit 7fd01f38b0
10 changed files with 17 additions and 17 deletions

View File

@ -18,7 +18,7 @@ namespace celestia
{ {
namespace filesystem namespace filesystem
{ {
class filesystem_error : std::system_error class filesystem_error : public std::system_error
{ {
public: public:
filesystem_error(std::error_code ec, const char* msg) : filesystem_error(std::error_code ec, const char* msg) :

View File

@ -7460,7 +7460,7 @@ void Renderer::renderAnnotations(const vector<Annotation>& annotations, FontStyl
switch (annotations[i].valign) switch (annotations[i].valign)
{ {
case AlignCenter: case VerticalAlignCenter:
vOffset = -font[fs]->getHeight() / 2; vOffset = -font[fs]->getHeight() / 2;
break; break;
case VerticalAlignTop: case VerticalAlignTop:

View File

@ -2845,10 +2845,6 @@ ShaderManager::buildParticleVertexShader(const ShaderProperties& props)
{ {
source << "uniform float pointScale;\n"; source << "uniform float pointScale;\n";
source << "attribute float pointSize;\n"; source << "attribute float pointSize;\n";
}
if (props.texUsage & ShaderProperties::PointSprite)
{
source << DeclareVarying("pointFade", Shader_Float); source << DeclareVarying("pointFade", Shader_Float);
} }

View File

@ -622,9 +622,6 @@ static LRESULT
DatePickerCreate(HWND hwnd, CREATESTRUCT& cs) DatePickerCreate(HWND hwnd, CREATESTRUCT& cs)
{ {
DatePicker* dp = new DatePicker(hwnd, cs); DatePicker* dp = new DatePicker(hwnd, cs);
if (dp == NULL)
return -1;
SetWindowLongPtr(hwnd, 0, reinterpret_cast<DWORD_PTR>(dp)); SetWindowLongPtr(hwnd, 0, reinterpret_cast<DWORD_PTR>(dp));
return 0; return 0;

View File

@ -2232,7 +2232,7 @@ static void BuildScriptsMenu(HMENU menuBar, const fs::path& scriptsDir)
} }
MENUITEMINFO info; MENUITEMINFO info;
memset(&info, sizeof(info), 0); memset(&info, 0, sizeof(info));
info.cbSize = sizeof(info); info.cbSize = sizeof(info);
info.fMask = MIIM_SUBMENU; info.fMask = MIIM_SUBMENU;
@ -3028,7 +3028,7 @@ static char* skipSpace(char* s)
static char* skipUntilQuote(char* s) static char* skipUntilQuote(char* s)
{ {
while (*s != '"' && s != '\0') while (*s != '"' && *s != '\0')
s++; s++;
return s; return s;
} }

View File

@ -45,10 +45,10 @@ BOOL APIENTRY TourGuideProc(HWND hDlg,
HWND hwnd = GetDlgItem(hDlg, IDC_COMBO_TOURGUIDE); HWND hwnd = GetDlgItem(hDlg, IDC_COMBO_TOURGUIDE);
const DestinationList* destinations = guide->appCore->getDestinations(); const DestinationList* destinations = guide->appCore->getDestinations();
Destination* dest = (*destinations)[0];
guide->selectedDest = dest;
if (hwnd != NULL && destinations != NULL) if (hwnd != NULL && destinations != NULL)
{ {
Destination* dest = (*destinations)[0];
guide->selectedDest = dest;
for (DestinationList::const_iterator iter = destinations->begin(); for (DestinationList::const_iterator iter = destinations->begin();
iter != destinations->end(); iter++) iter != destinations->end(); iter++)
{ {

View File

@ -13,6 +13,7 @@
#include "cmodops.h" #include "cmodops.h"
#include <celmodel/modelfile.h> #include <celmodel/modelfile.h>
#include <cel3ds/3dsread.h> #include <cel3ds/3dsread.h>
#include <celmath/mathlib.h>
#include <cstring> #include <cstring>
#include <cassert> #include <cassert>
#include <cmath> #include <cmath>
@ -20,6 +21,7 @@
using namespace cmod; using namespace cmod;
using namespace std; using namespace std;
using namespace celmath;
void usage() void usage()
@ -59,7 +61,7 @@ int main(int argc, char* argv[])
double weldTolerance = 1.0e-6; double weldTolerance = 1.0e-6;
bool weldVertices = true; bool weldVertices = true;
Model* newModel = GenerateModelNormals(*model, float(smoothAngle * 3.14159265 / 180.0), weldVertices, weldTolerance); Model* newModel = GenerateModelNormals(*model, (float)degToRad(smoothAngle), weldVertices, weldTolerance);
delete model; delete model;
if (!newModel) if (!newModel)

View File

@ -375,14 +375,14 @@ bool operator<(const Mesh::VertexDescription& a,
if (a.nAttributes < b.nAttributes) if (a.nAttributes < b.nAttributes)
return true; return true;
if (b.nAttributes < b.nAttributes) if (b.nAttributes < a.nAttributes)
return false; return false;
for (uint32_t i = 0; i < a.nAttributes; i++) for (uint32_t i = 0; i < a.nAttributes; i++)
{ {
if (a.attributes[i] < b.attributes[i]) if (a.attributes[i] < b.attributes[i])
return true; return true;
else if (b.attributes[i] < a.attributes[i]) if (b.attributes[i] < a.attributes[i])
return false; return false;
} }

View File

@ -1513,6 +1513,7 @@ ModelViewWidget::createShader(const ShaderKey& shaderKey)
{ {
qWarning("Vertex shader error: %s", vertexShader->log().c_str()); qWarning("Vertex shader error: %s", vertexShader->log().c_str());
std::cerr << vertexShaderSource.toStdString() << std::endl; std::cerr << vertexShaderSource.toStdString() << std::endl;
delete vertexShader;
delete glShader; delete glShader;
return nullptr; return nullptr;
} }
@ -1522,6 +1523,8 @@ ModelViewWidget::createShader(const ShaderKey& shaderKey)
{ {
qWarning("Fragment shader error: %s", fragmentShader->log().c_str()); qWarning("Fragment shader error: %s", fragmentShader->log().c_str());
std::cerr << fragmentShaderSource.toStdString() << std::endl; std::cerr << fragmentShaderSource.toStdString() << std::endl;
delete vertexShader;
delete fragmentShader;
delete glShader; delete glShader;
return nullptr; return nullptr;
} }
@ -1536,6 +1539,8 @@ ModelViewWidget::createShader(const ShaderKey& shaderKey)
if (!glShader->link()) if (!glShader->link())
{ {
qWarning("Shader link error: %s", glShader->log().c_str()); qWarning("Shader link error: %s", glShader->log().c_str());
delete vertexShader;
delete fragmentShader;
delete glShader; delete glShader;
return nullptr; return nullptr;
} }

View File

@ -118,7 +118,7 @@ bool WriteCrossIndex(istream& in, ostream& out)
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
if (!parseCommandLine(argc, argv) || inputFilename.empty()) if (!parseCommandLine(argc, argv)/* || inputFilename.empty()*/)
{ {
Usage(); Usage();
return 1; return 1;