Skip to content

Comments

canterp presumed missinterpretation of scanf return value#3826

Open
smoe wants to merge 2 commits intoLinuxCNC:masterfrom
smoe:caterp_fix_scanf
Open

canterp presumed missinterpretation of scanf return value#3826
smoe wants to merge 2 commits intoLinuxCNC:masterfrom
smoe:caterp_fix_scanf

Conversation

@smoe
Copy link
Collaborator

@smoe smoe commented Feb 24, 2026

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.

@smoe smoe added bug for-discussion-only This pull request is intended as a basis for discussion, not to be merged as-is labels Feb 24, 2026
@BsAtHome
Copy link
Contributor

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?

@smoe
Copy link
Collaborator Author

smoe commented Feb 24, 2026

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 :-)

@smoe smoe removed for-discussion-only This pull request is intended as a basis for discussion, not to be merged as-is labels Feb 24, 2026
@smoe
Copy link
Collaborator Author

smoe commented Feb 24, 2026

That said, canon's STRAIGHT_PROBE also has a probe-type argument, but that is apparently not supported/implemented?

Feels like we have some problem on a meta level that allows for any such inconsistencies.

@BsAtHome
Copy link
Contributor

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

@andypugh
Copy link
Collaborator

It feels like it would make sense to be able to omit ABCUVW if Canterp was a real interpreter.
But that would be 3, not 6.
All the example commands in canterp_example.can use all 9 axis values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants