motoman icon indicating copy to clipboard operation
motoman copied to clipboard

Missing `else` condition

Open ted-miller opened this issue 2 years ago • 4 comments

A user has found a missing else condition. This leads to an improper response to an unknown message type.

https://github.com/ros-industrial/motoman/blob/7860ff545106d98ed6a3fa0121f2fb60891f69bd/motoman_driver/MotoPlus/SimpleMessage.c#L153

ted-miller avatar Aug 29 '22 12:08 ted-miller

Isn't the actual consequence the else will always be taken if receiveMsg->header.msgType != ROS_MSG_MOTO_SELECT_TOOL?

So https://github.com/ros-industrial/motoman/blob/7860ff545106d98ed6a3fa0121f2fb60891f69bd/motoman_driver/MotoPlus/SimpleMessage.c#L160-L162

will always be executed?

gavanderhoorn avatar Aug 30 '22 09:08 gavanderhoorn

Without the "else" on line 153, all the preceeding code (line 138 to 152) is pointless because whatever is set in that code gets overwritten by line 161 and 162.

EricMarcil avatar Aug 30 '22 12:08 EricMarcil

Yes. That is what I wrote.

But only if msgType != ROS_MSG_MOTO_SELECT_TOOL.

gavanderhoorn avatar Aug 30 '22 12:08 gavanderhoorn

Isn't the actual consequence the else will always be taken if receiveMsg->header.msgType != ROS_MSG_MOTO_SELECT_TOOL?

Yes, you're correct. Now that I think about it some more... this might explain some wireshark captures that I've seen in the past that had unexpected sequence-id's in the reply. (I don't remember for certain. But I think I've seen this and just ignored it.)

ted-miller avatar Aug 30 '22 12:08 ted-miller

Closing as #550 was merged (replacement PR).

gavanderhoorn avatar Jun 28 '23 13:06 gavanderhoorn