gen-ipmi-sel: force numeric context

Coerce any bin/oct/hex strings returned from Targets.pm getAttribute
calls into numeric context, so the user can use whatever number base
encoding makes sense to them.

Change-Id: I66195dde94093041e304e1738b9b4330a1681d06
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/gen_ipmi_sel.pl b/gen_ipmi_sel.pl
index dd1fcbd..30efb0d 100755
--- a/gen_ipmi_sel.pl
+++ b/gen_ipmi_sel.pl
@@ -59,12 +59,12 @@
 
     if ($targetObj->getTargetType($target) eq "unit-ipmi-sensor") {
 
-        $sensorID = $targetObj->getAttribute($target, "IPMI_SENSOR_ID");
-        $sensorType = $targetObj->getAttribute($target, "IPMI_SENSOR_TYPE");
-        $eventReadingType = $targetObj->getAttribute($target,
-                             "IPMI_SENSOR_READING_TYPE");
+        $sensorID = getNumeric($targetObj, $target, "IPMI_SENSOR_ID");
+        $sensorType = getNumeric($targetObj, $target, "IPMI_SENSOR_TYPE");
+        $eventReadingType = getNumeric(
+            $targetObj, $target, "IPMI_SENSOR_READING_TYPE");
         $path = $targetObj->getAttribute($target, "INSTANCE_PATH");
-        $entityID = $targetObj->getAttribute($target, "IPMI_ENTITY_ID");
+        $entityID = getNumeric($targetObj, $target, "IPMI_ENTITY_ID");
 
         # Look only for the interested Entity ID & Sensor Type
         next if (not exists $types{$entityID});
@@ -101,6 +101,16 @@
 }
 close $fh;
 
+sub getNumeric
+{
+    my $obj = shift;
+    my $target = shift;
+    my $attr = shift;
+    my $val = $obj->getAttribute($target, $attr);
+    $val = oct($val) if $val =~ /^0/;
+    return $val;
+}
+
 # Usage
 sub printUsage
 {