| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
| |
You need to configure with g++ *and* -Accflags=-DPERL_GLOBAL_STRUCT
or -Accflags=-DPERL_GLOBAL_STRUCT_PRIVATE to see any difference.
(g++ does not do the "post-annotation" form of "unused".)
The version code has some of these issues, reported upstream.
|
|
|
|
|
|
| |
This reverts commit 148f39b7de6eae9ddd59e0b0aff691d6abea7aca.
(Still needs more work, but wanted to see how well this passed with Jenkins.)
|
|
|
|
|
|
| |
Definitely not *after* it. It marks the start of the unreachable,
not the first unrechable line. And if they are in that order,
it looks better to linebreak after the lint hint.
|
|
|
|
|
| |
Even though it can't be reached, the absence of a return statement
makes the VMS C compiler warn that it's missing.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- after return/croak/die/exit, return/break are pointless
(break is not a terminator/separator, it's a goto)
- after goto, another goto (!) is pointless
- in some cases (usually function ends) introduce explicit NOT_REACHED
to make the noreturn nature clearer (do not do this everywhere, though,
since that would mean adding NOT_REACHED after every croak)
- for the added NOT_REACHED also add /* NOTREACHED */ since
NOT_REACHED is for gcc (and VC), while the comment is for linters
- declaring variables in switch blocks is just too fragile:
it kind of works for narrowing the scope (which is nice),
but breaks the moment there are initializations for the variables
(the initializations will be skipped since the flow will bypass
the start of the block); in some easy cases simply hoist the declarations
out of the block and move them earlier
Note 1: Since after this patch the core is not yet -Wunreachable-code
clean, not enabling that via cflags.SH, one needs to -Accflags=... it.
Note 2: At least with the older gcc 4.4.7 there are far too many
"unreachable code" warnings, which seem to go away with gcc 4.8,
maybe better flow control analysis. Therefore, the warning should
eventually be enabled only for modernish gccs (what about clang and
Intel cc?)
|
|
|
|
|
|
|
| |
This reverts commit 8c2b19724d117cecfa186d044abdbf766372c679.
I don't understand - smoke-me came back happy with three
separate reports... oh well, some other time.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- after croak/die/exit (or return), break (or return!) are pointless
(break is not a terminator/separator, it's a promise of a jump)
- after goto, another goto (!) is pointless
- in some cases (usually function ends) introduce explicit NOT_REACHED
to make the noreturn nature clearer (do not do this everywhere, though,
since that would mean adding NOT_REACHED after every croak)
- for the added NOT_REACHED also add /* NOTREACHED */ since
NOT_REACHED is for gcc (and VC), while the comment is for linters
- declaring variables in switch blocks is just too fragile:
it kind of works for narrowing the scope (which is nice),
but breaks the moment there are initializations for the variables
(they will be skipped!); in some easy cases simply hoist the declarations
out of the block and move them earlier
There are still a few places left.
|
|
|
|
|
|
|
|
| |
Commit d6ded95025185cb1ec8ca3ba5879cab881d8b180 introduced
the ability to specify individual category parameters to 'use locale'.
However in doing so, it causes Perl to not be able to compile on
platforms that don't have some or all of those categories defined, such
as Android. This commit uses #ifdefs to remedy that.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It is not very user friendly to list functions as
"Functions found in file FOO". Better is to group them by purpose, as
many were already. I went through and placed the ones that weren't
already so grouped into groups. Patches welcome if you have a better
classification.
I changed the headings of some so that the important disctinction was
the first word so that they are placed in the file more appropriately.
And a couple of ones that I had created myself, I came up with a name
that I think is better than the original
|
|
|
|
|
|
|
| |
This commit allows one to specify to enable locale-awareness for only a
specified subset of the locale categories. Thus you could make a
section of code LC_MESSAGES aware, with no locale-awareness for the
other categories.
|
|
|
|
|
|
|
|
|
|
|
| |
remove some redundant code regarding stack handling
-removed:
-4/-8 pop on SP
+4/+8 push on SP
PUTBACK
function's machine code size dropped from 0xC5 to 0xBD bytes on VC2003
|
|
|
|
|
|
|
| |
Used by linters (static checkers), and also good for human readers.
Even though "FALL THROUGH" seems to be the most common, e.g BSD lint
manual only knows "FALLTHROUGH" (or "FALLTHRU").
|
|
|
|
|
|
|
|
| |
Adding asserts to more spots.
Fix for Coverity perl5 CIDs 28962,28968,28969:
CID ...: Dereference after null check (FORWARD_NULL)
var_deref_op: Dereferencing null pointer p->q
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(Also very few spots of negative numgroups for getgroups(),
and fgetc() return, but almost all checking is for fcntl.)
(merged fix for perl #121743 and perl #121745: hopefully
picked up all the fixes-to-fixes from the ticket...)
Fix for Coverity perl5 CIDs 28990..29003,29005..29011,29013,
45354,45363,49926:
Argument cannot be negative (NEGATIVE_RETURNS) fd is
passed to a parameter that cannot be negative.
and CIDs 29004, 29012:
Argument cannot be negative (NEGATIVE_RETURNS)
num_groups is passed to a parameter that cannot be negative
and because of CIDs 29005 and 29006 also CID 28924.
In the first set of issues a fd is retrieved from PerlIO_fileno, and
that is then used in places like fstat(), fchown(), dup(), etc.,
without checking whether the fd is valid (>=0).
In the second set of issues a potentially negative
number is potentially passed to getgroups().
The CIDs 29005 and 29006 were a bit messy: fixing them needed also
resolving CID 28924 where the return value of fstat() was ignored,
and for completeness adding two croak calls (with perldiag updates):
a bit of a waste since it's suidperl code.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fix for Coverity perl5 CID 29088: Uninitialized scalar variable (UNINIT)
uninit_use: Using uninitialized value tmbuf.tm_year.
There is a code path that can lead to accessing uninitialized tmbuf:
when the too-small or too-large time inputs to gmtime/localtime
happen.
- make it so that the tm_year is used only on successful code path:
pp_sys.c
- add the gmtime failed / localtime failed errors to perldiag:
pod/perldiag.pod
- test those errors: t/op/time.t
|
|
|
|
|
|
|
| |
If PerlIO_getc returns EOF, PerlIO_get_cnt is not going to return a
positive value all of a sudden.
Signed-off-by: Niels Thykier <niels@thykier.net>
|
| |
|
|
|
|
|
|
| |
Calls to Perl_do_openn() all have at least 2 unused arguments which clutter
the code and hinder easy understanding. Perl_do_open6() and
Perl_do_open_raw() each only do one job, so don't have the dead arguments.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It was replaced by the standard tms struct in v7.0, released in
1995. Explicit support for pre-7.0 was removed in 32995a382d65b
for Perl 5.16, but I missed the tbuffer_t bit, which tripped up
Nicholas in 25983af42cdcf2dc, because he asked for:
struct tbuffer_t
which via macro expansion became:
struct struct tms
which failed to compile. So remove code that's unnecessarily
different on VMS, leaving only a tbuffer_t compatibility macro
with a more appropriate comment so it will hopefully be less
likely to get used in new code.
|
|
|
|
|
|
|
|
|
|
| |
PL_timesbuf is effectively a vestige of Perl 1, and doesn't actually need to
be an interpreter variable. It will be removed early in v5.21.x, but it's a
good idea to refactor the code not to use it before then. A local struct tms
will be on the C stack, which will be in the CPU's L1 cache, whereas the
relevant part of the interpreter struct may well not be in the CPU cache at
all. Therefore this change might reduce cache pressure fractionally. A local
variable access should also be simpler machine code on most CPU architectures.
|
|
|
|
|
|
| |
av_tindex is a more clearly named synonym for av_len, available starting
in v5.18. This changes the core uses to it, including modules in /ext,
which are not dual-lifed.
|
|
|
|
|
|
|
|
|
| |
cygwin inherits recv behaviour from the Win32 sockets API which doesn't
modify the namebuf or it's associated size when you recv() from a
connected socket, handle this the same way Win32 does by zeroing the
length if it's the same as before calling recv().
Also adds some basic socket function tests to the core tests.
|
|
|
|
|
|
|
|
| |
The same scalar (the target) is used to return the value each time the
same getc operator is called. It was turning on the utf8 flag when
necessary, but not turning it off.
(I suspect recv has the same bug. I haven’t confirmed.)
|
|
|
|
|
|
| |
This static function is called from exactly two places that both die
aforehand if cv is null. Further, the cv parameter is already marked
as non-null.
|
|
|
|
| |
plus some typo fixes. I probably changed some things in perlintern, too.
|
|
|
|
|
| |
pp_enterwrite, EXTEND contains a funccall, dont save gv around it
pp_ioctl, move optype to first place used to reduce liveness
|
|
|
|
|
| |
Thanks again to Daniel Dragan for pointing out candidates in
<rt-4.0.18-29603-1387872667-551.120842-15-0@perl.org> (ticket #120842).
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Nulls only get pushed on to the stack when pp_coreargs uses them to
represent missing optional arguments. Ops that take * prototypes
will have had their arguments passed through rv2gv first, so they
should always be GVs. GvIOn never returns null. When given a GV
argument, it creates a new IO entry and returns that. When given
any other argument it croaks.
Thank you to Daniel Dragan for providing a list of candidate pp
functions in <rt-4.0.18-29609-1387862001-129.120842-15-0@perl.org>
(ticket #120842).
|
|
|
|
|
|
|
|
|
|
| |
There is actually no way for nulls to reach this code.
Nulls on the stack only happen with pp_coreargs, and only with
ops that have optional arguments, of which socketpair is not one.
GvIOn uses gv_add_by_type, which adds a new IO if there is not
already one, so it will never return null if the GV is not null.
|
|
|
|
|
|
|
|
|
|
| |
pp_socket: remove unreachable made by commit 9c9f25b8ce
pp_socketpair: increase locality, now gv2/io2 is tested before gv1 is
processed, *v1 vars become non-const to avoid large WS changes in
opening new scope
pp_bind: move op_type's init so it isn't saved by CC across a func call
|
|
|
|
|
|
| |
POSIX expects readdir() to leave errno alone when it reaches end of
directory without an error so that case can be detected. Do the same
in perl.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Due to the security risks associated with user-supplied formats
being passed to C-level printf() style functions (eg %n),
gcc has a -Wformat-nonliteral warning that complains whenever such a
function is passed a non-literal format string.
This commit silences all such warnings in core and ext/.
The main changes are
1) the 'f' (format) flag in embed.fnc is now handled slightly more
cleverly. Rather than just applying to functions whose last arg is '...'
(and where the format arg is assumed to be the previous arg), it
can now handle non-'...' functions: arg checking is disabled, but format
checking is sill done: it works by assuming that an arg called 'fmt',
'pat' or 'f' is the format string (and dies if fails to find exactly one
such arg).
2) with the new embed.fnc functionally, more functions have been marked
with the 'f' flag. When such a function passes its fmt arg onto an inner
printf-like function, we simply disable the warning for that call using
GCC_DIAG_IGNORE(-Wformat-nonliteral), since we know that the caller must
have already checked it.
3) In quite a few places the format string isn't literal, but it *is*
constant (e.g. PL_warn_uninit_sv). For those cases, again disable the
warning.
4) In pp_formline(), a particular format was was one of several different
literal strings depending on circumstances. Rather than assigning this
string to a temporary variable, incorporate the ?: branches directly in
the function call arg. gcc is clever enough to decide the arg is then
always literal.
|
|
|
|
|
|
|
|
|
|
|
| |
A suggested way of avoiding the the warning on nv1 != nv2
by replacing it with (nv1 < nv2 || nv1 > nv2), has too many issues
with NaN. [perl #120538].
I haven't found any other way of selectively disabling the warning,
so for now I'm just reverting the whole commit.
This reverts commit c279c4550ce59702722d0921739b1a1b92701b0d.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The gcc option -Wfloat-equal warns when two floating-point numbers
are directly compared for equality or inequality, the idea being that
this is usually a logic error, and that you should be checking that the
values are instead very near to each other.
perl on the other hand has lots of reasons to do a direct comparison.
Add two macros, NV_eq_nowarn(a,b) and NV_eq_nowarn(a,b)
that do the same as (a == b) and (a != b), but without the warnings.
They achieve this by instead doing (a < b) || ( a > b).
Under gcc at least, this is optimised into the same code as the direct
comparison.
The are three places that I've left untouched, because they are handling
NaNs, and that gets a bit tricky. In particular (nv != nv) is a test for a
NaN, and replacing it with (< || >) creates signalling NaNs (whereas ==
and != create quiet NaNs)
|
|
|
|
|
|
|
| |
This commit makes them behave like exit and die without the ampersand
by moving the OPpHUSH_VMSISH hint from exit/die op to the current
statement (nextstate/cop) instead. &CORE:: subs intentionally lack a
nextstate op, so they can see the hints in the caller’s nextstate op.
|
|
|
|
|
|
| |
[perl #120102] CORE::select ignoring timeout var's magic
Patch by Eric, with tested added by davem.
|
|
|
|
|
| |
This was added in 5.5/5.6 as a backwards-compatibility measure
when taint was extended to happen in more places.
|
| |
|
|
|
|
|
| |
There are several cases where PERL_MICRO is used combined with defines
not set in uconfig.h, the additional test isn't needed.
|
|
|
|
| |
These functions worked with ints instead of SSize_t,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
when unwinding sub and format calls.
The comments in the added test file explain what the problem is.
The fix is to call LEAVE_SCOPE in POPSUB and POPFORMAT (to free their
lexicals) before lowering CvDEPTH.
If the context has already been popped via cxstack_ix--, then
LEAVE_SCOPE could overwrite it, so accessing cx after LEAVE_SCOPE is
unsafe. Hence the changes to POPSUB and POPFORMAT are a bit involved.
Some callers of POPSUB do a temporary cxstack_ix++ first so they
can access cx afterwards. Two cases needed to be changed to
work that way.
|
|
|
|
|
|
|
|
|
|
|
| |
System select (select with 4 arguments) does not allow any of its
first three arguments to be read-only unless they are undef or
empty strings.
It does not work properly for read-only copy-on-write empty strings,
because it passes all copy-on-write through sv_force_normal under the
expectation that they will shortly be modified. It should not be
doing that for read-only empty strings.
|
|
|
|
|
|
|
|
|
| |
When elements of @_ refer to nonexistent hash or array elements, then
the magic scalar in $_[0] delegates all set/get actions to the element
in represents, vivifying it if needed.
tie/tied/untie, however, were not delegating to the element, but were
tying the the magical ‘deferred element’ scalar itself.
|
|
|
|
| |
The Strerror macro is defined properly to handle either case here.
|
| |
|
|
|
|
|
|
| |
This is unreachable. It only happens in pp_leavewrite when IoTOP_GV(io)
is null, but the code leading up to it makes sure that IoTOP_GV(io) is not
null. If it is still null, it jumps past the error with ‘goto forget_top’.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The code dealt rather inconsistently with uids and gids. Some
places assumed that they could be safely stored in UVs, others
in IVs, others in ints; All of them should've been using the
macros from config.h instead. Similarly, code that created
SVs or pushed values into the stack was also making incorrect
assumptions -- As a point of reference, only pp_stat did the
right thing:
#if Uid_t_size > IVSIZE
mPUSHn(PL_statcache.st_uid);
#else
# if Uid_t_sign <= 0
mPUSHi(PL_statcache.st_uid);
# else
mPUSHu(PL_statcache.st_uid);
# endif
#endif
The other places were potential bugs, and some were even causing
warnings in some unusual OSs, like haiku or qnx.
This commit ammends the situation by introducing four new macros,
SvUID(), sv_setuid(), SvGID(), and sv_setgid(), and using them
where needed.
|
|
|
|
|
|
|
|
|
|
|
| |
This means that there are always macros or functions for ntohl, ntohs,
htonl and htons available, so eliminate use of HAS_NTOHL etc, and
unconditionally compile the code that it was protecting. However, as code
on CPAN is using these guard macros, define all of them in perl.h
(Technically the 4 are not quite no-ops, as they truncate their values to
32 or 16 bits, to be consistent with the implementations for platforms which
need re-ordering.)
|
|
|
|
| |
and fix the test that's meant to detect this bug.
|