summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doio.c52
-rw-r--r--ext/Devel/Peek/Peek.xs5
-rw-r--r--ext/DynaLoader/dl_mpeix.xs2
-rw-r--r--ext/PerlIO/Via/Via.xs1
-rw-r--r--ext/Socket/Socket.xs12
-rw-r--r--pp_sys.c114
-rw-r--r--util.c10
7 files changed, 99 insertions, 97 deletions
diff --git a/doio.c b/doio.c
index 448b9b3b66..84d2aaac25 100644
--- a/doio.c
+++ b/doio.c
@@ -1395,7 +1395,6 @@ Perl_do_exec3(pTHX_ char *cmd, int fd, int do_report)
{
register char **a;
register char *s;
- char flags[10];
while (*cmd && isSPACE(*cmd))
cmd++;
@@ -1403,28 +1402,32 @@ Perl_do_exec3(pTHX_ char *cmd, int fd, int do_report)
/* save an extra exec if possible */
#ifdef CSH
- if (strnEQ(cmd,PL_cshname,PL_cshlen) && strnEQ(cmd+PL_cshlen," -c",3)) {
- strcpy(flags,"-c");
- s = cmd+PL_cshlen+3;
- if (*s == 'f') {
- s++;
- strcat(flags,"f");
- }
- if (*s == ' ')
- s++;
- if (*s++ == '\'') {
- char *ncmd = s;
-
- while (*s)
- s++;
- if (s[-1] == '\n')
- *--s = '\0';
- if (s[-1] == '\'') {
- *--s = '\0';
- PerlProc_execl(PL_cshname,"csh", flags,ncmd,(char*)0);
- *s = '\'';
- return FALSE;
- }
+ {
+ char flags[10];
+ if (strnEQ(cmd,PL_cshname,PL_cshlen) &&
+ strnEQ(cmd+PL_cshlen," -c",3)) {
+ strcpy(flags,"-c");
+ s = cmd+PL_cshlen+3;
+ if (*s == 'f') {
+ s++;
+ strcat(flags,"f");
+ }
+ if (*s == ' ')
+ s++;
+ if (*s++ == '\'') {
+ char *ncmd = s;
+
+ while (*s)
+ s++;
+ if (s[-1] == '\n')
+ *--s = '\0';
+ if (s[-1] == '\'') {
+ *--s = '\0';
+ PerlProc_execl(PL_cshname,"csh", flags, ncmd, (char*)0);
+ *s = '\'';
+ return FALSE;
+ }
+ }
}
}
#endif /* CSH */
@@ -1442,7 +1445,8 @@ Perl_do_exec3(pTHX_ char *cmd, int fd, int do_report)
goto doshell;
for (s = cmd; *s; s++) {
- if (*s != ' ' && !isALPHA(*s) && strchr("$&*(){}[]'\";\\|?<>~`\n",*s)) {
+ if (*s != ' ' && !isALPHA(*s) &&
+ strchr("$&*(){}[]'\";\\|?<>~`\n",*s)) {
if (*s == '\n' && !s[1]) {
*s = '\0';
break;
diff --git a/ext/Devel/Peek/Peek.xs b/ext/Devel/Peek/Peek.xs
index b3131b6c85..9806427552 100644
--- a/ext/Devel/Peek/Peek.xs
+++ b/ext/Devel/Peek/Peek.xs
@@ -151,7 +151,6 @@ void
fill_mstats(SV *sv, int level)
{
dTHX;
- int nbuckets;
struct mstats_buffer buf;
if (SvREADONLY(sv))
@@ -216,7 +215,7 @@ _mstats_to_hv(HV *hv, struct mstats_buffer *b, int level)
warn("FIXME: internal mstats buffer too short");
for (type = 0; type < (level ? 4 : 2); type++) {
- UV *p, *p1;
+ UV *p = 0, *p1 = 0;
AV *av;
int i;
static const char *types[4] = {
@@ -229,7 +228,7 @@ _mstats_to_hv(HV *hv, struct mstats_buffer *b, int level)
croak("Unexpected value for the key '%s' in the mstats hash", types[type]);
if (!SvOK(*svp)) {
av = newAV();
- SvUPGRADE(*svp, SVt_RV);
+ (void)SvUPGRADE(*svp, SVt_RV);
SvRV(*svp) = (SV*)av;
SvROK_on(*svp);
} else
diff --git a/ext/DynaLoader/dl_mpeix.xs b/ext/DynaLoader/dl_mpeix.xs
index 7d27901e65..d1da269465 100644
--- a/ext/DynaLoader/dl_mpeix.xs
+++ b/ext/DynaLoader/dl_mpeix.xs
@@ -51,7 +51,7 @@ dl_load_file(filename, flags=0)
PREINIT:
char buf[PATH_MAX + 3];
p_mpe_dld obj = NULL;
- int i;
+
CODE:
DLDEBUG(1,PerlIO_printf(Perl_debug_log, "dl_load_file(%s,%x):\n", filename,
flags));
diff --git a/ext/PerlIO/Via/Via.xs b/ext/PerlIO/Via/Via.xs
index cb3f328e6c..cdb46d448d 100644
--- a/ext/PerlIO/Via/Via.xs
+++ b/ext/PerlIO/Via/Via.xs
@@ -70,7 +70,6 @@ PerlIOVia_method(pTHX_ PerlIO *f,char *method,CV **save,int flags,...)
IV count;
dSP;
SV *arg;
- int i = 0;
ENTER;
PUSHMARK(sp);
XPUSHs(s->obj);
diff --git a/ext/Socket/Socket.xs b/ext/Socket/Socket.xs
index 1a21396e1c..30dd0f2e22 100644
--- a/ext/Socket/Socket.xs
+++ b/ext/Socket/Socket.xs
@@ -1496,12 +1496,12 @@ my @names = (qw(AF_802 AF_APPLETALK AF_CCITT AF_CHAOS AF_DATAKIT AF_DECnet
SO_SNDBUF SO_SNDLOWAT SO_SNDTIMEO SO_TYPE SO_USELOOPBACK
TCP_KEEPALIVE TCP_MAXRT TCP_MAXSEG TCP_NODELAY TCP_STDURG
UIO_MAXIOV MSG_URG),
- {name=>"MSG_CTRUNC", type=>"IV", macro=>["#if defined(MSG_CTRUNC) || defined(HAS_MSG_CTRUNC) /* might be an enum *" . "/\n", "#endif\n"]},
- {name=>"MSG_DONTROUTE", type=>"IV", macro=>["#if defined(MSG_DONTROUTE) || defined(HAS_MSG_DONTROUTE) /* might be an enum *" . "/\n", "#endif\n"]},
- {name=>"MSG_OOB", type=>"IV", macro=>["#if defined(MSG_OOB) || defined(HAS_MSG_OOB) /* might be an enum *" . "/\n", "#endif\n"]},
- {name=>"MSG_PEEK", type=>"IV", macro=>["#if defined(MSG_PEEK) || defined(HAS_MSG_PEEK) /* might be an enum *" . "/\n", "#endif\n"]},
- {name=>"MSG_PROXY", type=>"IV", macro=>["#if defined(MSG_PROXY) || defined(HAS_MSG_PROXY) /* might be an enum *" . "/\n", "#endif\n"]},
- {name=>"SCM_RIGHTS", type=>"IV", macro=>["#if defined(SCM_RIGHTS) || defined(HAS_SCM_RIGHTS) /* might be an enum *" . "/\n", "#endif\n"]},
+ {name=>"MSG_CTRUNC", type=>"IV", macro=>["#if defined(MSG_CTRUNC) || defined(HAS_MSG_CTRUNC) /" . "* might be an enum *" . "/\n", "#endif\n"]},
+ {name=>"MSG_DONTROUTE", type=>"IV", macro=>["#if defined(MSG_DONTROUTE) || defined(HAS_MSG_DONTROUTE) /" . "* might be an enum *" . "/\n", "#endif\n"]},
+ {name=>"MSG_OOB", type=>"IV", macro=>["#if defined(MSG_OOB) || defined(HAS_MSG_OOB) /" . "* might be an enum *" . "/\n", "#endif\n"]},
+ {name=>"MSG_PEEK", type=>"IV", macro=>["#if defined(MSG_PEEK) || defined(HAS_MSG_PEEK) /" . "* might be an enum *" . "/\n", "#endif\n"]},
+ {name=>"MSG_PROXY", type=>"IV", macro=>["#if defined(MSG_PROXY) || defined(HAS_MSG_PROXY) /" . "* might be an enum *" . "/\n", "#endif\n"]},
+ {name=>"SCM_RIGHTS", type=>"IV", macro=>["#if defined(SCM_RIGHTS) || defined(HAS_SCM_RIGHTS) /" . "* might be an enum *" . "/\n", "#endif\n"]},
{name=>"SHUT_RD", type=>"IV", default=>["IV", "0"]},
{name=>"SHUT_RDWR", type=>"IV", default=>["IV", "2"]},
{name=>"SHUT_WR", type=>"IV", default=>["IV", "1"]});
diff --git a/pp_sys.c b/pp_sys.c
index 7332603548..c61f09e96f 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1988,9 +1988,6 @@ PP(pp_truncate)
* at least as wide as size_t, so using an off_t should be okay. */
/* XXX Configure probe for the length type of *truncate() needed XXX */
Off_t len;
- int result = 1;
- GV *tmpgv;
- STRLEN n_a;
#if Size_t_size > IVSIZE
len = (Off_t)POPn;
@@ -2002,60 +1999,67 @@ PP(pp_truncate)
/* XXX Configure probe for the signedness of the length type of *truncate() needed? XXX */
SETERRNO(0,0);
#if defined(HAS_TRUNCATE) || defined(HAS_CHSIZE) || defined(F_FREESP)
- if (PL_op->op_flags & OPf_SPECIAL) {
- tmpgv = gv_fetchpv(POPpx, FALSE, SVt_PVIO);
- do_ftruncate:
- TAINT_PROPER("truncate");
- if (!GvIO(tmpgv) || !IoIFP(GvIOp(tmpgv)))
- result = 0;
- else {
- PerlIO_flush(IoIFP(GvIOp(tmpgv)));
+ {
+ STRLEN n_a;
+ int result = 1;
+ GV *tmpgv;
+
+ if (PL_op->op_flags & OPf_SPECIAL) {
+ tmpgv = gv_fetchpv(POPpx, FALSE, SVt_PVIO);
+
+ do_ftruncate:
+ TAINT_PROPER("truncate");
+ if (!GvIO(tmpgv) || !IoIFP(GvIOp(tmpgv)))
+ result = 0;
+ else {
+ PerlIO_flush(IoIFP(GvIOp(tmpgv)));
#ifdef HAS_TRUNCATE
- if (ftruncate(PerlIO_fileno(IoIFP(GvIOn(tmpgv))), len) < 0)
+ if (ftruncate(PerlIO_fileno(IoIFP(GvIOn(tmpgv))), len) < 0)
#else
- if (my_chsize(PerlIO_fileno(IoIFP(GvIOn(tmpgv))), len) < 0)
+ if (my_chsize(PerlIO_fileno(IoIFP(GvIOn(tmpgv))), len) < 0)
#endif
- result = 0;
- }
- }
- else {
- SV *sv = POPs;
- char *name;
- STRLEN n_a;
-
- if (SvTYPE(sv) == SVt_PVGV) {
- tmpgv = (GV*)sv; /* *main::FRED for example */
- goto do_ftruncate;
- }
- else if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVGV) {
- tmpgv = (GV*) SvRV(sv); /* \*main::FRED for example */
- goto do_ftruncate;
+ result = 0;
+ }
}
+ else {
+ SV *sv = POPs;
+ char *name;
+
+ if (SvTYPE(sv) == SVt_PVGV) {
+ tmpgv = (GV*)sv; /* *main::FRED for example */
+ goto do_ftruncate;
+ }
+ else if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVGV) {
+ tmpgv = (GV*) SvRV(sv); /* \*main::FRED for example */
+ goto do_ftruncate;
+ }
- name = SvPV(sv, n_a);
- TAINT_PROPER("truncate");
+ name = SvPV(sv, n_a);
+ TAINT_PROPER("truncate");
#ifdef HAS_TRUNCATE
- if (truncate(name, len) < 0)
- result = 0;
+ if (truncate(name, len) < 0)
+ result = 0;
#else
- {
- int tmpfd;
- if ((tmpfd = PerlLIO_open(name, O_RDWR)) < 0)
- result = 0;
- else {
- if (my_chsize(tmpfd, len) < 0)
+ {
+ int tmpfd;
+
+ if ((tmpfd = PerlLIO_open(name, O_RDWR)) < 0)
result = 0;
- PerlLIO_close(tmpfd);
+ else {
+ if (my_chsize(tmpfd, len) < 0)
+ result = 0;
+ PerlLIO_close(tmpfd);
+ }
}
- }
#endif
- }
+ }
- if (result)
- RETPUSHYES;
- if (!errno)
- SETERRNO(EBADF,RMS$_IFI);
- RETPUSHUNDEF;
+ if (result)
+ RETPUSHYES;
+ if (!errno)
+ SETERRNO(EBADF,RMS$_IFI);
+ RETPUSHUNDEF;
+ }
#else
DIE(aTHX_ "truncate not implemented");
#endif
@@ -3396,10 +3400,9 @@ PP(pp_chown)
PP(pp_chroot)
{
dSP; dTARGET;
- char *tmps;
#ifdef HAS_CHROOT
STRLEN n_a;
- tmps = POPpx;
+ char *tmps = POPpx;
TAINT_PROPER("chroot");
PUSHi( chroot(tmps) >= 0 );
RETURN;
@@ -4207,11 +4210,9 @@ PP(pp_setpgrp)
PP(pp_getpriority)
{
dSP; dTARGET;
- int which;
- int who;
#ifdef HAS_GETPRIORITY
- who = POPi;
- which = TOPi;
+ int who = POPi;
+ int which = TOPi;
SETi( getpriority(which, who) );
RETURN;
#else
@@ -4222,13 +4223,10 @@ PP(pp_getpriority)
PP(pp_setpriority)
{
dSP; dTARGET;
- int which;
- int who;
- int niceval;
#ifdef HAS_SETPRIORITY
- niceval = POPi;
- who = POPi;
- which = TOPi;
+ int niceval = POPi;
+ int who = POPi;
+ int which = TOPi;
TAINT_PROPER("setpriority");
SETi( setpriority(which, who, niceval) >= 0 );
RETURN;
diff --git a/util.c b/util.c
index 70a15535ef..81f413e966 100644
--- a/util.c
+++ b/util.c
@@ -4941,14 +4941,16 @@ Perl_sv_realpath(pTHX_ SV *sv, char *path, STRLEN len)
char name[MAXPATHLEN] = { 0 }, *s;
STRLEN pathlen, namelen;
+ /* Don't use strlen() to avoid running off the end. */
+ s = memchr(path, '\0', MAXPATHLEN);
+ pathlen = s ? s - path : MAXPATHLEN;
+
#ifdef HAS_REALPATH
+
/* Be paranoid about the use of realpath(),
* it is an infamous source of buffer overruns. */
- /* Is the source buffer too long?
- * Don't use strlen() to avoid running off the end. */
- s = memchr(path, '\0', MAXPATHLEN);
- pathlen = s ? s - path : MAXPATHLEN;
+ /* Is the source buffer too long? */
if (pathlen == MAXPATHLEN) {
Perl_warn(aTHX_ "sv_realpath: realpath(\"%s\"): %c= (MAXPATHLEN = %d)",
path, s ? '=' : '>', MAXPATHLEN);