]> code.ossystems Code Review - openembedded-core.git/commitdiff
lib/oe/qa: add explicit exception for 'file isn't an ELF'
authorRoss Burton <ross.burton@intel.com>
Wed, 24 Feb 2016 13:31:40 +0000 (13:31 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sun, 28 Feb 2016 11:32:35 +0000 (11:32 +0000)
Signed-off-by: Ross Burton <ross.burton@intel.com>
meta/classes/insane.bbclass
meta/classes/uninative.bbclass
meta/lib/oe/qa.py

index 61936e13774c0c340704f67d43ad333961eea063..b9adea77c805a899fff77e075399486571c1abfa 100644 (file)
@@ -792,9 +792,8 @@ def package_qa_walk(warnfuncs, errorfuncs, skip, package, d):
             elf = oe.qa.ELFFile(path)
             try:
                 elf.open()
-            except (IOError, ValueError):
+            except (IOError, oe.qa.NotELFFileError):
                 # IOError can happen if the packaging control files disappear,
-                # ValueError means the file isn't an ELF.
                 elf = None
             for func in warnfuncs:
                 func(path, package, d, elf, warnings)
index b14cec065ee1e8acbe1200562ad364ecdd6b2233..7e225e6f15007cf5feb48e59ddce759b133e69f0 100644 (file)
@@ -80,7 +80,7 @@ python uninative_changeinterp () {
             elf = oe.qa.ELFFile(f)
             try:
                 elf.open()
-            except ValueError:
+            except oe.qa.NotELFFileError:
                 continue
 
             #bb.warn("patchelf-uninative --set-interpreter %s %s" % (d.getVar("UNINATIVE_LOADER", True), f))
index 2ad6c63bdc33514a678ff5c011f214ebd81ab571..4efa21fd801cc6d5390f23f9d7b9f39342f8853f 100644 (file)
@@ -1,3 +1,6 @@
+class NotELFFileError(Exception):
+    pass
+
 class ELFFile:
     EI_NIDENT = 16
 
@@ -23,7 +26,7 @@ class ELFFile:
     def my_assert(self, expectation, result):
         if not expectation == result:
             #print "'%x','%x' %s" % (ord(expectation), ord(result), self.name)
-            raise ValueError("%s is not an ELF" % self.name)
+            raise NotELFFileError("%s is not an ELF" % self.name)
 
     def __init__(self, name, bits = 0):
         self.name = name
@@ -32,7 +35,7 @@ class ELFFile:
 
     def open(self):
         if not os.path.isfile(self.name):
-            raise ValueError("%s is not a normal file" % self.name)
+            raise NotELFFileError("%s is not a normal file" % self.name)
 
         self.file = file(self.name, "r")
         self.data = self.file.read(ELFFile.EI_NIDENT+4)
@@ -49,24 +52,24 @@ class ELFFile:
                 self.bits = 64
             else:
                 # Not 32-bit or 64.. lets assert
-                raise ValueError("ELF but not 32 or 64 bit.")
+                raise NotELFFileError("ELF but not 32 or 64 bit.")
         elif self.bits == 32:
             self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS32))
         elif self.bits == 64:
             self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS64))
         else:
-            raise ValueError("Must specify unknown, 32 or 64 bit size.")
+            raise NotELFFileError("Must specify unknown, 32 or 64 bit size.")
         self.my_assert(self.data[ELFFile.EI_VERSION], chr(ELFFile.EV_CURRENT) )
 
         self.sex = self.data[ELFFile.EI_DATA]
         if self.sex == chr(ELFFile.ELFDATANONE):
-            raise ValueError("self.sex == ELFDATANONE")
+            raise NotELFFileError("self.sex == ELFDATANONE")
         elif self.sex == chr(ELFFile.ELFDATA2LSB):
             self.sex = "<"
         elif self.sex == chr(ELFFile.ELFDATA2MSB):
             self.sex = ">"
         else:
-            raise ValueError("Unknown self.sex")
+            raise NotELFFileError("Unknown self.sex")
 
     def osAbi(self):
         return ord(self.data[ELFFile.EI_OSABI])