Skip to content

Commit

Permalink
Fixing fragile code pointed out by static analysis.
Browse files Browse the repository at this point in the history
  • Loading branch information
russell-taylor committed Nov 15, 2014
1 parent f302e3d commit 565cf07
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions vrpn_Button.C
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ vrpn_Button_Python::vrpn_Button_Python(const char *name, vrpn_Connection *c,
vrpn_Button_Python::vrpn_Button_Python(const char *name, vrpn_Connection *c,
int p, unsigned ph)
: vrpn_Button_Parallel(name, c, p, ph)
, d_first_fail(true)
{
}

Expand Down
4 changes: 1 addition & 3 deletions vrpn_DevInput.C
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ VRPN_SUPPRESS_EMPTY_OBJECT_WARNING()
static const std::string &getDeviceNodes(const std::string &device_name) {
std::map<std::string, std::string> s_devicesNodes;

std::string none_found="";

bool permission_missing = false;
unsigned int id = 0;
while (1) {
Expand Down Expand Up @@ -64,7 +62,7 @@ static const std::string &getDeviceNodes(const std::string &device_name) {
return node_name->second;
}

return none_found;
return "";
}

///////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions vrpn_YEI_3Space.C
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ vrpn_YEI_3Space_Sensor::vrpn_YEI_3Space_Sensor (const char * p_name
}
}

vrpn_gettimeofday(&timestamp, NULL);

// Set the mode to reset
d_status = STATUS_RESETTING;
}
Expand Down
4 changes: 2 additions & 2 deletions vrpn_inertiamouse.C
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ int vrpn_inertiamouse::get_report(void)
packet |= (buffer_[++nextchar] & 0xf0) >> 4;

int chnl = (packet >> 10) & 7;
if (chnl > Channels) {
if (chnl >= Channels) {
status_ = STATUS_SYNCING;
send_text_message("vrpn_inertiamouse: Too-large channel value",
timestamp,
Expand All @@ -175,7 +175,7 @@ int vrpn_inertiamouse::get_report(void)
// normval *= 1.5;

// update rotation data
if (chnl == 4 || chnl == 5) {
if ( (chnl == 4) || (chnl == 5) ) {
channel[chnl] = normval;
break;
}
Expand Down

0 comments on commit 565cf07

Please sign in to comment.