From a27025946b2d1cdf855e37dd90319695614f0d52 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Wed, 23 Aug 2023 06:14:03 +0200 Subject: [PATCH] [PR #7125/77214203 backport][stable-7] Fix inappropriate comparison on the length of a Collection (#7147) Fix inappropriate comparison on the length of a Collection (#7125) * Comment: Fixed inappropriate comparison on the length of a Collection. Added changlelog fragment file. * Comment: Updated the scope of the changelog fragment based on feedback. Co-authored-by: Felix Fontein --------- Co-authored-by: Felix Fontein (cherry picked from commit 7721420388aa1d9cf7751fa250754d3419f3a2b1) Co-authored-by: Munawar --- changelogs/fragments/7125-fix-inappropriate-comparison.yml | 2 ++ plugins/module_utils/oracle/oci_utils.py | 7 ++----- 2 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/7125-fix-inappropriate-comparison.yml diff --git a/changelogs/fragments/7125-fix-inappropriate-comparison.yml b/changelogs/fragments/7125-fix-inappropriate-comparison.yml new file mode 100644 index 0000000000..7bcfb1edd5 --- /dev/null +++ b/changelogs/fragments/7125-fix-inappropriate-comparison.yml @@ -0,0 +1,2 @@ +bugfixes: + - oci_utils module util - fix inappropriate logical comparison expressions and makes them simpler. The previous checks had logical short circuits (https://github.com/ansible-collections/community.general/pull/7125). diff --git a/plugins/module_utils/oracle/oci_utils.py b/plugins/module_utils/oracle/oci_utils.py index 9d8e16e5a3..717d253cec 100644 --- a/plugins/module_utils/oracle/oci_utils.py +++ b/plugins/module_utils/oracle/oci_utils.py @@ -561,7 +561,7 @@ def are_lists_equal(s, t): if s is None and t is None: return True - if (s is None and len(t) >= 0) or (t is None and len(s) >= 0) or (len(s) != len(t)): + if s is None or t is None or (len(s) != len(t)): return False if len(s) == 0: @@ -1026,10 +1026,7 @@ def check_if_user_value_matches_resources_attr( return if ( - resources_value_for_attr is None - and len(user_provided_value_for_attr) >= 0 - or user_provided_value_for_attr is None - and len(resources_value_for_attr) >= 0 + resources_value_for_attr is None or user_provided_value_for_attr is None ): res[0] = False return