mruby-io: use mrb_int for mrb_hal_io_readlink() return type

int64_t was unnecessary; readlink(2) returns ssize_t (bounded by
PATH_MAX), and the Windows HAL just raises NotImplementedError.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2026-03-24 13:57:45 +09:00
parent 7ae73ac7e4
commit b70c393039
4 changed files with 5 additions and 8 deletions
+2 -5
View File
@@ -200,14 +200,11 @@ mrb_hal_io_symlink(mrb_state *mrb, const char *target, const char *linkpath)
return symlink(target, linkpath);
}
int64_t
mrb_int
mrb_hal_io_readlink(mrb_state *mrb, const char *path, char *buf, size_t bufsize)
{
ssize_t rc;
(void)mrb;
rc = readlink(path, buf, bufsize);
return (int64_t)rc;
return (mrb_int)readlink(path, buf, bufsize);
}
char*
+1 -1
View File
@@ -207,7 +207,7 @@ mrb_hal_io_symlink(mrb_state *mrb, const char *target, const char *linkpath)
return -1; /* not reached */
}
int64_t
mrb_int
mrb_hal_io_readlink(mrb_state *mrb, const char *path, char *buf, size_t bufsize)
{
(void)path;
+1 -1
View File
@@ -189,7 +189,7 @@ int mrb_hal_io_symlink(mrb_state *mrb, const char *target, const char *linkpath)
* @param bufsize Buffer size
* @return Number of bytes placed in buf, -1 on error (sets errno)
*/
int64_t mrb_hal_io_readlink(mrb_state *mrb, const char *path, char *buf, size_t bufsize);
mrb_int mrb_hal_io_readlink(mrb_state *mrb, const char *path, char *buf, size_t bufsize);
/**
* Resolve pathname to absolute path
+1 -1
View File
@@ -900,7 +900,7 @@ mrb_file_s_readlink(mrb_state *mrb, mrb_value klass)
/* Use mrb_temp_alloc for exception safety - GC will clean up on exception */
char *buf = (char*)mrb_temp_alloc(mrb, PATH_MAX);
int64_t rc = mrb_hal_io_readlink(mrb, tmp, buf, PATH_MAX);
mrb_int rc = mrb_hal_io_readlink(mrb, tmp, buf, PATH_MAX);
mrb_locale_free(tmp);
if (rc == -1) {
mrb_sys_fail(mrb, path);