[PATCH 0/2] test: Using variable 'old_dtb' before assignment

Avoid errors reported by 'make pylint_err.
Heinrich Schuchardt (2): test: fit: Using variable 'old_dtb' before assignment test: vboot: Using variable 'old_dtb' before assignment
test/py/tests/test_fit.py | 6 +++--- test/py/tests/test_vboot.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)

old_dtb 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 --- test/py/tests/test_fit.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/py/tests/test_fit.py b/test/py/tests/test_fit.py index f45848484e..04f64fd4bc 100755 --- a/test/py/tests/test_fit.py +++ b/test/py/tests/test_fit.py @@ -390,10 +390,10 @@ def test_fit(u_boot_console):
cons = u_boot_console + # We need to use our own device tree file. Remember to restore it + # afterwards. + old_dtb = cons.config.dtb try: - # We need to use our own device tree file. Remember to restore it - # afterwards. - old_dtb = cons.config.dtb mkimage = cons.config.build_dir + '/tools/mkimage' run_fit_test(mkimage) finally:

On Sat, 9 Dec 2023 at 11:54, Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
old_dtb 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
test/py/tests/test_fit.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

old_dtb 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 --- test/py/tests/test_vboot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/py/tests/test_vboot.py b/test/py/tests/test_vboot.py index 04fa59f98b..7e0e8e4475 100644 --- a/test/py/tests/test_vboot.py +++ b/test/py/tests/test_vboot.py @@ -533,10 +533,10 @@ def test_vboot(u_boot_console, name, sha_algo, padding, sign_options, required, with open(evil_kernel, 'wb') as fd: fd.write(500 * b'\x01')
+ # We need to use our own device tree file. Remember to restore it + # afterwards. + old_dtb = cons.config.dtb try: - # We need to use our own device tree file. Remember to restore it - # afterwards. - old_dtb = cons.config.dtb cons.config.dtb = dtb if global_sign: test_global_sign(sha_algo, padding, sign_options)

On Sat, 9 Dec 2023 at 11:54, Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
old_dtb 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
test/py/tests/test_vboot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
I suggest mentioning the motivation for the patch in your commit message. E.g. does it cause a pylint failure?

On 11.12.23 18:52, Simon Glass wrote:
On Sat, 9 Dec 2023 at 11:54, Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
old_dtb 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
test/py/tests/test_vboot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
I suggest mentioning the motivation for the patch in your commit message. E.g. does it cause a pylint failure?
You only get a pylint error with current pylint, not with the one used by our CI.
Best regards
Heinrich
participants (2)
-
Heinrich Schuchardt
-
Simon Glass