]> sourceware.org Git - lvm2.git/commitdiff
select: fix string list selection to match whole words only but not prefixes of searc...
authorPeter Rajnoha <prajnoha@redhat.com>
Wed, 13 Aug 2014 13:27:00 +0000 (15:27 +0200)
committerPeter Rajnoha <prajnoha@redhat.com>
Wed, 13 Aug 2014 14:04:02 +0000 (16:04 +0200)
$ lvs -o name,tags vg/lvol0
  LV    LV Tags
  lvol0 a

Before this patch:

$ lvs -o name,tags vg/lvol0 -S 'tags=[a]'
  LV    LV Tags
  lvol0 a

$ lvs -o name,tags vg/lvol0 -S 'tags=[ab]'
  LV    LV Tags
  lvol0 a
(incorrect!)

$ lvs -o name,tags vg/lvol0 -S 'tags=[abc]'
  LV    LV Tags
  lvol0 a
(incorrect!)

With this patch applied:

$ lvs -o name,tags vg/lvol0 -S 'tags=[a]'
  LV    LV Tags
  lvol0 a

$ lvs -o name,tags vg/lvol0 -S 'tags=[ab]'
(no result - correct!)

$ lvs -o name,tags vg/lvol0 -S 'tags=[abc]'
(no result - correct!)

WHATS_NEW_DM
libdm/libdm-report.c

index 842ee15473e8d2b0f9a09d0e02179a00f5e408d1..7bb3f4ccb838e61d37ab2e299999eb78257ae711 100644 (file)
@@ -1,5 +1,6 @@
 Version 1.02.89 -
 =================================
+  Fix string list selection to match whole words only, not prefixes.
 
 Version 1.02.88 - 5th August 2014
 =================================
index b94cc00742614be83f2617155a07f3ee96429a3f..620283c88835e15e8ecb4e6ab72a19fe41501f01 100644 (file)
@@ -1260,7 +1260,8 @@ static int _cmp_field_string_list_all(const struct str_list_sort_value *val,
 
        /* both lists are sorted so they either match 1:1 or not */
        dm_list_iterate_items(sel_item, sel->list) {
-               if (strncmp(sel_item->str, val->value + val->items[i].pos, val->items[i].len))
+               if ((strlen(sel_item->str) != val->items[i].len) ||
+                   strncmp(sel_item->str, val->value + val->items[i].pos, val->items[i].len))
                        return 0;
                i++;
        }
@@ -1285,7 +1286,8 @@ static int _cmp_field_string_list_any(const struct str_list_sort_value *val,
                 *       Make use of the fact that the lists are sorted!
                 */
                for (i = 1; i <= val->items[0].len; i++) {
-                       if (!strncmp(sel_item->str, val->value + val->items[i].pos, val->items[i].len))
+                       if ((strlen(sel_item->str) == val->items[i].len) &&
+                           !strncmp(sel_item->str, val->value + val->items[i].pos, val->items[i].len))
                                return 1;
                }
        }
This page took 0.047044 seconds and 5 git commands to generate.