Am 02.02.2016 um 20:29 hat Eric Blake geschrieben: > On 02/02/2016 10:28 AM, Programmingkid wrote: > > >> Whats the rationale here ? Using pre-allocated fixed > >> length arrays is pretty bad practice in general, but > >> especially so for filenames > > > > With an automatic variable there is no worry about when to release it. > > Yeah, but it comes with the downside of having to worry about exhausting > stack space (there are platforms where MAXPATHLEN is intentionally > undefined [hello, GNU Hurd]), or with the downside of arbitrary > limitations. And at the same time, MAXPATHLEN is usually wasteful - > allocating 1k or 4k of stack to store what is typically less than 100 > bytes is dumb. Really, storing file names in fixed length arrays is > better off to avoid, and just get used to dynamic management.
Just let me add that while it's probably harmless here in .bdrv_open(), other paths in the block layer which run in a coroutine have a much more limited stack size and the danger of stack overflows is very real there. Kevin