Closed dunef-io closed 2 months ago
Attention: 2 lines
in your changes are missing coverage. Please review.
Comparison is base (
d185a37
) 79.82% compared to head (1f99b60
) 79.91%.
Files | Patch % | Lines |
---|---|---|
src/socket/dns.rs | 0.00% | 2 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Indeed, the documentation states that if the list of servers bigger than DNS_MAX_SERVER_COUNT
, it will panic.
There are two options:
DNS_MAX_SERVER_COUNT
.I'll leave the decision to @Dirbaio.
Your code might still panic. For example, it will panic when the length of the slice is smaller than DNS_MAX_SERVER_COUNT
.
The update should be something like:
self.servers = Vec::from_slice(&servers[..servers.len().min(DNS_MAX_SERVER_COUNT)]).unwrap();
Ahh yes thanks for the correction!
I think it's better that the there is an actual panic when the provided list of servers is bigger than DNS_MAX_SERVER_COUNT
. With your change, the user of the API would never know if all servers where added to the list of DNS servers. The function is also clearly documented that a panic might occur.
I wanted to connect my microcontroller with the wifi, but this library caused panics, because it found more than just one DNS Server. So I needed to change one line in the src/socket/dns.rs file with the update_servers method.
Instead of causing panic if the length of the servers argument exceeds DNS_MAX_SERVER_COUNT, it should take a slice of servers for the first DNS_MAX_SERVER_COUNT elements.