RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 679173 - uninitialized variable warnings from Perl
Summary: uninitialized variable warnings from Perl
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: pki-core
Version: 6.1
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Matthew Harmsen
QA Contact: Chandrasekar Kannan
URL:
Whiteboard:
Depends On: 678157
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-02-21 19:44 UTC by Matthew Harmsen
Modified: 2015-01-04 23:46 UTC (History)
6 users (show)

Fixed In Version: pki-core-9.0.3-3.el6
Doc Type: Bug Fix
Doc Text:
Clone Of: 678157
Environment:
Last Closed: 2011-05-19 13:44:04 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
use not operator to test for uninitialized or non empty value (7.16 KB, patch)
2011-02-21 23:14 UTC, Matthew Harmsen
awnuk: review+
Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2011:0627 0 normal SHIPPED_LIVE new package: pki-core 2011-05-18 17:56:00 UTC

Description Matthew Harmsen 2011-02-21 19:44:46 UTC
+++ This bug was initially created as a clone of Bug #678157 +++

Created attachment 479227 [details]
use not operator to test for uninitialized or non empty value

pkicreate, pkiremove and pkicommon.pm can sometimes emit a warning from Perl concerning an uninitialized variable. Previous patches (e.g. from the tomcat6 porting work) changed variable initialization from the empty string (e.g. "") to the special undef value (i.e. undefined) to catch errors and make the code more robust. We really want to know the difference between a variable which has never been assigned a value vs. a variable currently set to a string which happens to be empty.

A number of places in the code were modified to use the defined() function to ascertain if a value had been assigned to the variable. Formerly many of the tests were of the form 

if $var eq ""

But if $var was uninitialized this will produce a warning because you're comparing an uninitialized variable with a string constant. We do want the warning because using an uninitialized variable probably indicates a coding or logic error.

In some cases we simply want to test if a variable has a non-empty value, i.e. its not undef and it's not the empty string. The simple and clean way to test this condition is with the ! (i.e. not) operator, e.g.:

if !$var

This evaluates to True if the variable is either uninitialized or if it's the empty string without emitting a warning about accessing an uninitialized variable. In many cases this is the logic we want.

Attached is a patch which cleans up testing against the empty string and eliminates Perl warnings about such behaviour.

Comment 1 Matthew Harmsen 2011-02-21 23:14:32 UTC
Created attachment 480019 [details]
use not operator to test for uninitialized or non empty value

Comment 2 Matthew Harmsen 2011-02-21 23:37:09 UTC
IPA_v2_RHEL_6_1_ERRATA_BRANCH:

# cd pki

# svn status | grep -v ^$ | grep -v ^P | grep -v ^X | grep -v ^?
M       base/setup/pkiremove
M       base/setup/pkicommon.pm
M       base/setup/pkicreate

# svn commit
Sending        base/setup/pkicommon.pm
Sending        base/setup/pkicreate
Sending        base/setup/pkiremove
Transmitting file data ...
Committed revision 1860.

Resolves #679173 - uninitialized variable warnings from Perl

Comment 4 Jenny Severance 2011-04-18 17:53:25 UTC
Can you please add steps to verify this issue? thanks

Comment 7 Namita Soman 2011-04-28 13:33:40 UTC
Verified with:
ipa-server-2.0.0-23.el6.x86_64

Ran the ipa-server-install test suite which installs with all options, and then uninstalls also. 

Marking this Verified.

Comment 8 errata-xmlrpc 2011-05-19 13:44:04 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHEA-2011-0627.html


Note You need to log in before you can comment on or make changes to this bug.