summaryrefslogtreecommitdiff
path: root/doio.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-02-12 13:15:20 +0000
committerNicholas Clark <nick@ccl4.org>2008-02-12 13:15:20 +0000
commit7918f24d20384771923d344a382e1d16d9552018 (patch)
tree627e24f3c520f70ddfd3fc9779420bd72fd00c55 /doio.c
parent9f10164a6c9d93684fedbbc188fb9dfe004c22c4 (diff)
downloadperl-7918f24d20384771923d344a382e1d16d9552018.tar.gz
assert() that every NN argument is not NULL. Otherwise we have the
ability to create landmines that will explode under someone in the future when they upgrade their compiler to one with better optimisation. We've already done this at least twice. (Yes, some of the assertions are after code that would already have SEGVd because it already deferences a pointer, but they are put in to make it easier to automate checking that each and every case is covered.) Add a tool, checkARGS_ASSERT.pl, to check that every case is covered. p4raw-id: //depot/perl@33291
Diffstat (limited to 'doio.c')
-rw-r--r--doio.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/doio.c b/doio.c
index ba096ef88c..16d8d01c6b 100644
--- a/doio.c
+++ b/doio.c
@@ -79,6 +79,8 @@ Perl_do_openn(pTHX_ GV *gv, register const char *oname, I32 len, int as_raw,
char mode[PERL_MODE_MAX]; /* file mode ("r\0", "rb\0", "ab\0" etc.) */
SV *namesv;
+ PERL_ARGS_ASSERT_DO_OPENN;
+
Zero(mode,sizeof(mode),char);
PL_forkprocess = 1; /* assume true if no fork */
@@ -705,6 +707,8 @@ Perl_nextargv(pTHX_ register GV *gv)
Gid_t filegid;
IO * const io = GvIOp(gv);
+ PERL_ARGS_ASSERT_NEXTARGV;
+
if (!PL_argvoutgv)
PL_argvoutgv = gv_fetchpvs("ARGVOUT", GV_ADD|GV_NOTQUAL, SVt_PVIO);
if (io && (IoFLAGS(io) & IOf_ARGV) && (IoFLAGS(io) & IOf_START)) {
@@ -952,6 +956,8 @@ Perl_io_close(pTHX_ IO *io, bool not_implicit)
dVAR;
bool retval = FALSE;
+ PERL_ARGS_ASSERT_IO_CLOSE;
+
if (IoIFP(io)) {
if (IoTYPE(io) == IoTYPE_PIPE) {
const int status = PerlProc_pclose(IoIFP(io));
@@ -991,6 +997,8 @@ Perl_do_eof(pTHX_ GV *gv)
dVAR;
register IO * const io = GvIO(gv);
+ PERL_ARGS_ASSERT_DO_EOF;
+
if (!io)
return TRUE;
else if ((IoTYPE(io) == IoTYPE_WRONLY) && ckWARN(WARN_IO))
@@ -1035,6 +1043,8 @@ Perl_do_tell(pTHX_ GV *gv)
register IO *io = NULL;
register PerlIO *fp;
+ PERL_ARGS_ASSERT_DO_TELL;
+
if (gv && (io = GvIO(gv)) && (fp = IoIFP(io))) {
#ifdef ULTRIX_STDIO_BOTCH
if (PerlIO_eof(fp))
@@ -1075,6 +1085,8 @@ Perl_do_sysseek(pTHX_ GV *gv, Off_t pos, int whence)
register IO *io = NULL;
register PerlIO *fp;
+ PERL_ARGS_ASSERT_DO_SYSSEEK;
+
if (gv && (io = GvIO(gv)) && (fp = IoIFP(io)))
return PerlLIO_lseek(PerlIO_fileno(fp), pos, whence);
if (ckWARN2(WARN_UNOPENED,WARN_CLOSED))
@@ -1196,6 +1208,9 @@ bool
Perl_do_print(pTHX_ register SV *sv, PerlIO *fp)
{
dVAR;
+
+ PERL_ARGS_ASSERT_DO_PRINT;
+
/* assuming fp is checked earlier */
if (!sv)
return TRUE;
@@ -1366,6 +1381,7 @@ static void
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))
Perl_warner(aTHX_ packWARN(WARN_EXEC), "Can't exec \"%s\": %s",
cmd, Strerror(e));
@@ -1380,6 +1396,7 @@ Perl_do_aexec5(pTHX_ SV *really, register SV **mark, register SV **sp,
int fd, int do_report)
{
dVAR;
+ PERL_ARGS_ASSERT_DO_AEXEC5;
#if defined(MACOS_TRADITIONAL) || defined(__SYMBIAN32__) || defined(__LIBCATAMOUNT__)
Perl_croak(aTHX_ "exec? I'm not *that* kind of operating system");
#else
@@ -1434,9 +1451,11 @@ Perl_do_exec3(pTHX_ const char *incmd, int fd, int do_report)
register char *s;
char *buf;
char *cmd;
-
/* Make a copy so we can change it */
const Size_t cmdlen = strlen(incmd) + 1;
+
+ PERL_ARGS_ASSERT_DO_EXEC3;
+
Newx(buf, cmdlen, char);
cmd = buf;
memcpy(cmd, incmd, cmdlen);
@@ -1567,6 +1586,8 @@ Perl_apply(pTHX_ I32 type, register SV **mark, register SV **sp)
const char *s;
SV ** const oldmark = mark;
+ PERL_ARGS_ASSERT_APPLY;
+
/* Doing this ahead of the switch statement preserves the old behaviour,
where attempting to use kill as a taint test test would fail on
platforms where kill was not defined. */
@@ -1869,6 +1890,9 @@ Perl_cando(pTHX_ Mode_t mode, bool effective, register const Stat_t *statbufp)
*/
{
dVAR;
+
+ PERL_ARGS_ASSERT_CANDO;
+
#ifdef DOSISH
/* [Comments and code from Len Reed]
* MS-DOS "user" is similar to UNIX's "superuser," but can't write
@@ -1962,6 +1986,7 @@ Perl_do_ipcget(pTHX_ I32 optype, SV **mark, SV **sp)
const I32 n = (optype == OP_MSGGET) ? 0 : SvIVx(*++mark);
const I32 flags = SvIVx(*++mark);
+ PERL_ARGS_ASSERT_DO_IPCGET;
PERL_UNUSED_ARG(sp);
SETERRNO(0,0);
@@ -2002,6 +2027,7 @@ Perl_do_ipcctl(pTHX_ I32 optype, SV **mark, SV **sp)
STRLEN infosize = 0;
I32 getinfo = (cmd == IPC_STAT);
+ PERL_ARGS_ASSERT_DO_IPCCTL;
PERL_UNUSED_ARG(sp);
switch (optype)
@@ -2124,6 +2150,7 @@ Perl_do_msgsnd(pTHX_ SV **mark, SV **sp)
const char * const mbuf = SvPV_const(mstr, len);
const I32 msize = len - sizeof(long);
+ PERL_ARGS_ASSERT_DO_MSGSND;
PERL_UNUSED_ARG(sp);
if (msize < 0)
@@ -2147,6 +2174,8 @@ Perl_do_msgrcv(pTHX_ SV **mark, SV **sp)
I32 msize, flags, ret;
const I32 id = SvIVx(*++mark);
SV * const mstr = *++mark;
+
+ PERL_ARGS_ASSERT_DO_MSGRCV;
PERL_UNUSED_ARG(sp);
/* suppress warning when reading into undef var --jhi */
@@ -2185,6 +2214,8 @@ Perl_do_semop(pTHX_ SV **mark, SV **sp)
const I32 id = SvIVx(*++mark);
SV * const opstr = *++mark;
const char * const opbuf = SvPV_const(opstr, opsize);
+
+ PERL_ARGS_ASSERT_DO_SEMOP;
PERL_UNUSED_ARG(sp);
if (opsize < 3 * SHORTSIZE
@@ -2239,6 +2270,8 @@ Perl_do_shmio(pTHX_ I32 optype, SV **mark, SV **sp)
SV * const mstr = *++mark;
const I32 mpos = SvIVx(*++mark);
const I32 msize = SvIVx(*++mark);
+
+ PERL_ARGS_ASSERT_DO_SHMIO;
PERL_UNUSED_ARG(sp);
SETERRNO(0,0);
@@ -2305,6 +2338,9 @@ Perl_start_glob (pTHX_ SV *tmpglob, IO *io)
dVAR;
SV * const tmpcmd = newSV(0);
PerlIO *fp;
+
+ PERL_ARGS_ASSERT_START_GLOB;
+
ENTER;
SAVEFREESV(tmpcmd);
#ifdef VMS /* expand the wildcards right here, rather than opening a pipe, */