[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH] Dpkg::Deps: fix "Use of uninitialized value" warnings from dpkg-shlibdeps



Since commit 113533 (Dpkg::Deps: cleanup API, 2009-12-02), the REL_*
constants have been used as keys when defining the
%relation_ordering hash:

 our %relation_ordering = (
	'undef' => 0,
	REL_GE => 1,
	REL_GT => 2,
	REL_EQ => 3,
	REL_LT => 4,
	REL_LE => 5,
 )

Unfortunately, the => operator stringizes the REL_* identifiers, so
that their names rather than their values get used as keys.  As a
result, expressions like %relation_ordering{'>='} are no longer
defined.

Avoid the unwanted stringization by parenthesizing the lhs of the
=> operator.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Hi Raphaël,

When I run dpkg-shlibdeps with recent (unreleased) dpkg-dev, I get

Use of uninitialized value in numeric comparison (<=>) at /usr/share/perl5/Dpkg/Deps.pm line 343.

This fixes it for me.  An alternative fix would be to use a comma
instead of =>, but I kind of like the look of the => operator. :)

Regards,
Jonathan

 scripts/Dpkg/Deps.pm |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm
index 9d98e5e..9166f57 100644
--- a/scripts/Dpkg/Deps.pm
+++ b/scripts/Dpkg/Deps.pm
@@ -317,11 +317,11 @@ This function is mainly used to implement the sort() method.
 
 our %relation_ordering = (
 	'undef' => 0,
-	REL_GE => 1,
-	REL_GT => 2,
-	REL_EQ => 3,
-	REL_LT => 4,
-	REL_LE => 5,
+	(REL_GE) => 1,
+	(REL_GT) => 2,
+	(REL_EQ) => 3,
+	(REL_LT) => 4,
+	(REL_LE) => 5,
 );
 
 sub deps_compare {
-- 
1.7.0


Reply to: