The maximum allowed path is defined by PATH_MAX and *includes* the final zero byte. The size value passed to snprintf also includes the final zero byte. Therefore the arrays should be of size PATH_MAX and not PATH_MAX + 1.
To make GCC 7 & 8 happy, check the return value of the snprintf function and bail out with an error message. In practice this just improve a tiny bit the user experience, as the truncated path would just not be found by open or opendir.