SIP Precedence Warning, possible logic issue

Bug #1519879 reported by Josh Stompro
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Evergreen
Fix Released
Undecided
Unassigned

Bug Description

EG 2.8.4
Perl 5.20.2

I've got a bunch of warnings in my sip logs that say

Possible precedence issue with control flow operator at /usr/local/share/perl/5.20.2/OpenILS/SIP/Patron.pm line 314.

The code looks like the following:

 312 return
 313 !$circ_is_blocked and
 314 $u->active eq 't' and
 315 $u->card->active eq 't';
 316 }

http://git.evergreen-ils.org/?p=Evergreen.git;a=blob;f=Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm;h=ac4f05c3b2b42fbc1f88c413db5917de9c897946;hb=HEAD#l294

I believe that is being interpreted as
(return !$circ_is_blocked) and $u->active eq 't' and $u->card->active eq 't';

So the only check that actually matters is the !circ_is_blocked, the active check and card active check are never reached.

The warning is described at
http://search.cpan.org/dist/perl-5.19.9/pod/perl5194delta.pod#New_Warnings

"not", "and", "or" are considered low precedence operators in perl.

So the solution is to either use a high precedence 'and' (&&) or use parentheses around the checks. But I would like a second opinion.

Josh

Tags: sip
Galen Charlton (gmc)
Changed in evergreen:
status: New → Confirmed
Revision history for this message
Galen Charlton (gmc) wrote :

I confirm that there is indeed a precedence bug.

Changed in evergreen:
assignee: nobody → Josh Stompro (u-launchpad-stompro-org)
Jeff Godin (jgodin)
Changed in evergreen:
assignee: Josh Stompro (u-launchpad-stompro-org) → Jeff Godin (jgodin)
tags: added: sip
Changed in evergreen:
assignee: Jeff Godin (jgodin) → Jason Stephenson (jstephenson)
milestone: none → 3.3-rc
Revision history for this message
Jason Stephenson (jstephenson) wrote :

This was fixed as part of the fix for bug 1659928 that was included in Evergreen 3.0 beta.

no longer affects: evergreen/3.1
no longer affects: evergreen/3.2
Changed in evergreen:
assignee: Jason Stephenson (jstephenson) → nobody
milestone: 3.3-rc → none
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.