-
Notifications
You must be signed in to change notification settings - Fork 33
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
I'm not sure whether "Java_org_jpl7_fli_Prolog_attach_1pool_1engine" actually unlocks the engine array in all cases #86
Comments
Thanks for spotting the lacking unlock. Added. The rest is a bit harder. Some remarks on how I see the status of jpl.c.
As for state variables, I do not know. I don't really consider them better in general. I agree that dealing with many return paths in a function that uses locking should not be done as it is here. I typically use one of two options:
In general I'm not in favor of large rewrites unless needed. Yes, there are moments that the mess got big enough to rethink the whole thing again. If that turns the mess into something that is so clear that it is obviously correct, great. If it merely turns it into something that it still far from trivial to grasp and especially when there is no extensive regression test suite, I rather fix what is there and rely on git to tell me what happened to the code when and why. This is particularly the case for code that lacks a person with a complete overview that is in charge. For short, we either come with a good plan how to further develop JPL and who takes responsibility of JPL for the next (say) 3 years or we stick with incremental fixes and improvements. I'm happy with either, but I'm not that person. |
I have let the magic of Eclipse C IDE work on
jpl.c
.It complained that
Java_org_jpl7_fli_Prolog_attach_1pool_1engine
does not always properly return a value. It is right.Then I noticed that with some likelihood, the engines array is not properly unlocked under circumstances of error.
The code was hard to read so I reengineered it as below (using a state variable instead of a goto just feels better).
It compiles but I haven't tried to run it yet (so there is some likelihood of non-success). Well, tell me what you think or if it's of any use.
(It seems that the C code tries to stay conservatively in before-C99 style, feels very "automotive industry"?. Also, the restriction on 80 columns is very old-school.)
Enough grumbling:
vs the original which is compressed as for embedded MCUs, but hard to ascertain:
The text was updated successfully, but these errors were encountered: