Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ck_warner() more #23137

Merged
merged 1 commit into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions amigaos4/amigaio.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,8 @@ static void S_exec_failed(pTHX_ const char *cmd, int fd, int do_report)
// PERL_ARGS_ASSERT_EXEC_FAILED;
if (e)
{
if (ckWARN(WARN_EXEC))
warner(packWARN(WARN_EXEC),
"Can't exec \"%s\": %s", cmd, Strerror(e));
ck_warner(packWARN(WARN_EXEC),
"Can't exec \"%s\": %s", cmd, Strerror(e));
}
if (do_report)
{
Expand Down
5 changes: 2 additions & 3 deletions cygwin/cygwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ do_spawnvp (const char *path, const char * const *argv)
childpid = spawnvp(_P_NOWAIT,path,argv);
if (childpid < 0) {
status = -1;
if(ckWARN(WARN_EXEC))
warner(packWARN(WARN_EXEC),"Can't spawn \"%s\": %s",
path, Strerror(errno));
ck_warner(packWARN(WARN_EXEC), "Can't spawn \"%s\": %s",
path, Strerror(errno));
} else {
do {
result = wait4pid(childpid, &status, 0);
Expand Down
33 changes: 13 additions & 20 deletions doio.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,7 @@ Perl_do_open6(pTHX_ GV *gv, const char *oname, STRLEN len,
/* New style explicit name, type is just mode and layer info */
#ifdef USE_STDIO
if (SvROK(*svp) && !memchr(oname, '&', len)) {
if (ckWARN(WARN_IO))
warner(packWARN(WARN_IO), "Can't open a reference");
ck_warner(packWARN(WARN_IO), "Can't open a reference");
SETERRNO(EINVAL, LIB_INVARG);
fp = NULL;
goto say_false;
Expand Down Expand Up @@ -683,8 +682,7 @@ Perl_do_open6(pTHX_ GV *gv, const char *oname, STRLEN len,
}
if (*name == '\0') {
/* command is missing 19990114 */
if (ckWARN(WARN_PIPE))
warner(packWARN(WARN_PIPE), "Missing command in piped open");
ck_warner(packWARN(WARN_PIPE), "Missing command in piped open");
errno = EPIPE;
fp = NULL;
goto say_false;
Expand All @@ -694,8 +692,7 @@ Perl_do_open6(pTHX_ GV *gv, const char *oname, STRLEN len,
TAINT_PROPER("piped open");
if (!num_svs && name[len-1] == '|') {
name[--len] = '\0' ;
if (ckWARN(WARN_PIPE))
warner(packWARN(WARN_PIPE), "Can't open bidirectional pipe");
ck_warner(packWARN(WARN_PIPE), "Can't open bidirectional pipe");
}
mode[0] = 'w';
writing = 1;
Expand Down Expand Up @@ -917,8 +914,7 @@ Perl_do_open6(pTHX_ GV *gv, const char *oname, STRLEN len,
}
if (*name == '\0') {
/* command is missing 19990114 */
if (ckWARN(WARN_PIPE))
warner(packWARN(WARN_PIPE), "Missing command in piped open");
ck_warner(packWARN(WARN_PIPE), "Missing command in piped open");
errno = EPIPE;
fp = NULL;
goto say_false;
Expand Down Expand Up @@ -2359,12 +2355,10 @@ Perl_my_lstat_flags(pTHX_ const U32 flags)
return PL_laststatval;
}
PL_laststatval = -1;
if (ckWARN(WARN_IO)) {
/* diag_listed_as: Use of -l on filehandle%s */
warner(packWARN(WARN_IO),
"Use of -l on filehandle %" HEKf,
HEKfARG(GvENAME_HEK(cGVOP_gv)));
}
/* diag_listed_as: Use of -l on filehandle%s */
ck_warner(packWARN(WARN_IO),
"Use of -l on filehandle %" HEKf,
HEKfARG(GvENAME_HEK(cGVOP_gv)));
SETERRNO(EBADF,RMS_IFI);
return -1;
}
Expand Down Expand Up @@ -2416,9 +2410,8 @@ S_exec_failed(pTHX_ const char *cmd, int fd, int do_report)
const int e = errno;
PERL_ARGS_ASSERT_EXEC_FAILED;

if (ckWARN(WARN_EXEC))
warner(packWARN(WARN_EXEC), "Can't exec \"%s\": %s",
cmd, Strerror(e));
ck_warner(packWARN(WARN_EXEC), "Can't exec \"%s\": %s",
cmd, Strerror(e));
if (do_report) {
/* XXX silently ignore failures */
PERL_UNUSED_RESULT(PerlLIO_write(fd, (void*)&e, sizeof(int)));
Expand Down Expand Up @@ -3519,9 +3512,9 @@ Perl_vms_start_glob
#endif /* !VMS */
LEAVE;

if (!fp && ckWARN(WARN_GLOB)) {
warner(packWARN(WARN_GLOB), "glob failed (can't start child: %s)",
Strerror(errno));
if (!fp) {
ck_warner(packWARN(WARN_GLOB), "glob failed (can't start child: %s)",
Strerror(errno));
}

return fp;
Expand Down
43 changes: 21 additions & 22 deletions os2/os2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1165,9 +1165,8 @@ do_spawn_ve(pTHX_ SV *really, const char **argv, U32 flag, U32 execf, char *inic
}
if (PerlIO_close(file) != 0) { /* Failure */
panic_file:
if (ckWARN(WARN_EXEC))
warner(packWARN(WARN_EXEC), "Error reading \"%s\": %s",
scr, Strerror(errno));
ck_warner(packWARN(WARN_EXEC), "Error reading \"%s\": %s",
scr, Strerror(errno));
buf = ""; /* Not #! */
goto doshell_args;
}
Expand Down Expand Up @@ -1300,18 +1299,18 @@ do_spawn_ve(pTHX_ SV *really, const char **argv, U32 flag, U32 execf, char *inic
errno = err;
}
} else if (errno == ENOEXEC) { /* Cannot transfer `real_name' via shell. */
if (rc < 0 && ckWARN(WARN_EXEC))
warner(packWARN(WARN_EXEC), "Can't %s script `%s' with ARGV[0] being `%s'",
((execf != EXECF_EXEC && execf != EXECF_TRUEEXEC)
? "spawn" : "exec"),
real_name, argv[0]);
if (rc < 0)
ck_warner(packWARN(WARN_EXEC), "Can't %s script `%s' with ARGV[0] being `%s'",
((execf != EXECF_EXEC && execf != EXECF_TRUEEXEC)
? "spawn" : "exec"),
real_name, argv[0]);
goto warned;
} else if (errno == ENOENT) { /* Cannot transfer `real_name' via shell. */
if (rc < 0 && ckWARN(WARN_EXEC))
warner(packWARN(WARN_EXEC), "Can't %s `%s' with ARGV[0] being `%s' (looking for executables only, not found)",
((execf != EXECF_EXEC && execf != EXECF_TRUEEXEC)
? "spawn" : "exec"),
real_name, argv[0]);
if (rc < 0))
ck_warner(packWARN(WARN_EXEC), "Can't %s `%s' with ARGV[0] being `%s' (looking for executables only, not found)",
((execf != EXECF_EXEC && execf != EXECF_TRUEEXEC)
? "spawn" : "exec"),
real_name, argv[0]);
goto warned;
}
} else if (rc < 0 && pass == 2 && errno == ENOENT) { /* File not found */
Expand All @@ -1325,11 +1324,11 @@ do_spawn_ve(pTHX_ SV *really, const char **argv, U32 flag, U32 execf, char *inic
goto retry;
}
}
if (rc < 0 && ckWARN(WARN_EXEC))
warner(packWARN(WARN_EXEC), "Can't %s \"%s\": %s\n",
((execf != EXECF_EXEC && execf != EXECF_TRUEEXEC)
? "spawn" : "exec"),
real_name, Strerror(errno));
if (rc < 0))
ck_warner(packWARN(WARN_EXEC), "Can't %s \"%s\": %s\n",
((execf != EXECF_EXEC && execf != EXECF_TRUEEXEC)
? "spawn" : "exec"),
real_name, Strerror(errno));
warned:
if (rc < 0 && (execf != EXECF_SPAWN_NOWAIT)
&& ((trueflag & 0xFF) == P_WAIT))
Expand Down Expand Up @@ -1436,10 +1435,10 @@ do_spawn3(pTHX_ char *cmd, int execf, int flag)
else
rc = result(aTHX_ P_WAIT,
spawnl(P_NOWAIT,shell,shell,copt,cmd,(char*)0));
if (rc < 0 && ckWARN(WARN_EXEC))
warner(packWARN(WARN_EXEC), "Can't %s \"%s\": %s",
(execf == EXECF_SPAWN ? "spawn" : "exec"),
shell, Strerror(errno));
if (rc < 0)
ck_warner(packWARN(WARN_EXEC), "Can't %s \"%s\": %s",
(execf == EXECF_SPAWN ? "spawn" : "exec"),
shell, Strerror(errno));
if (rc < 0)
rc = -1;
}
Expand Down
15 changes: 7 additions & 8 deletions perl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1423,8 +1423,8 @@ perl_destruct(pTHXx)
}
}

if (PL_sv_count != 0 && ckWARN_d(WARN_INTERNAL))
warner(packWARN(WARN_INTERNAL),"Scalars leaked: %ld\n", (long)PL_sv_count);
if (PL_sv_count != 0)
ck_warner_d(packWARN(WARN_INTERNAL), "Scalars leaked: %ld\n", (long)PL_sv_count);

#ifdef DEBUG_LEAKING_SCALARS
if (PL_sv_count != 0) {
Expand Down Expand Up @@ -3645,9 +3645,9 @@ Perl_get_debug_opts(pTHX_ const char **s, bool givehelp)
const char * const d = strchr(debopts,**s);
if (d)
uv |= 1 << (d - debopts);
else if (ckWARN_d(WARN_DEBUGGING))
warner(packWARN(WARN_DEBUGGING),
"invalid option -D%c, use -D'' to see choices\n", **s);
else
ck_warner_d(packWARN(WARN_DEBUGGING),
"invalid option -D%c, use -D'' to see choices\n", **s);
}
}
else if (isDIGIT(**s)) {
Expand Down Expand Up @@ -3804,9 +3804,8 @@ Perl_moreswitches(pTHX_ const char *s)
s++;
PL_debug = get_debug_opts( (const char **)&s, 1) | DEBUG_TOP_FLAG;
#else /* !DEBUGGING */
if (ckWARN_d(WARN_DEBUGGING))
warner(packWARN(WARN_DEBUGGING),
"Recompile perl with -DDEBUGGING to use -D switch (did you mean -d ?)\n");
ck_warner_d(packWARN(WARN_DEBUGGING),
"Recompile perl with -DDEBUGGING to use -D switch (did you mean -d ?)\n");
for (s++; isWORDCHAR(*s); s++) ;
#endif
return s;
Expand Down
15 changes: 5 additions & 10 deletions perlio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1086,8 +1086,7 @@ PerlIOScalar_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg,
if (SvROK(arg)) {
if (SvREADONLY(SvRV(arg)) && !SvIsCOW(SvRV(arg))
&& mode && *mode != 'r') {
if (ckWARN(WARN_LAYER))
warner(packWARN(WARN_LAYER), "%s", PL_no_modify);
ck_warner(packWARN(WARN_LAYER), "%s", PL_no_modify);
SETERRNO(EACCES, RMS_PRV);
return -1;
}
Expand Down Expand Up @@ -1115,8 +1114,7 @@ PerlIOScalar_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg,
if (SvPOK(s->var)) *SvPVX(s->var) = 0;
}
if (SvUTF8(s->var) && !sv_utf8_downgrade(s->var, TRUE)) {
if (ckWARN(WARN_UTF8))
warner(packWARN(WARN_UTF8), code_point_warning);
ck_warner(packWARN(WARN_UTF8), code_point_warning);
SETERRNO(EINVAL, SS_IVCHAN);
SvREFCNT_dec(s->var);
s->var = NULL;
Expand Down Expand Up @@ -1181,8 +1179,7 @@ PerlIOScalar_seek(pTHX_ PerlIO * f, Off_t offset, int whence)
return -1;
}
if (new_posn < 0) {
if (ckWARN(WARN_LAYER))
warner(packWARN(WARN_LAYER), "Offset outside string");
ck_warner(packWARN(WARN_LAYER), "Offset outside string");
SETERRNO(EINVAL, SS_IVCHAN);
return -1;
}
Expand Down Expand Up @@ -1221,8 +1218,7 @@ PerlIOScalar_read(pTHX_ PerlIO *f, void *vbuf, Size_t count)
p = SvPV_nomg(sv, len);
}
else {
if (ckWARN(WARN_UTF8))
warner(packWARN(WARN_UTF8), code_point_warning);
ck_warner(packWARN(WARN_UTF8), code_point_warning);
SETERRNO(EINVAL, SS_IVCHAN);
return -1;
}
Expand Down Expand Up @@ -1265,8 +1261,7 @@ PerlIOScalar_write(pTHX_ PerlIO * f, const void *vbuf, Size_t count)
if (!SvROK(sv)) sv_force_normal(sv);
if (SvOK(sv)) SvPV_force_nomg_nolen(sv);
if (SvUTF8(sv) && !sv_utf8_downgrade(sv, TRUE)) {
if (ckWARN(WARN_UTF8))
warner(packWARN(WARN_UTF8), code_point_warning);
ck_warner(packWARN(WARN_UTF8), code_point_warning);
SETERRNO(EINVAL, SS_IVCHAN);
return 0;
}
Expand Down
8 changes: 4 additions & 4 deletions pp_hot.c
Original file line number Diff line number Diff line change
Expand Up @@ -6626,10 +6626,10 @@ PP(pp_aelem)
SV *sv;
SV *retsv;

if (UNLIKELY(SvROK(elemsv) && !SvGAMAGIC(elemsv) && ckWARN(WARN_MISC)))
warner(packWARN(WARN_MISC),
"Use of reference \"%" SVf "\" as array index",
SVfARG(elemsv));
if (UNLIKELY(SvROK(elemsv) && !SvGAMAGIC(elemsv)))
ck_warner(packWARN(WARN_MISC),
"Use of reference \"%" SVf "\" as array index",
SVfARG(elemsv));
if (UNLIKELY(SvTYPE(av) != SVt_PVAV)) {
retsv = &PL_sv_undef;
goto ret;
Expand Down
6 changes: 2 additions & 4 deletions pp_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -3900,10 +3900,8 @@ PP_wrapped(pp_chdir, MAXARG, 0)
if (PL_op->op_flags & OPf_SPECIAL) {
gv = gv_fetchsv(sv, 0, SVt_PVIO);
if (!gv) {
if (ckWARN(WARN_UNOPENED)) {
warner(packWARN(WARN_UNOPENED),
"chdir() on unopened filehandle %" SVf, sv);
}
ck_warner(packWARN(WARN_UNOPENED),
"chdir() on unopened filehandle %" SVf, sv);
SETERRNO(EBADF,RMS_IFI);
TAINT_PROPER("chdir");
RETPUSHNO;
Expand Down
12 changes: 5 additions & 7 deletions sv.c
Original file line number Diff line number Diff line change
Expand Up @@ -11444,10 +11444,8 @@ S_sv_catpvn_simple(pTHX_ SV *const sv, const char* const buf, const STRLEN len)
*/
STATIC void
S_warn_vcatpvfn_missing_argument(pTHX) {
if (ckWARN(WARN_MISSING)) {
warner(packWARN(WARN_MISSING), "Missing argument in %s",
PL_op ? OP_DESC(PL_op) : "sv_vcatpvfn()");
}
ck_warner(packWARN(WARN_MISSING), "Missing argument in %s",
PL_op ? OP_DESC(PL_op) : "sv_vcatpvfn()");
}


Expand Down Expand Up @@ -13909,9 +13907,9 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
/* Now that we've consumed all our printf format arguments (svix)
* do we have things left on the stack that we didn't use?
*/
if (!no_redundant_warning && sv_count >= svix + 1 && ckWARN(WARN_REDUNDANT)) {
warner(packWARN(WARN_REDUNDANT), "Redundant argument in %s",
PL_op ? OP_DESC(PL_op) : "sv_vcatpvfn()");
if (!no_redundant_warning && sv_count >= svix + 1) {
ck_warner(packWARN(WARN_REDUNDANT), "Redundant argument in %s",
PL_op ? OP_DESC(PL_op) : "sv_vcatpvfn()");
}

if (SvTYPE(sv) >= SVt_PVMG && SvMAGIC(sv)) {
Expand Down
38 changes: 17 additions & 21 deletions utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -2664,13 +2664,11 @@ Perl_utf8_length(pTHX_ const U8 * const s0, const U8 * const e)
}

warn_and_return:
if (ckWARN_d(WARN_UTF8)) {
if (PL_op)
warner(packWARN(WARN_UTF8),
"%s in %s", unees, OP_DESC(PL_op));
else
warner(packWARN(WARN_UTF8), "%s", unees);
}
if (PL_op)
ck_warner_d(packWARN(WARN_UTF8),
"%s in %s", unees, OP_DESC(PL_op));
else
ck_warner_d(packWARN(WARN_UTF8), "%s", unees);

return s - s0;
}
Expand Down Expand Up @@ -4005,23 +4003,21 @@ S_to_case_cp_list(pTHX_
* points */
if (isUNICODE_POSSIBLY_PROBLEMATIC(original)) {
if (UNLIKELY(UNICODE_IS_SURROGATE(original))) {
if (ckWARN_d(WARN_SURROGATE)) {
const char* desc = (PL_op) ? OP_DESC(PL_op) : normal;
warner(packWARN(WARN_SURROGATE),
"Operation \"%s\" returns its argument for"
" UTF-16 surrogate U+%04" UVXf, desc, original);
}
ck_warner_d(packWARN(WARN_SURROGATE),
"Operation \"%s\" returns its argument for"
" UTF-16 surrogate U+%04" UVXf,
(PL_op) ? OP_DESC(PL_op) : normal,
original);
}
else if (UNLIKELY(UNICODE_IS_SUPER(original))) {
if (UNLIKELY(original > MAX_LEGAL_CP)) {
if (UNLIKELY(original > MAX_LEGAL_CP))
croak("%s", form_cp_too_large_msg(16, NULL, 0, original));
}
if (ckWARN_d(WARN_NON_UNICODE)) {
const char* desc = (PL_op) ? OP_DESC(PL_op) : normal;
warner(packWARN(WARN_NON_UNICODE),
"Operation \"%s\" returns its argument for"
" non-Unicode code point 0x%04" UVXf, desc, original);
}

ck_warner_d(packWARN(WARN_NON_UNICODE),
"Operation \"%s\" returns its argument for"
" non-Unicode code point 0x%04" UVXf,
(PL_op) ? OP_DESC(PL_op) : normal,
original);
}

/* Note that non-characters are perfectly legal, so no warning
Expand Down
Loading
Loading