mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
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:
@@ -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*
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user