From: Jarkko Hietaniemi Date: Tue, 10 Aug 1999 09:06:42 +0000 (+0000) Subject: Gratuitous uid and gid casts to I32s and ints removed. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d8eceb896c98708a63dcc63f7bf202b095342359;p=p5sagit%2Fp5-mst-13.2.git Gratuitous uid and gid casts to I32s and ints removed. There are still problem spots in printfing such ids: width (%d vs %ld) and signedness %d vs %u. p4raw-id: //depot/cfgperl@3945 --- diff --git a/doio.c b/doio.c index f13d09f..7620e3a 100644 --- a/doio.c +++ b/doio.c @@ -1488,7 +1488,8 @@ nothing in the core. /* Do the permissions allow some operation? Assumes statcache already set. */ #ifndef VMS /* VMS' cando is in vms.c */ I32 -Perl_cando(pTHX_ I32 bit, I32 effective, register struct stat *statbufp) +Perl_cando(pTHX_ I32 bit, Uid_t effective, register struct stat *statbufp) +/* Note: we use `effective' both for uids and gids. */ { #ifdef DOSISH /* [Comments and code from Len Reed] @@ -1528,7 +1529,7 @@ Perl_cando(pTHX_ I32 bit, I32 effective, register struct stat *statbufp) if (statbufp->st_mode & bit) return TRUE; /* ok as "user" */ } - else if (ingroup((I32)statbufp->st_gid,effective)) { + else if (ingroup(statbufp->st_gid,effective)) { if (statbufp->st_mode & bit >> 3) return TRUE; /* ok as "group" */ } @@ -1539,8 +1540,8 @@ Perl_cando(pTHX_ I32 bit, I32 effective, register struct stat *statbufp) } #endif /* ! VMS */ -I32 -Perl_ingroup(pTHX_ I32 testgid, I32 effective) +bool +Perl_ingroup(pTHX_ Gid_t testgid, Uid_t effective) { if (testgid == (effective ? PL_egid : PL_gid)) return TRUE; diff --git a/embed.pl b/embed.pl index 09df177..ff4ad5c 100755 --- a/embed.pl +++ b/embed.pl @@ -1051,7 +1051,7 @@ p |I32 |block_gimme p |int |block_start |int full p |void |boot_core_UNIVERSAL p |void |call_list |I32 oldscope|AV* av_list -p |I32 |cando |I32 bit|I32 effective|Stat_t* statbufp +p |I32 |cando |I32 bit|Uid_t effective|Stat_t* statbufp p |U32 |cast_ulong |NV f p |I32 |cast_i32 |NV f p |IV |cast_iv |NV f @@ -1222,7 +1222,7 @@ p |HE* |hv_store_ent |HV* tb|SV* key|SV* val|U32 hash p |void |hv_undef |HV* tb p |I32 |ibcmp |const char* a|const char* b|I32 len p |I32 |ibcmp_locale |const char* a|const char* b|I32 len -p |I32 |ingroup |I32 testgid|I32 effective +p |bool |ingroup |Gid_t testgid|Uid_t effective p |void |init_debugger p |void |init_stacks p |U32 |intro_my diff --git a/intrpvar.h b/intrpvar.h index 65ab5c6..a291d39 100644 --- a/intrpvar.h +++ b/intrpvar.h @@ -200,10 +200,10 @@ PERLVARI(Ithreadnum, U32, 0) /* incremented each thread creation */ PERLVAR(Istrtab_mutex, perl_mutex) /* Mutex for string table access */ #endif /* USE_THREADS */ -PERLVAR(Iuid, int) /* current real user id */ -PERLVAR(Ieuid, int) /* current effective user id */ -PERLVAR(Igid, int) /* current real group id */ -PERLVAR(Iegid, int) /* current effective group id */ +PERLVAR(Iuid, Uid_t) /* current real user id */ +PERLVAR(Ieuid, Uid_t) /* current effective user id */ +PERLVAR(Igid, Gid_t) /* current real group id */ +PERLVAR(Iegid, Gid_t) /* current effective group id */ PERLVAR(Inomemok, bool) /* let malloc context handle nomem */ PERLVAR(Ian, U32) /* malloc sequence number */ PERLVAR(Icop_seqmax, U32) /* statement sequence number */ diff --git a/mg.c b/mg.c index 19479db..6418b27 100644 --- a/mg.c +++ b/mg.c @@ -1813,13 +1813,13 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) if (PL_uid == PL_euid) /* special case $< = $> */ (void)PerlProc_setuid(PL_uid); else { - PL_uid = (I32)PerlProc_getuid(); + PL_uid = PerlProc_getuid(); Perl_croak(aTHX_ "setruid() not implemented"); } #endif #endif #endif - PL_uid = (I32)PerlProc_getuid(); + PL_uid = PerlProc_getuid(); PL_tainting |= (PL_uid && (PL_euid != PL_uid || PL_egid != PL_gid)); break; case '>': @@ -1840,13 +1840,13 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) if (PL_euid == PL_uid) /* special case $> = $< */ PerlProc_setuid(PL_euid); else { - PL_euid = (I32)PerlProc_geteuid(); + PL_euid = rlProc_geteuid(); Perl_croak(aTHX_ "seteuid() not implemented"); } #endif #endif #endif - PL_euid = (I32)PerlProc_geteuid(); + PL_euid = PerlProc_geteuid(); PL_tainting |= (PL_uid && (PL_euid != PL_uid || PL_egid != PL_gid)); break; case '(': @@ -1867,13 +1867,13 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) if (PL_gid == PL_egid) /* special case $( = $) */ (void)PerlProc_setgid(PL_gid); else { - PL_gid = (I32)PerlProc_getgid(); + PL_gid = PerlProc_getgid(); Perl_croak(aTHX_ "setrgid() not implemented"); } #endif #endif #endif - PL_gid = (I32)PerlProc_getgid(); + PL_gid = PerlProc_getgid(); PL_tainting |= (PL_uid && (PL_euid != PL_uid || PL_egid != PL_gid)); break; case ')': @@ -1916,13 +1916,13 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) if (PL_egid == PL_gid) /* special case $) = $( */ (void)PerlProc_setgid(PL_egid); else { - PL_egid = (I32)PerlProc_getegid(); + PL_egid = PerlProc_getegid(); Perl_croak(aTHX_ "setegid() not implemented"); } #endif #endif #endif - PL_egid = (I32)PerlProc_getegid(); + PL_egid = PerlProc_getegid(); PL_tainting |= (PL_uid && (PL_euid != PL_uid || PL_egid != PL_gid)); break; case ':': diff --git a/perl.c b/perl.c index d811879..9de8755 100644 --- a/perl.c +++ b/perl.c @@ -2459,10 +2459,10 @@ S_find_beginning(pTHX) STATIC void S_init_ids(pTHX) { - PL_uid = (int)PerlProc_getuid(); - PL_euid = (int)PerlProc_geteuid(); - PL_gid = (int)PerlProc_getgid(); - PL_egid = (int)PerlProc_getegid(); + PL_uid = PerlProc_getuid(); + PL_euid = PerlProc_geteuid(); + PL_gid = PerlProc_getgid(); + PL_egid = PerlProc_getegid(); #ifdef VMS PL_uid |= PL_gid << 16; PL_euid |= PL_egid << 16; diff --git a/perlapi.c b/perlapi.c index d0c7f33..4875caa 100755 --- a/perlapi.c +++ b/perlapi.c @@ -254,7 +254,7 @@ Perl_call_list(pTHXo_ I32 oldscope, AV* av_list) #undef Perl_cando I32 -Perl_cando(pTHXo_ I32 bit, I32 effective, Stat_t* statbufp) +Perl_cando(pTHXo_ I32 bit, Uid_t effective, Stat_t* statbufp) { return ((CPerlObj*)pPerl)->Perl_cando(bit, effective, statbufp); } @@ -1343,8 +1343,8 @@ Perl_ibcmp_locale(pTHXo_ const char* a, const char* b, I32 len) } #undef Perl_ingroup -I32 -Perl_ingroup(pTHXo_ I32 testgid, I32 effective) +bool +Perl_ingroup(pTHXo_ Gid_t testgid, Uid_t effective) { return ((CPerlObj*)pPerl)->Perl_ingroup(testgid, effective); } diff --git a/pp_hot.c b/pp_hot.c index 38658d1..78f07a1 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -767,8 +767,8 @@ PP(pp_aassign) } # endif /* HAS_SETREUID */ #endif /* HAS_SETRESUID */ - PL_uid = (int)PerlProc_getuid(); - PL_euid = (int)PerlProc_geteuid(); + PL_uid = PerlProc_getuid(); + PL_euid = PerlProc_geteuid(); } if (PL_delaymagic & DM_GID) { #ifdef HAS_SETRESGID @@ -796,8 +796,8 @@ PP(pp_aassign) } # endif /* HAS_SETREGID */ #endif /* HAS_SETRESGID */ - PL_gid = (int)PerlProc_getgid(); - PL_egid = (int)PerlProc_getegid(); + PL_gid = PerlProc_getgid(); + PL_egid = PerlProc_getegid(); } PL_tainting |= (PL_uid && (PL_euid != PL_uid || PL_egid != PL_gid)); } diff --git a/proto.h b/proto.h index bdb0ea0..f809677 100644 --- a/proto.h +++ b/proto.h @@ -37,7 +37,7 @@ VIRTUAL I32 Perl_block_gimme(pTHX); VIRTUAL int Perl_block_start(pTHX_ int full); VIRTUAL void Perl_boot_core_UNIVERSAL(pTHX); VIRTUAL void Perl_call_list(pTHX_ I32 oldscope, AV* av_list); -VIRTUAL I32 Perl_cando(pTHX_ I32 bit, I32 effective, Stat_t* statbufp); +VIRTUAL I32 Perl_cando(pTHX_ I32 bit, Uid_t effective, Stat_t* statbufp); VIRTUAL U32 Perl_cast_ulong(pTHX_ NV f); VIRTUAL I32 Perl_cast_i32(pTHX_ NV f); VIRTUAL IV Perl_cast_iv(pTHX_ NV f); @@ -197,7 +197,7 @@ VIRTUAL HE* Perl_hv_store_ent(pTHX_ HV* tb, SV* key, SV* val, U32 hash); VIRTUAL void Perl_hv_undef(pTHX_ HV* tb); VIRTUAL I32 Perl_ibcmp(pTHX_ const char* a, const char* b, I32 len); VIRTUAL I32 Perl_ibcmp_locale(pTHX_ const char* a, const char* b, I32 len); -VIRTUAL I32 Perl_ingroup(pTHX_ I32 testgid, I32 effective); +VIRTUAL bool Perl_ingroup(pTHX_ Gid_t testgid, Uid_t effective); VIRTUAL void Perl_init_debugger(pTHX); VIRTUAL void Perl_init_stacks(pTHX); VIRTUAL U32 Perl_intro_my(pTHX); @@ -855,7 +855,6 @@ STATIC regnode* S_reg(pTHX_ I32, I32 *); STATIC regnode* S_reganode(pTHX_ U8, U32); STATIC regnode* S_regatom(pTHX_ I32 *); STATIC regnode* S_regbranch(pTHX_ I32 *, I32); -STATIC void S_regc(pTHX_ U8, char *); STATIC void S_reguni(pTHX_ UV, char *, I32*); STATIC regnode* S_regclass(pTHX); STATIC regnode* S_regclassutf8(pTHX);