fd-util: introduce FDNAME_MAX

This commit is contained in:
Yu Watanabe
2021-05-12 10:19:19 +09:00
parent 6001df6594
commit ae3f4bae68
2 changed files with 4 additions and 1 deletions
+1 -1
View File
@@ -454,7 +454,7 @@ bool fdname_is_valid(const char *s) {
return false;
}
return p - s < 256;
return p - s <= FDNAME_MAX;
}
int fd_get_path(int fd, char **ret) {
+3
View File
@@ -8,6 +8,9 @@
#include "macro.h"
/* maximum length of fdname */
#define FDNAME_MAX 255
/* Make sure we can distinguish fd 0 and NULL */
#define FD_TO_PTR(fd) INT_TO_PTR((fd)+1)
#define PTR_TO_FD(p) (PTR_TO_INT(p)-1)