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

Use upsdebug_with_errno() instead of a few cases calling upsdebugx(..., errno, strerror()) explicitly #2396

Open
jimklimov opened this issue Apr 13, 2024 · 0 comments
Labels
enhancement Low-hanging fruit A proposal or issue that is good for newcomers to codebase or otherwise a quick win refactor/fightwarn PR or issue proposal to improve code maintainability without functional changes, or to fix warnings
Milestone

Comments

@jimklimov
Copy link
Member

jimklimov commented Apr 13, 2024

We have a nice helper method and a handful of places that can be made more simple with this change.

Single-line hits are easy to find with git grep (there may be more with multi-line code involved):

:;  git grep -E upsdebugx'.*(strerror|errno)' | grep -v _strerror
clients/upssched.c:                     upsdebugx(6, "read() from fd %d returned %" PRIiSIZE " (bytes): '%c'; errno=%d: %s",
clients/upssched.c:                                     upsdebugx(4, "read() from fd %d returned 0; errno=%d: %s",
drivers/blazer_ser.c:           upsdebugx(3, "send: %s", ret ? strerror(errno) : "timeout");
drivers/blazer_ser.c:           upsdebugx(3, "read: %s", ret ? strerror(errno) : "timeout");
drivers/main.c:                         upsdebugx(1, "Socket dialog with the other driver instance: %s", strerror(errno));
drivers/main.c:                 upsdebugx_with_errno(1, "Socket dialog with the other driver instance");
drivers/riello_usb.c:                   upsdebugx(3, "USB: Send_USB_Packet: send_usb_packet, err = %d %s ", err, strerror(errno));
drivers/riello_usb.c:                   upsdebugx(3, "USB: Send_USB_Packet: send_usb_packet, err = %d %s ", err, strerror(errno));
drivers/riello_usb.c:           upsdebugx(3, "USB: Get_USB_Packet: send_usb_packet, err = %d %s ", err, strerror(errno));

(Note we have quite a few helpers like nut_usb_strerror, shut_strerror, modbus_strerror... which do not easily fall into this cleanup's targets, but might benefit from similar helpers).

@jimklimov jimklimov added enhancement refactor/fightwarn PR or issue proposal to improve code maintainability without functional changes, or to fix warnings Low-hanging fruit A proposal or issue that is good for newcomers to codebase or otherwise a quick win labels Apr 13, 2024
@jimklimov jimklimov added this to the 2.8.3 milestone Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Low-hanging fruit A proposal or issue that is good for newcomers to codebase or otherwise a quick win refactor/fightwarn PR or issue proposal to improve code maintainability without functional changes, or to fix warnings
Projects
None yet
Development

No branches or pull requests

1 participant