Merge pull request #546 from KLayout/sonarqube-fixes

Sonarqube fixes
This commit is contained in:
Matthias Köfferlein 2020-04-30 22:06:38 +02:00 committed by GitHub
commit cb3833f563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 108 additions and 49 deletions

View File

@ -331,6 +331,7 @@ BD_PUBLIC int strmxor (int argc, char *argv[])
xor_data.threads = threads; xor_data.threads = threads;
xor_data.tile_size = tile_size; xor_data.tile_size = tile_size;
xor_data.output_layout = output_layout.get (); xor_data.output_layout = output_layout.get ();
xor_data.output_cell = output_top;
xor_data.l2l_map = l2l_map; xor_data.l2l_map = l2l_map;
xor_data.results = &results; xor_data.results = &results;

View File

@ -427,6 +427,9 @@ struct PathCompareOpWithTolerance
db::Path::iterator ia = a.begin (), ib = b.begin (); db::Path::iterator ia = a.begin (), ib = b.begin ();
while (ia != a.end () && ib != b.end ()) { while (ia != a.end () && ib != b.end ()) {
c = compare_point (*ia, *ib, m_tolerance); c = compare_point (*ia, *ib, m_tolerance);
if (c != 0) {
return c < 0;
}
++ia; ++ia;
++ib; ++ib;
} }

View File

@ -358,8 +358,10 @@ void LayoutToNetlistStandardReader::read_netlist (db::Netlist *netlist, db::Layo
dm->set_name (name); dm->set_name (name);
netlist->add_device_abstract (dm); netlist->add_device_abstract (dm);
if (l2n) {
db::cell_index_type ci = l2n->internal_layout ()->add_cell (name.c_str ()); db::cell_index_type ci = l2n->internal_layout ()->add_cell (name.c_str ());
dm->set_cell_index (ci); dm->set_cell_index (ci);
}
std::string cls; std::string cls;
read_word_or_quoted (cls); read_word_or_quoted (cls);

View File

@ -90,6 +90,7 @@ LibraryManager::delete_lib (Library *library)
library->remap_to (0); library->remap_to (0);
delete library; delete library;
m_libs [id] = 0; m_libs [id] = 0;
break;
} }
} }
} }

View File

@ -0,0 +1,24 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2020 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "dbPlugin.h"

View File

@ -133,3 +133,4 @@ Class<db::Manager> decl_Manager ("db", "Manager",
); );
} }

View File

@ -1,3 +1,4 @@
/* /*
KLayout Layout Viewer KLayout Layout Viewer

View File

@ -1300,15 +1300,17 @@ TEST(6)
EXPECT_EQ (r.text (), EXPECT_EQ (r.text (),
"layout_diff: paths differ for layer 17/0 in cell c2x\n" "layout_diff: paths differ for layer 17/0 in cell c2x\n"
"Not in b but in a:\n" "Not in b but in a:\n"
" (1,2;11,12) w=17 bx=0 ex=0 r=false\n"
"Not in a but in b:\n" "Not in a but in b:\n"
" (1,2;11,12) w=17 bx=0 ex=0 r=true\n" " (1,2;11,12) w=17 bx=0 ex=0 r=true\n"
" (1,2;11,12) w=17 bx=0 ex=-1 r=false\n" " (1,2;11,12) w=17 bx=0 ex=-1 r=false\n"
" (1,3;11,11) w=17 bx=0 ex=0 r=false\n" " (1,3;11,11) w=17 bx=0 ex=0 r=false\n"
" (1,3;11,12) w=17 bx=0 ex=0 r=false\n"
" (1,2;11,12) w=17 bx=1 ex=0 r=false\n" " (1,2;11,12) w=17 bx=1 ex=0 r=false\n"
" (1,2;11,12) w=18 bx=0 ex=0 r=false\n" " (1,2;11,12) w=18 bx=0 ex=0 r=false\n"
); );
// two more to match more of h: // some more to match more of h:
g.cell (c2i).shapes (0).insert (p); g.cell (c2i).shapes (0).insert (p);
g.cell (c2i).shapes (0).insert (p); g.cell (c2i).shapes (0).insert (p);
g.cell (c2i).shapes (0).insert (p); g.cell (c2i).shapes (0).insert (p);

View File

@ -618,21 +618,21 @@ public:
size_t n = data_length (); size_t n = data_length ();
for (unsigned int i = 0; i < 3; ++i) { for (unsigned int i = 0; i < 3; ++i) {
if (mp_color_data[i]) { if (mp_color_data[i]) {
stat->add (typeid (float []), (void *) mp_color_data[i], sizeof (n * sizeof (float)), sizeof (n * sizeof (float)), (void *) this, purpose, cat); stat->add (typeid (float []), (void *) mp_color_data[i], n * sizeof (float), n * sizeof (float), (void *) this, purpose, cat);
} }
if (mp_color_byte_data[i]) { if (mp_color_byte_data[i]) {
stat->add (typeid (unsigned char []), (void *) mp_color_byte_data[i], sizeof (n * sizeof (unsigned char)), sizeof (n * sizeof (unsigned char)), (void *) this, purpose, cat); stat->add (typeid (unsigned char []), (void *) mp_color_byte_data[i], n * sizeof (unsigned char), n * sizeof (unsigned char), (void *) this, purpose, cat);
} }
} }
if (mp_mask) { if (mp_mask) {
stat->add (typeid (unsigned char []), (void *) mp_mask, sizeof (n * sizeof (unsigned char)), sizeof (n * sizeof (unsigned char)), (void *) this, purpose, cat); stat->add (typeid (unsigned char []), (void *) mp_mask, n * sizeof (unsigned char), n * sizeof (unsigned char), (void *) this, purpose, cat);
} }
if (mp_data) { if (mp_data) {
stat->add (typeid (float []), (void *) mp_data, sizeof (n * sizeof (float)), sizeof (n * sizeof (float)), (void *) this, purpose, cat); stat->add (typeid (float []), (void *) mp_data, n * sizeof (float), n * sizeof (float), (void *) this, purpose, cat);
} }
if (mp_byte_data) { if (mp_byte_data) {
stat->add (typeid (unsigned char []), (void *) mp_byte_data, sizeof (n * sizeof (unsigned char)), sizeof (n * sizeof (unsigned char)), (void *) this, purpose, cat); stat->add (typeid (unsigned char []), (void *) mp_byte_data, n * sizeof (unsigned char), n * sizeof (unsigned char), (void *) this, purpose, cat);
} }
} }

View File

@ -1675,7 +1675,6 @@ LayoutView::enable_edits (bool enable)
if (m_disabled_edits > 0) { if (m_disabled_edits > 0) {
--m_disabled_edits; --m_disabled_edits;
} }
enable = (m_disabled_edits == 0);
} else { } else {
++m_disabled_edits; ++m_disabled_edits;
} }

View File

@ -1131,11 +1131,10 @@ LayoutViewConfigPage6::stipple_button_clicked ()
if (m_palette.stipples () > i) { if (m_palette.stipples () > i) {
unsigned int s = m_palette.stipple_by_index (i);
SelectStippleForm stipples_form (0, m_pattern); SelectStippleForm stipples_form (0, m_pattern);
if (stipples_form.exec () && stipples_form.selected () >= 0) { if (stipples_form.exec () && stipples_form.selected () >= 0) {
s = stipples_form.selected (); unsigned int s = stipples_form.selected ();
m_manager.transaction (tl::to_string (QObject::tr ("Set stipple"))); m_manager.transaction (tl::to_string (QObject::tr ("Set stipple")));
m_manager.queue (this, new StipplePaletteOp (m_palette, false, true /*before*/)); m_manager.queue (this, new StipplePaletteOp (m_palette, false, true /*before*/));
@ -1350,11 +1349,10 @@ LayoutViewConfigPage6a::line_style_button_clicked ()
if (m_palette.styles () > i) { if (m_palette.styles () > i) {
unsigned int s = m_palette.style_by_index (i);
SelectLineStyleForm styles_form (0, m_style); SelectLineStyleForm styles_form (0, m_style);
if (styles_form.exec () && styles_form.selected () >= 0) { if (styles_form.exec () && styles_form.selected () >= 0) {
s = styles_form.selected (); unsigned int s = styles_form.selected ();
m_manager.transaction (tl::to_string (QObject::tr ("Set style"))); m_manager.transaction (tl::to_string (QObject::tr ("Set style")));
m_manager.queue (this, new LineStylePaletteOp (m_palette, true /*before*/)); m_manager.queue (this, new LineStylePaletteOp (m_palette, true /*before*/));

View File

@ -1406,7 +1406,6 @@ DXFReader::read_entities (db::Layout &layout, db::Cell &cell, const db::DVector
std::string layer; std::string layer;
int flags = 0; int flags = 0;
double width1 = 0.0, width2 = 0.0; double width1 = 0.0, width2 = 0.0;
unsigned int got_width = 0;
double common_width1 = 0.0, common_width2 = 0.0; double common_width1 = 0.0, common_width2 = 0.0;
unsigned int common_width_set = 0; unsigned int common_width_set = 0;
double ex = 0.0, ey = 0.0, ez = 1.0; double ex = 0.0, ey = 0.0, ez = 1.0;
@ -1417,6 +1416,7 @@ DXFReader::read_entities (db::Layout &layout, db::Cell &cell, const db::DVector
unsigned int xy_flags = 0; unsigned int xy_flags = 0;
double x = 0.0, y = 0.0; double x = 0.0, y = 0.0;
unsigned int got_width = 0;
while ((g = read_group_code ()) != 0) { while ((g = read_group_code ()) != 0) {
@ -1445,7 +1445,6 @@ DXFReader::read_entities (db::Layout &layout, db::Cell &cell, const db::DVector
if (got_width == 3) { if (got_width == 3) {
widths.push_back (std::make_pair (seg_start, width1)); widths.push_back (std::make_pair (seg_start, width1));
widths.push_back (std::make_pair (points.size () - 1, width2)); widths.push_back (std::make_pair (points.size () - 1, width2));
got_width = 0;
} }
got_width = 0; got_width = 0;
@ -1516,7 +1515,7 @@ DXFReader::read_entities (db::Layout &layout, db::Cell &cell, const db::DVector
const std::string &e = read_string (true); const std::string &e = read_string (true);
if (e == "VERTEX") { if (e == "VERTEX") {
got_width = 0; unsigned int got_width = 0;
double x = 0.0, y = 0.0; double x = 0.0, y = 0.0;
double bnew = 0.0; double bnew = 0.0;
@ -1551,7 +1550,6 @@ DXFReader::read_entities (db::Layout &layout, db::Cell &cell, const db::DVector
if (got_width == 3) { if (got_width == 3) {
widths.push_back (std::make_pair (seg_start, width1)); widths.push_back (std::make_pair (seg_start, width1));
widths.push_back (std::make_pair (points.size () - 1, width2)); widths.push_back (std::make_pair (points.size () - 1, width2));
got_width = 0;
} }
} else if (e == "SEQEND") { } else if (e == "SEQEND") {
@ -2303,7 +2301,6 @@ DXFReader::read_entities (db::Layout &layout, db::Cell &cell, const db::DVector
// close previous loop if necessary // close previous loop if necessary
finish_loop (loop_start, iedges.size (), iedges); finish_loop (loop_start, iedges.size (), iedges);
loop_start = iedges.size ();
// create the polygons // create the polygons
std::pair <bool, unsigned int> ll = open_layer (layout, layer); std::pair <bool, unsigned int> ll = open_layer (layout, layer);

View File

@ -384,3 +384,4 @@ gsi::ClassExt<db::SaveLayoutOptions> dxf_writer_options (
); );
} }

View File

@ -293,3 +293,4 @@ gsi::ClassExt<db::SaveLayoutOptions> oasis_writer_options (
); );
} }

View File

@ -1,3 +1,4 @@
/* /*
KLayout Layout Viewer KLayout Layout Viewer

View File

@ -526,7 +526,7 @@ PyObject *c2python_func<const char *>::operator() (const char *p)
#if PY_MAJOR_VERSION < 3 #if PY_MAJOR_VERSION < 3
return PyString_FromString (s); return PyString_FromString (s);
#else #else
PyObject *ret = PyUnicode_DecodeUTF8 (p, strlen (p), NULL); PyObject *ret = PyUnicode_DecodeUTF8 (s, strlen (s), NULL);
if (ret == NULL) { if (ret == NULL) {
check_error (); check_error ();
} }

View File

@ -1930,6 +1930,7 @@ property_getter_impl (int mid, PyObject *self)
// a signal getter is implemented as returning a proxy object for the signal which allows manipulation // a signal getter is implemented as returning a proxy object for the signal which allows manipulation
// of the signal // of the signal
tl_assert (p != 0); // no static signals
return PYASignal::create (self, p->signal_handler (meth)); return PYASignal::create (self, p->signal_handler (meth));
} else { } else {

View File

@ -104,10 +104,10 @@ class _PCellDeclarationHelper(PCellDeclaration):
pdecl.unit = unit pdecl.unit = unit
if not (choices is None): if not (choices is None):
if not isinstance(choices, list) and not isinstance(choices, tuple): if not isinstance(choices, list) and not isinstance(choices, tuple):
raise "choices value must be an list/tuple of two-element arrays (description, value)" raise Exception("choices value must be an list/tuple of two-element arrays (description, value)")
for c in choices: for c in choices:
if (not isinstance(choices, list) and not isinstance(choices, tuple)) or len(c) != 2: if (not isinstance(choices, list) and not isinstance(choices, tuple)) or len(c) != 2:
raise "choices value must be an list/tuple of two-element arrays (description, value)" raise Exception("choices value must be an list/tuple of two-element arrays (description, value)")
pdecl.add_choice(c[0], c[1]) pdecl.add_choice(c[0], c[1])
# return the declaration object for further operations # return the declaration object for further operations

View File

@ -38,7 +38,9 @@ namespace tl
TL_PUBLIC NO_RETURN void assertion_failed (const char *filename, unsigned int line, const char *condition); TL_PUBLIC NO_RETURN void assertion_failed (const char *filename, unsigned int line, const char *condition);
// the throw int(0) instruction will tell the compiler that the assertion will not return // the throw int(0) instruction will tell the compiler that the assertion will not return
#define tl_assert(COND) if (!(COND)) { tl::assertion_failed (__FILE__, __LINE__, #COND); } #define tl_assert(COND) if (!(COND)) { \
tl::assertion_failed (__FILE__, __LINE__, #COND); \
}
} // namespace tl } // namespace tl

View File

@ -0,0 +1,24 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2020 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "tlVector.h"