[PATCH 1/1] binman: elf: Using variable 'old_val' before assignment

old_val can only be assumed initialized in the finally block if it is assigned a value before the try statement.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com --- tools/binman/elf_test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/binman/elf_test.py b/tools/binman/elf_test.py index e3dee79d06..b64134123c 100644 --- a/tools/binman/elf_test.py +++ b/tools/binman/elf_test.py @@ -249,8 +249,8 @@ class TestElf(unittest.TestCase):
def testEmbedFail(self): """Test calling GetSymbolFileOffset() without elftools""" + old_val = elf.ELF_TOOLS try: - old_val = elf.ELF_TOOLS elf.ELF_TOOLS = False fname = self.ElfTestFile('embed_data') with self.assertRaises(ValueError) as e: @@ -290,8 +290,8 @@ class TestElf(unittest.TestCase):
def test_read_segments_fail(self): """Test for read_loadable_segments() without elftools""" + old_val = elf.ELF_TOOLS try: - old_val = elf.ELF_TOOLS elf.ELF_TOOLS = False fname = self.ElfTestFile('embed_data') with self.assertRaises(ValueError) as e: @@ -327,8 +327,8 @@ class TestElf(unittest.TestCase):
def test_get_file_offset_fail(self): """Test calling GetFileOffset() without elftools""" + old_val = elf.ELF_TOOLS try: - old_val = elf.ELF_TOOLS elf.ELF_TOOLS = False fname = self.ElfTestFile('embed_data') with self.assertRaises(ValueError) as e: @@ -351,8 +351,8 @@ class TestElf(unittest.TestCase):
def test_get_symbol_from_address_fail(self): """Test calling GetSymbolFromAddress() without elftools""" + old_val = elf.ELF_TOOLS try: - old_val = elf.ELF_TOOLS elf.ELF_TOOLS = False fname = self.ElfTestFile('embed_data') with self.assertRaises(ValueError) as e:

On Sat, 9 Dec 2023 at 11:50, Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
old_val can only be assumed initialized in the finally block if it is assigned a value before the try statement.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com
tools/binman/elf_test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/binman/elf_test.py b/tools/binman/elf_test.py index e3dee79d06..b64134123c 100644 --- a/tools/binman/elf_test.py +++ b/tools/binman/elf_test.py @@ -249,8 +249,8 @@ class TestElf(unittest.TestCase):
Reviewed-by: Simon Glass sjg@chromium.org
An odd case though...I cannot imagine how this might fail.

On 11.12.23 18:52, Simon Glass wrote:
On Sat, 9 Dec 2023 at 11:50, Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
old_val can only be assumed initialized in the finally block if it is assigned a value before the try statement.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com
tools/binman/elf_test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/binman/elf_test.py b/tools/binman/elf_test.py index e3dee79d06..b64134123c 100644 --- a/tools/binman/elf_test.py +++ b/tools/binman/elf_test.py @@ -249,8 +249,8 @@ class TestElf(unittest.TestCase):
Reviewed-by: Simon Glass sjg@chromium.org
An odd case though...I cannot imagine how this might fail.
This patch is needed to use a recent pylint. Otherwise 'make pylint_err' will fail in future.
Best regards
Heinrich

On 11.12.23 18:52, Simon Glass wrote:
On Sat, 9 Dec 2023 at 11:50, Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
old_val can only be assumed initialized in the finally block if it is assigned a value before the try statement.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com
tools/binman/elf_test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Applied to u-boot-dm/next, thanks!
participants (2)
-
Heinrich Schuchardt
-
Simon Glass