On Mon, Dec 18, 2017 at 09:23:41PM +0100, Adrien Mazarguil wrote: > On Mon, Dec 18, 2017 at 10:34:12AM -0800, Stephen Hemminger wrote: > > On Mon, 18 Dec 2017 17:46:23 +0100 > > Adrien Mazarguil <adrien.mazarg...@6wind.com> wrote: > > <snip> > > > +static int > > > +hyperv_iface_is_netvsc(const struct if_nameindex *iface) > > > +{ > > > + static const char temp[] = "/sys/class/net/%s/device/class_id"; > > > + char path[snprintf(NULL, 0, temp, iface->if_name) + 1]; > > > > Doing this snprintf is gross. Either use PATH_MAX or asprintf > > I don't think allocating more stack space than necessary or on the heap with > a possible allocation failure to deal with is any better, sorry. > > Prove this snprintf() call can fail and you'll have a point. > While I get your point, I'd tend to go with Stephen's view on this that it's looking a bit "gross". What's the problem with allocating a bit more stack space for it?
/Bruce