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