multun commented on this pull request.
> + sprintf(buf, "255.255.255.%d", n_octet);
+ addr_len = 4;
+ } else if (cidr > 16) {
+ sprintf(buf, "255.255.%d.0", n_octet);
+ addr_len = 3;
+ } else if (cidr > 8) {
+ sprintf(buf, "255.%d.0.0", n_octet);
+ addr_len = 2;
+ } else if (cidr > 0) {
+ sprintf(buf, "%d.0.0.0", n_octet);
+ addr_len = 1;
+ } else if (cidr == 0) {
+ sprintf(buf, "0.0.0.0");
+ addr_len = 0;
+ } else {
+ DBGC(cidr, "Unknown netmask descriptor /%d.\n", cidr);
I don't quite get what's the point of having an individual format string for
each full byte. Isn't converting it to a netmask already sufficient ?
```python
def cidr_to_netmask(cidr):
return tuple(0xFF & ~((1 << (8 - min(8, cidr - i * 8))) - 1) for i in
range(4))
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/ipxe/ipxe/pull/67#pullrequestreview-116469263
_______________________________________________
ipxe-devel mailing list
ipxe-devel@lists.ipxe.org
https://lists.ipxe.org/mailman/listinfo.cgi/ipxe-devel