Skip to content
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

Logic issue in AsebaSendChangedVariables #992

Open
ypiguet-epfl opened this issue Feb 21, 2022 · 0 comments
Open

Logic issue in AsebaSendChangedVariables #992

ypiguet-epfl opened this issue Feb 21, 2022 · 0 comments

Comments

@ypiguet-epfl
Copy link
Collaborator

In function AsebaSendChangedVariables in aseba/transport/buffer/vm-buffer.c, about the test vm->variablesOld && idx <= vm->variablesSize in the for loop: vm->variablesOld is probably defined (non-NULL) in all Mobsya uses, including in aseba-target-thymio2 (definition of vmState in file skel-usb.c). But if the purpose of vm->variablesOld && is to handle cases where variablesOld doesn't exist, i.e. vm->variablesOld is NULL, then:

  • No need to test it for every loop iteration, it would be better to do it once with an if
  • No message will be sent at all, clients like Aseba Studio will never receive the requested information. I'd suggest
    if (vm->variablesOld)
        for (idx = 0; idx <= vm->variablesSize; idx++) {
            ...
        }
    else
        AsebaSendVariables(vm, 0, vm->variablesSize);
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant