* 4byte name length
* 4byte name
* plus the dirlist structure */
- if (count < (2 * (2 * (sizeof(*ep) + sizeof("..") + 4) + sizeof(*dp))))
+#define NEEDROOM (2 * (2 * (sizeof(*ep) + sizeof("..") + 4) + sizeof(*dp)))
+ if (count < NEEDROOM) {
+ dlog("%s: not enough room %u < %zu", __func__, count, NEEDROOM);
return EINVAL;
+ }
xp = next_nonerror_node(mp->am_child);
dp->dl_entries = ep;
* 8byte next entry addres) = sizeof(*ep)
* 2byte name + 1byte terminator
* plus the dirlist structure */
- if (count < ((2 * ((sizeof(*ep) + sizeof("..") + 1))) + sizeof(*dp)));
+#define NEEDROOM3 ((2 * ((sizeof(*ep) + sizeof("..") + 1))) + sizeof(*dp))
+ if (count < NEEDROOM3) {
+ dlog("%s: not enough room %u < %zu", __func__, count, NEEDROOM3);
return EINVAL;
+ }
xp = next_nonerror_node(mp->am_child);
dp->entries = ep;