Commit 4def0958 authored by jean-pierre charras's avatar jean-pierre charras

Fix some coverity warnings. Fix typo and errors in comments. Very minor other fixes.

parent be785d55
......@@ -48,7 +48,7 @@
#include <sch_component.h>
static const int pin_orientation_codes[] =
static const int pin_orientation_codes[] =
{
PIN_RIGHT,
PIN_LEFT,
......@@ -61,7 +61,7 @@ static const int pin_orientation_codes[] =
// bitmaps to show pins orientations in dialog editor
// must have same order than pin_orientation_names
static const BITMAP_DEF s_icons_Pins_Orientations[] =
static const BITMAP_DEF iconsPinsOrientations[] =
{
pinorient_right_xpm,
pinorient_left_xpm,
......@@ -72,7 +72,7 @@ static const BITMAP_DEF s_icons_Pins_Orientations[] =
// bitmaps to show pins shapes in dialog editor
// must have same order than pin_style_names
static BITMAP_DEF s_icons_Pins_Shapes[] =
static BITMAP_DEF iconsPinsShapes[] =
{
pinshape_normal_xpm,
pinshape_invert_xpm,
......@@ -122,7 +122,7 @@ static const BITMAP_DEF iconsPinsElectricalType[] =
#define PIN_ELECTRICAL_TYPE_CNT DIM( iconsPinsElectricalType )
const wxString LIB_PIN::GetCanonicalElectricalTypeName( unsigned aType )
const wxString LIB_PIN::GetCanonicalElectricalTypeName( int aType )
{
// These strings are the canonical name of the electrictal type
// Not translated, no space in name, only ASCII chars.
......@@ -144,7 +144,7 @@ const wxString LIB_PIN::GetCanonicalElectricalTypeName( unsigned aType )
wxT( "???" )
};
if( aType >= PIN_NMAX )
if( aType < 0 || aType > int( PIN_NMAX ) )
aType = PIN_NMAX;
return msgPinElectricType[ aType ];
......@@ -155,7 +155,7 @@ const wxString LIB_PIN::GetCanonicalElectricalTypeName( unsigned aType )
// Note: the strings are *not* static because they are translated and must be built
// on the fly, to be properly translated
static const wxString getPinOrientationName( unsigned aPinOrientationCode )
static const wxString getPinOrientationName( int aPinOrientationCode )
{
/* Note: The following name lists are sentence capitalized per the GNOME UI
* standards for list controls. Please do not change the capitalization
......@@ -166,16 +166,17 @@ static const wxString getPinOrientationName( unsigned aPinOrientationCode )
_( "Right" ),
_( "Left" ),
_( "Up" ),
_( "Down" )
_( "Down" ),
wxT( "???" )
};
if( aPinOrientationCode < PIN_ORIENTATION_CNT )
return pin_orientation_names[ aPinOrientationCode ];
else
return wxT( "??" );
if( aPinOrientationCode < 0 || aPinOrientationCode > int( PIN_ORIENTATION_CNT ) )
aPinOrientationCode = PIN_ORIENTATION_CNT;
return pin_orientation_names[ aPinOrientationCode ];
}
const wxString LIB_PIN::GetElectricalTypeName( unsigned aPinsElectricalType )
const wxString LIB_PIN::GetElectricalTypeName( int aPinsElectricalType )
{
const wxString pin_electrical_type_names[] =
{ // Keep these translated strings not static
......@@ -189,16 +190,17 @@ const wxString LIB_PIN::GetElectricalTypeName( unsigned aPinsElectricalType )
_( "Power output" ),
_( "Open collector" ),
_( "Open emitter" ),
_( "Not connected" )
_( "Not connected" ),
wxT( "???" )
};
if( aPinsElectricalType < PIN_ELECTRICAL_TYPE_CNT )
return pin_electrical_type_names[ aPinsElectricalType ];
if( aPinsElectricalType < 0 || aPinsElectricalType > int( PIN_ELECTRICAL_TYPE_CNT ) )
aPinsElectricalType = PIN_ELECTRICAL_TYPE_CNT;
return wxT( "??" );
return pin_electrical_type_names[ aPinsElectricalType ];
}
const wxString getPinStyleName( unsigned aPinsStyle )
static const wxString getPinStyleName( int aPinsStyle )
{
const wxString pin_style_names[] =
{ // Keep these translated strings not static
......@@ -210,13 +212,14 @@ const wxString getPinStyleName( unsigned aPinsStyle )
_( "Clock low" ),
_( "Output low" ),
_( "Falling edge clock" ),
_( "NonLogic" )
_( "NonLogic" ),
wxT( "???" )
};
if( aPinsStyle < PIN_STYLE_CNT )
return pin_style_names[ aPinsStyle ];
if( aPinsStyle < 0 || aPinsStyle > int( PIN_STYLE_CNT ) )
aPinsStyle = PIN_STYLE_CNT;
return wxT( "??" );
return pin_style_names[ aPinsStyle ];
}
......@@ -2227,13 +2230,13 @@ const BITMAP_DEF* LIB_PIN::GetElectricalTypeSymbols()
const BITMAP_DEF* LIB_PIN::GetOrientationSymbols()
{
return s_icons_Pins_Orientations;
return iconsPinsOrientations;
}
const BITMAP_DEF* LIB_PIN::GetStyleSymbols()
{
return s_icons_Pins_Shapes;
return iconsPinsShapes;
}
......
......@@ -272,7 +272,7 @@ public:
* @param aType is the electrical type (see enum ElectricPinType )
* @return The electrical name for a pin type (see enun MsgPinElectricType for names).
*/
static const wxString GetCanonicalElectricalTypeName( unsigned aType );
static const wxString GetCanonicalElectricalTypeName( int aType );
/**
* return a string giving the electrical type of the pin.
......@@ -289,7 +289,7 @@ public:
* @param aType is the electrical type (see enum ElectricPinType )
* @return The electrical name of the pin (see enun MsgPinElectricType for names).
*/
static const wxString GetElectricalTypeName( unsigned aType );
static const wxString GetElectricalTypeName( int aType );
/**
* return a translated string for messages giving the electrical type of the pin.
......
......@@ -198,7 +198,7 @@ struct KIFACE
* @param aCtlBits consists of bit flags from the set of KFCTL_* \#defines above.
*
* @return wxWindow* - and if not NULL, should be cast into the known type using
* and old school cast. dynamic_cast is problemenatic since it needs typeinfo probably
* and old school cast. dynamic_cast is problematic since it needs typeinfo probably
* not contained in the caller's link image.
*/
VTBL_ENTRY wxWindow* CreateWindow( wxWindow* aParent, int aClassId,
......@@ -228,7 +228,7 @@ struct KIFACE
* having to link to the top process module which houses the KIWAY(s). More importantly
* it makes it possible to send custom wxEvents between DSOs and from the top
* process module down into the DSOs. The latter capability is thought useful
* for driving the lower DSOs from a python test rig or for demo (automaton) purposes.
* for driving the lower DSOs from a python test rig or for demo (automation) purposes.
* <p>
* Most all calls are via virtual functions, which means C++ vtables
* are used to hold function pointers and eliminate the need to link to specific
......
......@@ -82,6 +82,9 @@ public:
m_func( aEntry ), m_saved( NULL ), m_self( NULL ), m_stack( NULL ),
m_stackSize( c_defaultStackSize ), m_running( false )
{
// Avoid not initialized members, and make static analysers quiet
m_args = 0;
m_retVal = 0;
}
~COROUTINE()
......
......@@ -697,7 +697,9 @@ WORKSHEET_DATAITEM* PL_EDITOR_FRAME::Locate( const wxPoint& aPosition )
drawList.SetSheetNumber( screen->m_ScreenNumber );
drawList.SetSheetCount( screen->m_NumberOfScreens );
drawList.SetFileName( GetCurrFileName() );
drawList.SetSheetName( GetScreenDesc() );
// GetScreenDesc() returns a temporary string. Store it to avoid issues.
wxString descr = GetScreenDesc();
drawList.SetSheetName( descr );
drawList.BuildWorkSheetGraphicList( pageInfo, t_block, color, color );
......
......@@ -125,7 +125,7 @@ public:
}
/**
* Function AddMember
* Function Add
* adds \a aNetname to this NETCLASS if it is not already in this NETCLASS.
* It is harmless to try and add a second identical name.
*/
......
......@@ -531,6 +531,9 @@ TRACK* TRACK::GetEndNetCode( int NetCode )
void TRACK::DrawShortNetname( EDA_DRAW_PANEL* panel,
wxDC* aDC, GR_DRAWMODE aDrawMode, EDA_COLOR_T aBgColor )
{
if( ! panel )
return;
/* we must filter tracks, to avoid a lot of texts.
* - only tracks with a length > 10 * thickness are eligible
* and, of course, if we are not printing the board
......@@ -594,6 +597,7 @@ void TRACK::DrawShortNetname( EDA_DRAW_PANEL* panel,
}
LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
if( ( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE )
&& ( !(!IsOnLayer( curr_layer )&& displ_opts->m_ContrastModeDisplay) ) )
{
......@@ -601,8 +605,7 @@ void TRACK::DrawShortNetname( EDA_DRAW_PANEL* panel,
GRSetDrawMode( aDC, GR_COPY );
tsize = (tsize * 7) / 10; // small reduction to give a better look
EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
DrawGraphicHaloText( clipbox, aDC, tpos,
DrawGraphicHaloText( panel->GetClipBox(), aDC, tpos,
aBgColor, BLACK, WHITE, net->GetShortNetname(), angle,
wxSize( tsize, tsize ),
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
......
......@@ -421,7 +421,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, const void* testDa
* follows layer visibility controls (but that was already
* checked) */
if( via || module || pad || m_Guide->IsLayerVisible( layer )
if( via || module || pad || m_Guide->IsLayerVisible( layer )
|| !m_Guide->IgnoreNonVisibleLayers() )
{
if( !m_Guide->IsLayerLocked( layer ) || !m_Guide->IgnoreLockedLayers() )
......@@ -466,7 +466,7 @@ void GENERAL_COLLECTOR::Collect( BOARD_ITEM* aItem, const KICAD_T aScanList[],
SetTimeNow(); // when snapshot was taken
// record the length of the primary list before concatonating on to it.
// record the length of the primary list before concatenating on to it.
m_PrimaryLength = m_List.size();
// append 2nd list onto end of the first list
......
......@@ -228,7 +228,7 @@ protected:
/**
* The number of items that were originally in the primary list before the
* m_List2nd was concatonated onto the end of it.
* m_List2nd was concatenated onto the end of it.
*/
int m_PrimaryLength;
......
......@@ -107,7 +107,7 @@ public:
/**
* Function BuildPadsList
* Fills m_sortedPads with all pads that be connected to tracks
* pads are sorted by > then Y coordinates to allow fast binary search in list
* pads are sorted by X then Y coordinates to allow fast binary search in list
* @param aNetcode = net code to use to filter pads
* if aNetcode < 0, all pads will be put in list (default)
*/
......
......@@ -86,7 +86,7 @@ private:
///> Sets up handlers for various events.
void setTransitions();
///> Pointerto the currently used edit frame.
///> Pointer to the currently used edit frame.
PCB_BASE_FRAME* m_frame;
};
......
......@@ -225,7 +225,7 @@ private:
void setTransitions();
/**
* Function ClearSelection()
* Function clearSelection()
* Clears the current selection.
*/
void clearSelection();
......@@ -264,7 +264,7 @@ private:
bool selectable( const BOARD_ITEM* aItem ) const;
/**
* Function selectItem()
* Function select()
* Takes necessary action mark an item as selected.
*
* @param aItem is an item to be selected.
......@@ -272,7 +272,7 @@ private:
void select( BOARD_ITEM* aItem );
/**
* Function unselectItem()
* Function unselect()
* Takes necessary action mark an item as unselected.
*
* @param aItem is an item to be unselected.
......@@ -280,7 +280,7 @@ private:
void unselect( BOARD_ITEM* aItem );
/**
* Function unselectVisually()
* Function selectVisually()
* Marks item as selected, but does not add it to the ITEMS_PICKED_LIST.
* @param aItem is an item to be be marked.
*/
......@@ -294,7 +294,7 @@ private:
void unselectVisually( BOARD_ITEM* aItem ) const;
/**
* Function containsSelected()
* Function selectionContains()
* Checks if the given point is placed within any of selected items' bounding box.
*
* @return True if the given point is contained in any of selected items' bouding box.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment