William, Am 26.01.20 um 18:41 schrieb William Dauchy: > int dns_hostname_validation(const char *string, char **err) > { > - const char *c, *d; > int i;
Consider moving this into the `while` loop to reduce the scope of `i`. > + while (*string && *string != '.' && i < DNS_MAX_LABEL_SIZE) { Here you check `*string` > [...] > - if ((i >= DNS_MAX_LABEL_SIZE) && (d[i] != '.')) { > + if (*string == '\0') Here you check `*string == '\0'`. For consistency consider to to either: *string and !*string or *string != '\0' and *string == '\0' or *string != 0 and *string == 0 - Overall I think your version is much more readable than the old one. It's also easier to understand and assert its correctness. Best regards Tim Düsterhus