Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-5411

cfs_hlist_for_each_entry() not working as intended

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Minor
    • None
    • None
    • None
    • 3
    • 15052

    Description

      When HAVE_HLIST_FOR_EACH_3ARG is defined, cfs_hlist_for_each_entry_safe (and similarly cfs_hlist_for_each_entry) are defined as this:

              pos = NULL; hlist_for_each_entry_safe(tpos, n, head, member)
      

      However if we have some code like:

                  for (i = 0; i < REMOTE_PERM_HASHSIZE; i++)
                          cfs_hlist_for_each_entry_safe(lrp, node, next, hash + i,
                                                        lrp_list)
                                  free_ll_remote_perm(lrp);
      

      we end up actually doing:

        
                  for (i = 0; i < REMOTE_PERM_HASHSIZE; i++)
                      pos = NULL;
                  hlist_for_each_entry_safe(lrp, node, next, hash + i, lrp_list)
                                  free_ll_remote_perm(lrp);
      

      which is probably not what was intended.

      pos = NULL can be safely removed since it's an internal cursor. However that will generate some "unused" warnings on platforms where HAVE_HLIST_FOR_EACH_3ARG is defined.

      The other option is to add braces around the call, such as:

        
                  for (i = 0; i < REMOTE_PERM_HASHSIZE; i++) {
                          cfs_hlist_for_each_entry_safe(lrp, node, next, hash + i,
                                                        lrp_list)
                                  free_ll_remote_perm(lrp);
                  }
      

      However that won't prevent a similar bug from being introduced in the future.

      Attachments

        Issue Links

          Activity

            People

              wc-triage WC Triage
              fzago Frank Zago (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: