diff --git a/avogadro/core/coordinateblockgenerator.cpp b/avogadro/core/coordinateblockgenerator.cpp index 147fe519cc..ddf3c24314 100644 --- a/avogadro/core/coordinateblockgenerator.cpp +++ b/avogadro/core/coordinateblockgenerator.cpp @@ -64,8 +64,8 @@ std::string CoordinateBlockGenerator::generateCoordinateBlock() const Index numAtoms = m_molecule->atomCount(); Atom atom; unsigned char atomicNumber; - const char* symbol; - const char* name; + const char* symbol = "\0"; + const char* name = "\0"; Vector3 pos3d; Vector3 fpos3d; const UnitCell* cell = diff --git a/avogadro/core/dihedraliterator.cpp b/avogadro/core/dihedraliterator.cpp index cc93c04b24..d1584ef783 100644 --- a/avogadro/core/dihedraliterator.cpp +++ b/avogadro/core/dihedraliterator.cpp @@ -35,7 +35,7 @@ Dihedral DihedralIterator::begin() Index c = bc.second; // find an a - Index a; + Index a = 0; for (const auto maybeA : graph.neighbors(b)) { if (maybeA != c) { a = maybeA; diff --git a/avogadro/core/elements.cpp b/avogadro/core/elements.cpp index e9b9b8ab84..20ee588348 100644 --- a/avogadro/core/elements.cpp +++ b/avogadro/core/elements.cpp @@ -196,7 +196,7 @@ unsigned char Elements::guessAtomicNumber(const std::string& inputStr) str[0] = static_cast(toupper(static_cast(str[0]))); int length = str.size(); - unsigned char atomicNumber; + unsigned char atomicNumber = InvalidElement; while (length > 0) { if (length > 3) atomicNumber = atomicNumberFromName(str.substr(0, length)); diff --git a/avogadro/io/gromacsformat.cpp b/avogadro/io/gromacsformat.cpp index d3e9430ee7..9ed05b4848 100644 --- a/avogadro/io/gromacsformat.cpp +++ b/avogadro/io/gromacsformat.cpp @@ -54,7 +54,7 @@ bool GromacsFormat::read(std::istream& in, Molecule& molecule) { string buffer; string value; - Residue* r; + Residue* r = nullptr; size_t currentResidueId = 0; // Title @@ -138,7 +138,9 @@ bool GromacsFormat::read(std::istream& in, Molecule& molecule) // Atom name: value = trimmed(buffer.substr(10, 5)); Atom atom; - int atomicNum = r->getAtomicNumber(value); + int atomicNum = 0; + if (r != nullptr) + r->getAtomicNumber(value); if (atomicNum) { atom = molecule.addAtom(atomicNum); } else { diff --git a/avogadro/io/lammpsformat.cpp b/avogadro/io/lammpsformat.cpp index 5c7d5a409e..c8502d7d28 100644 --- a/avogadro/io/lammpsformat.cpp +++ b/avogadro/io/lammpsformat.cpp @@ -426,6 +426,7 @@ bool LammpsDataFormat::write(std::ostream& outStream, const Core::Molecule& mol) std::ostringstream massStream, atomStream, bondStream; double xmin, xmax, ymin, ymax, zmin, zmax; + xmin = xmax = ymin = ymax = zmin = zmax = 0.0; size_t numAtoms = mol2.atomCount(); outStream << to_string(numAtoms) << " atoms\n"; diff --git a/avogadro/io/pdbformat.cpp b/avogadro/io/pdbformat.cpp index 72366ded3e..d3f7e6aacc 100644 --- a/avogadro/io/pdbformat.cpp +++ b/avogadro/io/pdbformat.cpp @@ -43,7 +43,7 @@ bool PdbFormat::read(std::istream& in, Core::Molecule& mol) { string buffer; std::vector terList; - Residue* r; + Residue* r = nullptr; size_t currentResidueId = 0; bool ok(false); int coordSet = 0; @@ -173,7 +173,7 @@ bool PdbFormat::read(std::istream& in, Core::Molecule& mol) } else if (coordSet == 0) { Atom newAtom = mol.addAtom(atomicNum); newAtom.setPosition3d(pos); - if (r) { + if (r != nullptr) { r->addResidueAtom(atomName, newAtom); } rawToAtomId.push_back(mol.atomCount() - 1); diff --git a/avogadro/io/turbomoleformat.cpp b/avogadro/io/turbomoleformat.cpp index 7722fac509..2e226f784a 100644 --- a/avogadro/io/turbomoleformat.cpp +++ b/avogadro/io/turbomoleformat.cpp @@ -58,6 +58,8 @@ bool TurbomoleFormat::read(std::istream& inStream, Core::Molecule& mol) // possible lattice constants Real a, b, c, alpha, beta, gamma; + a = b = c = 100.0; + alpha = beta = gamma = 90.0; // defaults if periodicity is not 3 Vector3 v1(100.0, 0.0, 0.0); Vector3 v2(0.0, 100.0, 0.0); diff --git a/avogadro/qtplugins/templatetool/templatetool.cpp b/avogadro/qtplugins/templatetool/templatetool.cpp index 6882f601be..8263872e4f 100644 --- a/avogadro/qtplugins/templatetool/templatetool.cpp +++ b/avogadro/qtplugins/templatetool/templatetool.cpp @@ -370,7 +370,7 @@ void TemplateTool::atomLeftClick(QMouseEvent*) return; // Find dummy atom in template and get all necessary info - size_t templateDummyIndex; + size_t templateDummyIndex = 0; std::vector templateLigandIndices; std::vector templateLigandUIDs; for (size_t i = 0; i < templateMolecule.atomCount(); i++) {