canterp presumed missinterpretation of scanf return value#3826
canterp presumed missinterpretation of scanf return value#3826smoe wants to merge 2 commits intoLinuxCNC:masterfrom
Conversation
|
Also correct. The test on sscanf is supposed to be exact and requires to match the number of conversions requested. Otherwise it makes no sense. That said, canon's STRAIGHT_PROBE also has a probe-type argument, but that is apparently not supported/implemented? |
|
Checked the man page - "These functions return the number of input items assigned. This can be fewer than provided for, or even zero, in the event of a matching failure.". So, there may be something hidden by that magic omission of 3 arguments that I fail to grasp. We need some tests for this. And for other bits :-) |
Feels like we have some problem on a meta level that allows for any such inconsistencies. |
|
There is a lack of automatic quality control because there is a lack of one or another form of unit tests (primarily internal tests of APIs). Using the static analysis of cppcheck uncovered many bugs and inconsistencies, but fails to detect logic errors (like the sscanf issue or using the wrong variable). There are many more lurking in the code. Ideas are welcome to extend (static) testing on that. Internal tests need to be implemented to check both consistency and function of those parts that the user normally never sees. And that is not always a simple task(*). There is afaik no standard framework to cope with the complexities and intricacies of LCNC, so it would need to be written. A heavy task that we can put on the TODO pile... (*) and they need to be parallelizable to speed things up |
|
It feels like it would make sense to be able to omit ABCUVW if Canterp was a real interpreter. |
A comment should be added if the comparison against 6 is correct - 6 <= scanf() if there are some values not expected to be set, or 9, since all values are used downstream.