Skip to content

Commit dbd0f2f

Browse files
Leontmauke
authored andcommitted
Avoid calling Perl_croak_nocontext from core
In core we almost always have a context, or we can easily get one.
1 parent 453b1c0 commit dbd0f2f

File tree

17 files changed

+53
-54
lines changed

17 files changed

+53
-54
lines changed

doop.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -906,8 +906,8 @@ Perl_do_vecset(pTHX_ SV *sv)
906906
if (errflags) {
907907
assert(!(errflags & ~(LVf_NEG_OFF|LVf_OUT_OF_RANGE)));
908908
if (errflags & LVf_NEG_OFF)
909-
Perl_croak_nocontext("Negative offset to vec in lvalue context");
910-
Perl_croak_nocontext("Out of memory during vec in lvalue context");
909+
croak("Negative offset to vec in lvalue context");
910+
croak("Out of memory during vec in lvalue context");
911911
}
912912

913913
if (!targ)
@@ -937,7 +937,7 @@ Perl_do_vecset(pTHX_ SV *sv)
937937
else if (size > 8) {
938938
int n = size/8;
939939
if (offset > Size_t_MAX / n - 1) /* would overflow */
940-
Perl_croak_nocontext("Out of memory during vec in lvalue context");
940+
croak("Out of memory during vec in lvalue context");
941941
offset *= n;
942942
}
943943

dump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2974,7 +2974,7 @@ Perl_runops_debug(pTHX)
29742974
#endif
29752975
#ifdef PERL_USE_HWM
29762976
if (PL_curstackinfo->si_stack_hwm < PL_stack_sp - PL_stack_base)
2977-
Perl_croak_nocontext(
2977+
croak(
29782978
"panic: previous op failed to extend arg stack: "
29792979
"base=%p, sp=%p, hwm=%p\n",
29802980
PL_stack_base, PL_stack_sp,

embed.fnc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2443,7 +2443,7 @@ Adp |OP * |op_prepend_elem|I32 optype \
24432443
Cdp |void |op_refcnt_lock
24442444
Cdp |void |op_refcnt_unlock
24452445
Adpx |OP * |op_scope |NULLOK OP *o
2446-
ATdp |OP * |op_sibling_splice \
2446+
Adp |OP * |op_sibling_splice \
24472447
|NULLOK OP *parent \
24482448
|NULLOK OP *start \
24492449
|int del_count \

embed.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@
505505
# define op_refcnt_lock() Perl_op_refcnt_lock(aTHX)
506506
# define op_refcnt_unlock() Perl_op_refcnt_unlock(aTHX)
507507
# define op_scope(a) Perl_op_scope(aTHX_ a)
508-
# define op_sibling_splice Perl_op_sibling_splice
508+
# define op_sibling_splice(a,b,c,d) Perl_op_sibling_splice(aTHX_ a,b,c,d)
509509
# define op_wrap_finally(a,b) Perl_op_wrap_finally(aTHX_ a,b)
510510
# define opdump_printf(a,...) Perl_opdump_printf(aTHX_ a,__VA_ARGS__)
511511
# define packlist(a,b,c,d,e) Perl_packlist(aTHX_ a,b,c,d,e)

hv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,7 +2072,7 @@ Perl_hv_clear(pTHX_ HV *hv)
20722072
if (HeVAL(entry)) {
20732073
if (SvREADONLY(HeVAL(entry))) {
20742074
SV* const keysv = hv_iterkeysv(entry);
2075-
Perl_croak_nocontext(
2075+
croak(
20762076
"Attempt to delete readonly key '%" SVf "' from a restricted hash",
20772077
(void*)keysv);
20782078
}
@@ -3410,7 +3410,7 @@ S_share_hek_flags(pTHX_ const char *str, STRLEN len, U32 hash, int flags)
34103410
assert(!(flags & HVhek_NOTSHARED));
34113411

34123412
if (UNLIKELY(len > (STRLEN) I32_MAX)) {
3413-
Perl_croak_nocontext("Sorry, hash keys must be smaller than 2**31 bytes");
3413+
croak("Sorry, hash keys must be smaller than 2**31 bytes");
34143414
}
34153415

34163416
/* what follows is the moral equivalent of:

locale.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7316,7 +7316,7 @@ S_emulate_langinfo(pTHX_ const PERL_INTMAX_T item,
73167316
* invalid. */;
73177317
# if defined(I_LANGINFO)
73187318

7319-
Perl_croak_nocontext("panic: Unexpected nl_langinfo() item %jd",
7319+
croak("panic: Unexpected nl_langinfo() item %jd",
73207320
item);
73217321

73227322
# else

op.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,7 +1590,7 @@ see C<L</OpMORESIB_set>>, C<L</OpLASTSIB_set>>, C<L</OpMAYBESIB_set>>.
15901590
*/
15911591

15921592
OP *
1593-
Perl_op_sibling_splice(OP *parent, OP *start, int del_count, OP* insert)
1593+
Perl_op_sibling_splice(pTHX_ OP *parent, OP *start, int del_count, OP* insert)
15941594
{
15951595
OP *first;
15961596
OP *rest;
@@ -1673,7 +1673,7 @@ Perl_op_sibling_splice(OP *parent, OP *start, int del_count, OP* insert)
16731673
return last_del ? first : NULL;
16741674

16751675
no_parent:
1676-
Perl_croak_nocontext("panic: op_sibling_splice(): NULL parent");
1676+
croak("panic: op_sibling_splice(): NULL parent");
16771677
}
16781678

16791679
/*
@@ -2788,7 +2788,7 @@ Perl_check_hash_fields_and_hekify(pTHX_ UNOP *rop, SVOP *key_op, int real)
27882788
SSize_t keylen;
27892789
const char * const key = SvPV_const(sv, *(STRLEN*)&keylen);
27902790
if (keylen > I32_MAX) {
2791-
Perl_croak_nocontext("Sorry, hash keys must be smaller than 2**31 bytes");
2791+
croak("Sorry, hash keys must be smaller than 2**31 bytes");
27922792
}
27932793

27942794
SV *nsv = newSVpvn_share(key, SvUTF8(sv) ? -(I32)keylen : (I32)keylen, 0);
@@ -11147,12 +11147,12 @@ Perl_newATTRSUB_x(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs,
1114711147
PL_compcv = 0;
1114811148
if (isBEGIN) {
1114911149
if (PL_in_eval & EVAL_KEEPERR)
11150-
Perl_croak_nocontext("BEGIN not safe after errors--compilation aborted");
11150+
croak("BEGIN not safe after errors--compilation aborted");
1115111151
else {
1115211152
SV * const errsv = ERRSV;
1115311153
/* force display of errors found but not reported */
1115411154
sv_catpvs(errsv, "BEGIN not safe after errors--compilation aborted");
11155-
Perl_croak_nocontext("%" SVf, SVfARG(errsv));
11155+
croak("%" SVf, SVfARG(errsv));
1115611156
}
1115711157
}
1115811158
goto done;

pad.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ Perl_cv_undef_flags(pTHX_ CV *cv, U32 flags)
332332
assert(SvTYPE(cv) == SVt_PVCV || SvTYPE(cv) == SVt_PVFM); /*unsafe is safe */
333333
if (CvDEPTHunsafe(&cvbody)) {
334334
assert(SvTYPE(cv) == SVt_PVCV);
335-
Perl_croak_nocontext("Can't undef active subroutine");
335+
croak("Can't undef active subroutine");
336336
}
337337
ENTER;
338338

perl.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2276,7 +2276,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
22762276
#if defined(SILENT_NO_TAINT_SUPPORT)
22772277
/* silently ignore */
22782278
#elif defined(NO_TAINT_SUPPORT)
2279-
Perl_croak_nocontext("This perl was compiled without taint support. "
2279+
croak("This perl was compiled without taint support. "
22802280
"Cowardly refusing to run with -t or -T flags");
22812281
#else
22822282
CHECK_MALLOC_TOO_LATE_FOR('t');
@@ -2291,7 +2291,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
22912291
#if defined(SILENT_NO_TAINT_SUPPORT)
22922292
/* silently ignore */
22932293
#elif defined(NO_TAINT_SUPPORT)
2294-
Perl_croak_nocontext("This perl was compiled without taint support. "
2294+
croak("This perl was compiled without taint support. "
22952295
"Cowardly refusing to run with -t or -T flags");
22962296
#else
22972297
CHECK_MALLOC_TOO_LATE_FOR('T');
@@ -2409,7 +2409,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
24092409
#if defined(SILENT_NO_TAINT_SUPPORT)
24102410
/* silently ignore */
24112411
#elif defined(NO_TAINT_SUPPORT)
2412-
Perl_croak_nocontext("This perl was compiled without taint support. "
2412+
croak("This perl was compiled without taint support. "
24132413
"Cowardly refusing to run with -t or -T flags");
24142414
#else
24152415
CHECK_MALLOC_TOO_LATE_FOR('T');
@@ -2448,7 +2448,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
24482448
#if defined(SILENT_NO_TAINT_SUPPORT)
24492449
/* silently ignore */
24502450
#elif defined(NO_TAINT_SUPPORT)
2451-
Perl_croak_nocontext("This perl was compiled without taint support. "
2451+
croak("This perl was compiled without taint support. "
24522452
"Cowardly refusing to run with -t or -T flags");
24532453
#else
24542454
if( !TAINTING_get) {
@@ -3910,7 +3910,7 @@ Perl_moreswitches(pTHX_ const char *s)
39103910
#if defined(SILENT_NO_TAINT_SUPPORT)
39113911
/* silently ignore */
39123912
#elif defined(NO_TAINT_SUPPORT)
3913-
Perl_croak_nocontext("This perl was compiled without taint support. "
3913+
croak("This perl was compiled without taint support. "
39143914
"Cowardly refusing to run with -t or -T flags");
39153915
#else
39163916
if (!TAINTING_get)
@@ -4088,7 +4088,7 @@ Perl_my_unexec(pTHX)
40884088
# ifdef VMS
40894089
lib$signal(SS$_DEBUG); /* ssdef.h #included from vmsish.h */
40904090
# elif defined(WIN32) || defined(__CYGWIN__)
4091-
Perl_croak_nocontext("dump is not supported");
4091+
croak("dump is not supported");
40924092
# else
40934093
ABORT(); /* for use with undump */
40944094
# endif
@@ -4329,7 +4329,7 @@ S_validate_suid(pTHX_ PerlIO *rsfp)
43294329
int fd = PerlIO_fileno(rsfp);
43304330
Stat_t statbuf;
43314331
if (fd < 0 || PerlLIO_fstat(fd, &statbuf) < 0) { /* may be either wrapped or real suid */
4332-
Perl_croak_nocontext( "Illegal suidscript");
4332+
croak( "Illegal suidscript");
43334333
}
43344334
if ((my_euid != my_uid && my_euid == statbuf.st_uid && statbuf.st_mode & S_ISUID)
43354335
||

perlio.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2747,28 +2747,27 @@ PerlIOUnix_refcnt_inc(int fd)
27472747
int
27482748
PerlIOUnix_refcnt_dec(int fd)
27492749
{
2750+
dTHX;
27502751
int cnt = 0;
27512752
if (fd >= 0) {
2752-
#ifdef DEBUGGING
2753-
dTHX;
2754-
#endif
2753+
27552754
MUTEX_LOCK(&PL_perlio_mutex);
27562755
if (fd >= PL_perlio_fd_refcnt_size) {
27572756
/* diag_listed_as: refcnt_dec: fd %d%s */
2758-
Perl_croak_nocontext("refcnt_dec: fd %d >= refcnt_size %d\n",
2757+
croak("refcnt_dec: fd %d >= refcnt_size %d\n",
27592758
fd, PL_perlio_fd_refcnt_size);
27602759
}
27612760
if (PL_perlio_fd_refcnt[fd] <= 0) {
27622761
/* diag_listed_as: refcnt_dec: fd %d%s */
2763-
Perl_croak_nocontext("refcnt_dec: fd %d: %d <= 0\n",
2762+
croak("refcnt_dec: fd %d: %d <= 0\n",
27642763
fd, PL_perlio_fd_refcnt[fd]);
27652764
}
27662765
cnt = --PL_perlio_fd_refcnt[fd];
27672766
DEBUG_i( PerlIO_debug("refcnt_dec: fd %d refcnt=%d\n", fd, cnt) );
27682767
MUTEX_UNLOCK(&PL_perlio_mutex);
27692768
} else {
27702769
/* diag_listed_as: refcnt_dec: fd %d%s */
2771-
Perl_croak_nocontext("refcnt_dec: fd %d < 0\n", fd);
2770+
croak("refcnt_dec: fd %d < 0\n", fd);
27722771
}
27732772
return cnt;
27742773
}
@@ -5289,8 +5288,8 @@ Perl_PerlIO_stderr(pTHX)
52895288
char *
52905289
PerlIO_getname(PerlIO *f, char *buf)
52915290
{
5292-
#ifdef VMS
52935291
dTHX;
5292+
#ifdef VMS
52945293
char *name = NULL;
52955294
bool exported = FALSE;
52965295
FILE *stdio = PerlIOSelf(f, PerlIOStdio)->stdio;
@@ -5306,7 +5305,7 @@ PerlIO_getname(PerlIO *f, char *buf)
53065305
#else
53075306
PERL_UNUSED_ARG(f);
53085307
PERL_UNUSED_ARG(buf);
5309-
Perl_croak_nocontext("Don't know how to get file name");
5308+
croak("Don't know how to get file name");
53105309
return NULL;
53115310
#endif
53125311
}

0 commit comments

Comments
 (0)