-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing breaks #3290
Comments
As to problem 1: However, I still think that there should be a break at the end of the RET_INT case. It would not makes sense to go through the trouble to setup the All proposed changes from |
Can anybody say if O-word numbers can indeed have a decimal point? I think I tried with G70 and at least there it is not accepted. |
Without looking into this at all.... |
The RET_INT part is from return values through the python interface. It appears to come from remap, where you can map a python function to an O-word. That part seems to be understood. The question is whether it should fall through to RET_ERRORMSG resulting in an error. That seems wrong if you look at the RET_DOUBLE case. Also, the comment seems to indicate that a python mapped O-word returning an int is simply promoted to double and all should be swell. Therefore, there should be a break at the end of the RET_INT case. That is the question. |
The first one definitely looks wrong, I can only assume that it is a seldom-used bit of code. |
I decided that it almost certainly was as simple as it looked, and have pushed a fix. |
Ah yes, thanks. However, those weren't the only missing breaks. I'll make a PR to cover the remaining few (which are obvious errors). |
There are two unresolved switch case fall-through warnings that need review.
Problem case 1:
The code in emc/rs274ngc/interp_o_word.cc seems to be executed as a result of a python callable O-word, where the return value is integer. When the return value is double (RET_DOUBLE), then the case is concluded with a break. However, when the return value is integer (RET_INT), then the case falls through to the default case. Code in question (lines 621-659):
Not only is the break missing, but the else-clause within the RET_INT case is different from the RET_DOUBLE case. The double case calls (expands macro) ERS(), which stacks an error message and returns an INTERP_ERROR. The RET_INT case does not do the same thing.
I think the resolution should be to align the RET_INT case with the RET_DOUBLE case and change the RET_INT case to have both a break at the end and call ERS() in the else-clause.
Problem case 2:
Another part of the code in emc/rs274ngc/interp_o_word.cc handles O-word returns. There is a case in a sub-switch that handles INTERP_EXECUTE_FINISH, which falls through to the default case. Code in question (lines 392-514):
Falling through from INTERP_EXECUTE_FINISH causes
settings->calls_state
to be overwritten, which seems the wrong thing to do.I think there should be a break at the end of the INTERP_EXECUTE_FINISH case (after the CHP(status) macro).
Please advise on these two problem cases.
The text was updated successfully, but these errors were encountered: