]> sourceware.org Git - lvm2.git/commitdiff
libdm: fix condition
authorZdenek Kabelac <zkabelac@redhat.com>
Fri, 3 May 2024 19:50:38 +0000 (21:50 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Fri, 3 May 2024 22:58:44 +0000 (00:58 +0200)
When we switch supported_reserved_types_with_range to const
gcc repots this problem:

 warning: ‘and’ of mutually exclusive equal-tests is always 0
 !(iter->type & supported_reserved_types_with_range))) {

It's not clear from the history what was the actual intention of this
internal error test, let's assume the check wanted to make sure
that when DM_REPORT_FIELD_RESERVED_VALUE_RANGE is set,
some other fields from supported_reserved_types_with_range set
are also selected.

device_mapper/libdm-report.c
libdm/libdm-report.c

index 362c8b8b6d62313fa9f74f72bb240b65c93e4c64..122ca83abf94808425d52d8c1f6cc4ed684b0e97 100644 (file)
@@ -2589,7 +2589,8 @@ static int _check_reserved_values_supported(const struct dm_report_field_type fi
                if (iter->type & DM_REPORT_FIELD_TYPE_MASK) {
                        if (!(iter->type & supported_reserved_types) ||
                            ((iter->type & DM_REPORT_FIELD_RESERVED_VALUE_RANGE) &&
-                            !(iter->type & supported_reserved_types_with_range))) {
+                            !(iter->type & (supported_reserved_types_with_range &
+                                            ~DM_REPORT_FIELD_RESERVED_VALUE_RANGE)))) {
                                log_error(INTERNAL_ERROR "_check_reserved_values_supported: "
                                          "global reserved value for type 0x%x not supported",
                                           iter->type);
@@ -2600,7 +2601,8 @@ static int _check_reserved_values_supported(const struct dm_report_field_type fi
                        field = &fields[field_res->field_num];
                        if (!(field->flags & supported_reserved_types) ||
                            ((iter->type & DM_REPORT_FIELD_RESERVED_VALUE_RANGE) &&
-                            !(iter->type & supported_reserved_types_with_range))) {
+                            !(iter->type & (supported_reserved_types_with_range &
+                                            ~DM_REPORT_FIELD_RESERVED_VALUE_RANGE)))) {
                                log_error(INTERNAL_ERROR "_check_reserved_values_supported: "
                                          "field-specific reserved value of type 0x%x for "
                                          "field %s not supported",
index 5e74d91297460d63538c2c8eb4f0280410e91066..87defe94a1bce46c08151362ad3325288d3b749f 100644 (file)
@@ -2587,7 +2587,8 @@ static int _check_reserved_values_supported(const struct dm_report_field_type fi
                if (iter->type & DM_REPORT_FIELD_TYPE_MASK) {
                        if (!(iter->type & supported_reserved_types) ||
                            ((iter->type & DM_REPORT_FIELD_RESERVED_VALUE_RANGE) &&
-                            !(iter->type & supported_reserved_types_with_range))) {
+                            !(iter->type & (supported_reserved_types_with_range &
+                                            ~DM_REPORT_FIELD_RESERVED_VALUE_RANGE)))) {
                                log_error(INTERNAL_ERROR "_check_reserved_values_supported: "
                                          "global reserved value for type 0x%x not supported",
                                           iter->type);
@@ -2598,7 +2599,8 @@ static int _check_reserved_values_supported(const struct dm_report_field_type fi
                        field = &fields[field_res->field_num];
                        if (!(field->flags & supported_reserved_types) ||
                            ((iter->type & DM_REPORT_FIELD_RESERVED_VALUE_RANGE) &&
-                            !(iter->type & supported_reserved_types_with_range))) {
+                            !(iter->type & (supported_reserved_types_with_range &
+                                            ~DM_REPORT_FIELD_RESERVED_VALUE_RANGE)))) {
                                log_error(INTERNAL_ERROR "_check_reserved_values_supported: "
                                          "field-specific reserved value of type 0x%x for "
                                          "field %s not supported",
This page took 0.045236 seconds and 5 git commands to generate.