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

[refactoring] usb.c: Can we remove some unused code? #1211

Closed
hydroconstructor opened this issue Jan 6, 2022 · 2 comments · Fixed by #1210
Closed

[refactoring] usb.c: Can we remove some unused code? #1211

hydroconstructor opened this issue Jan 6, 2022 · 2 comments · Fixed by #1210

Comments

@hydroconstructor
Copy link
Collaborator

In usb.c there are next lines:

stlink_t *stlink_open_usb(...) {
line 1144:
    // TODO: Reading a environment variable in a usb open function is not very nice, this should
    // be refactored and moved into the CLI tools, and instead of giving USB_BUS:USB_ADDR a real
    // stlink serial string should be passed to this function. Probably people are using this
    // but this is very odd because as programmer can change to multiple busses and it is better
    // to detect them based on serial.
    char *device = getenv("STLINK_DEVICE");

Here supposed that there is an environment variable in user system with name "STLINK_DEVICE" and value "Device_bus:Device_Address". In case of presence such variable in user system function gets device bus and device address from USB devices list and compare them with ones in environment variable. If do not match then proceed with next USB device from list.

There is no such variable in my system. I can not find any place in code which set this variable. Function stlink_open_usb gets serial of ST-LINK in 3rd parameter and uses it to find right USB device. So may it be useful to completely remove all code which works with getenv function and variables device, devBus and devAddr?

@hydroconstructor
Copy link
Collaborator Author

hydroconstructor commented Jan 6, 2022

Pushed new commit to #1210 pull request

@Nightwalker-87
Copy link
Member

In general it is favourable to do so if there is no remaining use within the codebase.
However this must be assured for all platforms.

Please note that no further refactoring should take place until the chip-id reading has been finally rewritten.
All old bindings need to be replaced and switched to new structure.

@Nightwalker-87 Nightwalker-87 changed the title usb.c refactoring request: can we remove some unused code? usb.c refactoring request: Can we remove some unused code? Jan 6, 2022
@Nightwalker-87 Nightwalker-87 changed the title usb.c refactoring request: Can we remove some unused code? [refactoring] usb.c: Can we remove some unused code? Jan 6, 2022
@stlink-org stlink-org locked as resolved and limited conversation to collaborators Jan 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants