mirror of
https://github.com/ruby/ruby.git
synced 2026-10-28 08:25:20 +08:00
Use rb_len_t for lengths in process.c and signal.c
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
224dc5c110
commit
803c68f0da
2 files changed
+26
-26
Notes:
git
2026-10-09 05:02:04 +00:00
No files matched your search
@@ -2161,7 +2161,7 @@ check_exec_options_i_extract(st_data_t st_key, st_data_t st_val, st_data_t arg)
|
||||
static int
|
||||
check_exec_fds_1(struct rb_execarg *eargp, VALUE h, int maxhint, VALUE ary)
|
||||
{
|
||||
long i;
|
||||
rb_len_t i;
|
||||
|
||||
if (ary != Qfalse) {
|
||||
for (i = 0; i < RARRAY_LEN(ary); i++) {
|
||||
@@ -2194,7 +2194,7 @@ check_exec_fds(struct rb_execarg *eargp)
|
||||
VALUE h = rb_hash_new();
|
||||
VALUE ary;
|
||||
int maxhint = -1;
|
||||
long i;
|
||||
rb_len_t i;
|
||||
|
||||
maxhint = check_exec_fds_1(eargp, h, maxhint, eargp->fd_dup2);
|
||||
maxhint = check_exec_fds_1(eargp, h, maxhint, eargp->fd_close);
|
||||
@@ -2646,7 +2646,7 @@ fill_envp_buf_i(st_data_t st_key, st_data_t st_val, st_data_t arg)
|
||||
}
|
||||
|
||||
|
||||
static long run_exec_dup2_tmpbuf_size(long n);
|
||||
static rb_len_t run_exec_dup2_tmpbuf_size(rb_len_t n);
|
||||
|
||||
struct open_struct {
|
||||
VALUE fname;
|
||||
@@ -2667,7 +2667,7 @@ open_func(void *ptr)
|
||||
}
|
||||
|
||||
static void
|
||||
rb_execarg_allocate_dup2_tmpbuf(struct rb_execarg *eargp, long len)
|
||||
rb_execarg_allocate_dup2_tmpbuf(struct rb_execarg *eargp, rb_len_t len)
|
||||
{
|
||||
rb_alloc_tmp_buffer(&eargp->dup2_tmpbuf, run_exec_dup2_tmpbuf_size(len), false);
|
||||
}
|
||||
@@ -2682,7 +2682,7 @@ rb_execarg_parent_start1(VALUE execarg_obj)
|
||||
|
||||
ary = eargp->fd_open;
|
||||
if (ary != Qfalse) {
|
||||
long i;
|
||||
rb_len_t i;
|
||||
for (i = 0; i < RARRAY_LEN(ary); i++) {
|
||||
VALUE elt = RARRAY_AREF(ary, i);
|
||||
int fd = FIX2INT(RARRAY_AREF(elt, 0));
|
||||
@@ -2740,7 +2740,7 @@ rb_execarg_parent_start1(VALUE execarg_obj)
|
||||
}
|
||||
hide_obj(envtbl);
|
||||
if (envopts != Qfalse) {
|
||||
long i;
|
||||
rb_len_t i;
|
||||
for (i = 0; i < RARRAY_LEN(envopts); i++) {
|
||||
VALUE pair = RARRAY_AREF(envopts, i);
|
||||
VALUE key = RARRAY_AREF(pair, 0);
|
||||
@@ -2803,7 +2803,7 @@ execarg_parent_end(VALUE execarg_obj)
|
||||
|
||||
ary = eargp->fd_open;
|
||||
if (ary != Qfalse) {
|
||||
long i;
|
||||
rb_len_t i;
|
||||
for (i = 0; i < RARRAY_LEN(ary); i++) {
|
||||
VALUE elt = RARRAY_AREF(ary, i);
|
||||
VALUE param = RARRAY_AREF(elt, 1);
|
||||
@@ -3039,13 +3039,13 @@ intrcmp(const void *a, const void *b)
|
||||
struct run_exec_dup2_fd_pair {
|
||||
int oldfd;
|
||||
int newfd;
|
||||
long older_index;
|
||||
long num_newer;
|
||||
rb_len_t older_index;
|
||||
rb_len_t num_newer;
|
||||
int cloexec;
|
||||
};
|
||||
|
||||
static long
|
||||
run_exec_dup2_tmpbuf_size(long n)
|
||||
static rb_len_t
|
||||
run_exec_dup2_tmpbuf_size(rb_len_t n)
|
||||
{
|
||||
return sizeof(struct run_exec_dup2_fd_pair) * n;
|
||||
}
|
||||
@@ -3116,7 +3116,7 @@ fd_clear_cloexec(int fd, char *errmsg, size_t errmsg_buflen)
|
||||
static int
|
||||
run_exec_dup2(VALUE ary, VALUE tmpbuf, struct rb_execarg *sargp, char *errmsg, size_t errmsg_buflen)
|
||||
{
|
||||
long n, i;
|
||||
rb_len_t n, i;
|
||||
int ret;
|
||||
int extra_fd = -1;
|
||||
struct run_exec_dup2_fd_pair *pairs = RB_IMEMO_TMPBUF_PTR(tmpbuf);
|
||||
@@ -3158,7 +3158,7 @@ run_exec_dup2(VALUE ary, VALUE tmpbuf, struct rb_execarg *sargp, char *errmsg, s
|
||||
|
||||
/* non-cyclic redirection: O(n) */
|
||||
for (i = 0; i < n; i++) {
|
||||
long j = i;
|
||||
rb_len_t j = i;
|
||||
while (j != -1 && pairs[j].oldfd != -1 && pairs[j].num_newer == 0) {
|
||||
if (save_redirect_fd(pairs[j].newfd, sargp, errmsg, errmsg_buflen) < 0) /* async-signal-safe */
|
||||
goto fail;
|
||||
@@ -3181,7 +3181,7 @@ run_exec_dup2(VALUE ary, VALUE tmpbuf, struct rb_execarg *sargp, char *errmsg, s
|
||||
|
||||
/* cyclic redirection: O(n) */
|
||||
for (i = 0; i < n; i++) {
|
||||
long j;
|
||||
rb_len_t j;
|
||||
if (pairs[i].oldfd == -1)
|
||||
continue;
|
||||
if (pairs[i].oldfd == pairs[i].newfd) { /* self cycle */
|
||||
@@ -3246,7 +3246,7 @@ run_exec_dup2(VALUE ary, VALUE tmpbuf, struct rb_execarg *sargp, char *errmsg, s
|
||||
static int
|
||||
run_exec_close(VALUE ary, char *errmsg, size_t errmsg_buflen)
|
||||
{
|
||||
long i;
|
||||
rb_len_t i;
|
||||
int ret;
|
||||
|
||||
for (i = 0; i < RARRAY_LEN(ary); i++) {
|
||||
@@ -3265,7 +3265,7 @@ run_exec_close(VALUE ary, char *errmsg, size_t errmsg_buflen)
|
||||
static int
|
||||
run_exec_dup2_child(VALUE ary, struct rb_execarg *sargp, char *errmsg, size_t errmsg_buflen)
|
||||
{
|
||||
long i;
|
||||
rb_len_t i;
|
||||
int ret;
|
||||
|
||||
for (i = 0; i < RARRAY_LEN(ary); i++) {
|
||||
@@ -3324,7 +3324,7 @@ run_exec_pgroup(const struct rb_execarg *eargp, struct rb_execarg *sargp, char *
|
||||
static int
|
||||
run_exec_rlimit(VALUE ary, struct rb_execarg *sargp, char *errmsg, size_t errmsg_buflen)
|
||||
{
|
||||
long i;
|
||||
rb_len_t i;
|
||||
for (i = 0; i < RARRAY_LEN(ary); i++) {
|
||||
VALUE elt = RARRAY_AREF(ary, i);
|
||||
int rtype = NUM2INT(RARRAY_AREF(elt, 0));
|
||||
@@ -3422,7 +3422,7 @@ rb_execarg_run_options(const struct rb_execarg *eargp, struct rb_execarg *sargp,
|
||||
|
||||
obj = eargp->env_modification;
|
||||
if (obj != Qfalse) {
|
||||
long i;
|
||||
rb_len_t i;
|
||||
save_env(sargp);
|
||||
for (i = 0; i < RARRAY_LEN(obj); i++) {
|
||||
VALUE pair = RARRAY_AREF(obj, i);
|
||||
@@ -5215,7 +5215,7 @@ proc_setpriority(VALUE obj, VALUE which, VALUE who, VALUE prio)
|
||||
|
||||
#if defined(HAVE_SETRLIMIT) && defined(NUM2RLIM)
|
||||
static int
|
||||
rlimit_resource_name2int(const char *name, long len, int casetype)
|
||||
rlimit_resource_name2int(const char *name, rb_len_t len, int casetype)
|
||||
{
|
||||
int resource;
|
||||
const char *p;
|
||||
@@ -5327,13 +5327,13 @@ rlimit_resource_name2int(const char *name, long len, int casetype)
|
||||
}
|
||||
|
||||
static int
|
||||
rlimit_type_by_hname(const char *name, long len)
|
||||
rlimit_type_by_hname(const char *name, rb_len_t len)
|
||||
{
|
||||
return rlimit_resource_name2int(name, len, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
rlimit_type_by_lname(const char *name, long len)
|
||||
rlimit_type_by_lname(const char *name, rb_len_t len)
|
||||
{
|
||||
return rlimit_resource_name2int(name, len, 1);
|
||||
}
|
||||
@@ -5343,7 +5343,7 @@ rlimit_type_by_sym(VALUE key)
|
||||
{
|
||||
VALUE name = rb_sym2str(key);
|
||||
const char *rname = RSTRING_PTR(name);
|
||||
long len = RSTRING_LEN(name);
|
||||
rb_len_t len = RSTRING_LEN(name);
|
||||
int rtype = -1;
|
||||
static const char prefix[] = "rlimit_";
|
||||
enum {prefix_len = sizeof(prefix)-1};
|
||||
@@ -5360,7 +5360,7 @@ static int
|
||||
rlimit_resource_type(VALUE rtype)
|
||||
{
|
||||
const char *name;
|
||||
long len;
|
||||
rb_len_t len;
|
||||
VALUE v;
|
||||
int r;
|
||||
|
||||
|
||||
@@ -212,7 +212,7 @@ signm2signo(VALUE *sig_ptr, int negative, int exit, int *prefix_ptr)
|
||||
const struct signals *sigs;
|
||||
VALUE vsig = *sig_ptr;
|
||||
const char *nm;
|
||||
long len, nmlen;
|
||||
rb_len_t len, nmlen;
|
||||
int prefix = 0;
|
||||
|
||||
if (RB_SYMBOL_P(vsig)) {
|
||||
@@ -245,7 +245,7 @@ signm2signo(VALUE *sig_ptr, int negative, int exit, int *prefix_ptr)
|
||||
if (memcmp(nm + prefix, signame_prefix, signame_prefix_len) == 0)
|
||||
prefix += signame_prefix_len;
|
||||
}
|
||||
if (len <= (long)prefix) {
|
||||
if (len <= (rb_len_t)prefix) {
|
||||
goto unsupported;
|
||||
}
|
||||
|
||||
@@ -1248,7 +1248,7 @@ trap_handler(VALUE *cmd, int sig)
|
||||
}
|
||||
if (!NIL_P(command)) {
|
||||
const char *cptr;
|
||||
long len;
|
||||
rb_len_t len;
|
||||
StringValue(command);
|
||||
*cmd = command;
|
||||
RSTRING_GETMEM(command, cptr, len);
|
||||
|
||||
Reference in new issue
Block a user