summaryrefslogtreecommitdiff
path: root/doio.c
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2020-11-17 15:59:44 +1100
committerTony Cook <tony@develop-help.com>2020-11-24 13:35:21 +1100
commitd43c116b2ae74ec1f3ed78829d4f3ca76f091390 (patch)
tree5c2a08a6a9204a0f58add3736b8cc533ed8fa6b6 /doio.c
parente1902e4ac113e51aa730e03a2b1bc54ec96c371c (diff)
downloadperl-d43c116b2ae74ec1f3ed78829d4f3ca76f091390.tar.gz
io/sem.t: eliminate warnings
This eliminates some warnings that semctl() (or other *ctl()) calls might generate, and some warnings specific to io/sem.t: - for IPC_STAT and GETALL, the current value of ARG is overwritten so making an undefined value warning for it nonsensical, so don't use SvPV_force(). - for other calls, ARG is either ignored, or in a behaviour introduced in perl 3 (along with the ops), treats the supplied value as an integer which is then converted to a pointer. Rather than warning on an undef value which is most likely to be ignored we treat the undef as zero without the usual warning. - always pass a number for SEMNUM in the test code I didn't try to eliminate warning for non-numeric/undefined SEMNUM, since while we know it isn't used by SETALL, GETALL, IPC_STAT and IPC_SET, it may or may not be used by system defined *ctl() operators such as SEM_INFO and SHM_LOCK on Linux. fixes #17926
Diffstat (limited to 'doio.c')
-rw-r--r--doio.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/doio.c b/doio.c
index 29a431d8eb..bc59c178df 100644
--- a/doio.c
+++ b/doio.c
@@ -2999,7 +2999,11 @@ Perl_do_ipcctl(pTHX_ I32 optype, SV **mark, SV **sp)
{
if (getinfo)
{
- SvPV_force_nolen(astr);
+ /* we're not using the value here, so don't SvPVanything */
+ SvUPGRADE(astr, SVt_PV);
+ SvGETMAGIC(astr);
+ if (SvTHINKFIRST(astr))
+ sv_force_normal_flags(astr, 0);
a = SvGROW(astr, infosize+1);
}
else
@@ -3015,8 +3019,18 @@ Perl_do_ipcctl(pTHX_ I32 optype, SV **mark, SV **sp)
}
else
{
- const IV i = SvIV(astr);
- a = INT2PTR(char *,i); /* ouch */
+ /* We historically treat this as a pointer if we don't otherwise recognize
+ the op, but for many ops the value is simply ignored anyway, so
+ don't warn on undef.
+ */
+ SvGETMAGIC(astr);
+ if (SvOK(astr)) {
+ const IV i = SvIV_nomg(astr);
+ a = INT2PTR(char *,i); /* ouch */
+ }
+ else {
+ a = NULL;
+ }
}
SETERRNO(0,0);
switch (optype)
@@ -3058,7 +3072,7 @@ Perl_do_ipcctl(pTHX_ I32 optype, SV **mark, SV **sp)
if (getinfo && ret >= 0) {
SvCUR_set(astr, infosize);
*SvEND(astr) = '\0';
- SvUTF8_off(astr);
+ SvPOK_only(astr);
SvSETMAGIC(astr);
}
return ret;