Fixed some issues found by Coverity scan.

This commit is contained in:
Matthias Koefferlein 2018-03-19 18:24:09 +01:00
parent cabd8bbdf1
commit 415d52f35d
10 changed files with 28 additions and 14 deletions

View File

@ -449,6 +449,9 @@ CIFReader::read_cell (db::Layout &layout, db::Cell &cell, double sf, int level)
if (! test_semi ()) {
denom = read_integer ();
divider = read_integer ();
if (divider == 0) {
error ("'DS' command: divider cannot be zero");
}
}
expect_semi ();
@ -476,7 +479,7 @@ CIFReader::read_cell (db::Layout &layout, db::Cell &cell, double sf, int level)
// DF command:
// "D" blank* "F"
if (level == 0) {
error ("'DS' command must be inside a cell specification");
error ("'DF' command must be inside a cell specification");
}
// skip the rest of the command
@ -490,7 +493,7 @@ CIFReader::read_cell (db::Layout &layout, db::Cell &cell, double sf, int level)
// "D" blank* "D" integer
read_integer ();
warn ("DD command ignored");
warn ("'DD' command ignored");
skip_to_end ();
} else {

View File

@ -665,6 +665,9 @@ OASISWriter::OASISWriter ()
mp_cell (0),
m_layer (0), m_datatype (0),
m_in_cblock (false),
m_propname_id (0),
m_propstring_id (0),
m_proptables_written (false),
m_progress (tl::to_string (QObject::tr ("Writing OASIS file")), 10000)
{
m_progress.set_format (tl::to_string (QObject::tr ("%.0f MB")));

View File

@ -104,6 +104,8 @@ RecursiveShapeIterator::RecursiveShapeIterator ()
mp_shape_prop_sel = 0;
m_shape_inv_prop_sel = false;
m_needs_reinit = false;
m_inst_quad_id = 0;
m_shape_quad_id = 0;
}
RecursiveShapeIterator::RecursiveShapeIterator (const shapes_type &shapes)

View File

@ -36,7 +36,8 @@ class LayoutDiff
{
public:
LayoutDiff ()
: mp_layout_a (0), mp_layout_b (0)
: mp_layout_a (0), mp_cell_a (0), m_layer_index_a (0),
mp_layout_b (0), mp_cell_b (0), m_layer_index_b (0)
{
// .. nothing yet ..
}

View File

@ -49,13 +49,13 @@ struct A : public db::Object
x += d;
}
void undo (db::Op *op) throw ()
void undo (db::Op *op)
{
AO *aop = dynamic_cast<AO *> (op);
x -= aop->d;
}
void redo (db::Op *op) throw ()
void redo (db::Op *op)
{
AO *aop = dynamic_cast<AO *> (op);
tl_assert (aop != 0);
@ -154,13 +154,13 @@ struct B : public db::Object
}
}
void undo (db::Op *op) throw ()
void undo (db::Op *op)
{
BO *bop = dynamic_cast<BO *> (op);
x -= bop->d;
}
void redo (db::Op *op) throw ()
void redo (db::Op *op)
{
BO *bop = dynamic_cast<BO *> (op);
tl_assert (bop != 0);

View File

@ -703,7 +703,8 @@ SearchReplaceDialog::SearchReplaceDialog (lay::PluginRoot *root, lay::LayoutView
m_current_mode (0),
m_window (FitMarker),
m_window_dim (0.0),
m_max_item_count (0)
m_max_item_count (0),
m_last_query_cv_index (0)
{
setObjectName (QString::fromUtf8 ("search_replace_dialog"));

View File

@ -1143,7 +1143,7 @@ static bool
skip_quad (const db::Box &qb, const lay::Bitmap *vertex_bitmap, const db::CplxTrans &trans)
{
double threshold = 32 / trans.mag (); // don't check cells below 32x32 pixels
if (qb.empty () || qb.width () > threshold || qb.height () > threshold) {
if (qb.empty () || qb.width () > threshold || qb.height () > threshold || !vertex_bitmap) {
return false;
}

View File

@ -321,7 +321,7 @@ SaveLayoutOptionsDialog::get_options_internal ()
// SaveLayoutAsOptionsDialog implementation
SaveLayoutAsOptionsDialog::SaveLayoutAsOptionsDialog (QWidget *parent, const std::string &title)
: QDialog (parent), Ui::SaveLayoutAsOptionsDialog ()
: QDialog (parent), Ui::SaveLayoutAsOptionsDialog (), mp_tech (0)
{
setObjectName (QString::fromUtf8 ("save_layout_options_dialog"));

View File

@ -401,7 +401,7 @@ public:
bool cat_matches (const QModelIndex &index, const QString &filter) const
{
MarkerBrowserTreeViewModelCacheEntry *node = (MarkerBrowserTreeViewModelCacheEntry *)(index.internalPointer ());
if (node) {
if (node && mp_database) {
rdb::id_type id = node->id ();
const rdb::Category *category = mp_database->category_by_id (id);
@ -418,7 +418,7 @@ public:
bool cell_matches (const QModelIndex &index, const QString &filter) const
{
MarkerBrowserTreeViewModelCacheEntry *node = (MarkerBrowserTreeViewModelCacheEntry *)(index.internalPointer ());
if (node) {
if (node && mp_database) {
rdb::id_type id = node->id ();
const rdb::Cell *cell = mp_database->cell_by_id (id);
@ -435,7 +435,7 @@ public:
bool no_errors (const QModelIndex &index) const
{
MarkerBrowserTreeViewModelCacheEntry *node = (MarkerBrowserTreeViewModelCacheEntry *)(index.internalPointer ());
if (node) {
if (node && mp_database) {
rdb::id_type id = node->id ();
bool none = false;
@ -638,6 +638,10 @@ public:
QModelIndex next_index (QModelIndex current_index, bool up)
{
if (!mp_database) {
return QModelIndex ();
}
MarkerBrowserTreeViewModelCacheEntry *node = (MarkerBrowserTreeViewModelCacheEntry *) current_index.internalPointer ();
rdb::id_type id = node->id ();

View File

@ -41,7 +41,7 @@ inline void usleep(long us)
class Sum
{
public:
Sum () : m_sum(0) { }
Sum () : m_sum(0), m_flag (false) { }
void reset () { lock.lock (); m_sum = 0; lock.unlock (); m_flag = false; }
void add(int n) { lock.lock (); m_sum += n; lock.unlock (); m_flag = true; }