On Wed, 30.07.14 00:37, Zbigniew Jędrzejewski-Szmek (zbys...@in.waw.pl) wrote:
> > +_public_ int sd_network_get_domainname(int ifindex, char **domainname) { > > + _cleanup_free_ char *s = NULL, *p = NULL; > > + int r; > > + > > + assert_return(ifindex > 0, -EINVAL); > > + assert_return(domainname, -EINVAL); > > + > > + if (asprintf(&p, "/run/systemd/netif/links/%d", ifindex) < 0) > > + return -ENOMEM; > Not terribly important, but please spell that as: > > char p[sizeof("/run/systemd/netif/links/") + > DECIMAL_STRING_MAX(int)]; > snprintf(p, sizeof(p), "/run/systemd/netif/links/%d", > ifindex); Actually, I'd even use normal sprintf() here, not snprintf(), after all, we carefully sized the string anyway, hence no need to enforce the size limit here. In particular since snprintf() doesn't add a trailing NULL if it truncates the string, which makes the whole excercise kinda pointless... an snprintf() without something like char_array_0() invoked right after it always raises my eyebrows. Using sprintf() here makes is clear to me that the buffer was carefully sized before, so I think would be preferrable... Lennart -- Lennart Poettering, Red Hat _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel