Bug 53345

Summary: _get_dates returns the same date twice if there are both call and text events
Product: Telepathy Reporter: Debarshi Ray <rishi.is>
Component: loggerAssignee: Telepathy bugs list <telepathy-bugs>
Status: RESOLVED FIXED QA Contact: Telepathy bugs list <telepathy-bugs>
Severity: normal    
Priority: medium    
Version: git master   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: log-store-xml: Filter out duplicate dates in get_dates
log-store-xml: Filter out duplicate dates in get_dates

Description Debarshi Ray 2012-08-10 14:17:23 UTC
Looking at log_store_xml_get_dates it is obvious that there is no filtering in place to ensure that each date in the returned list is unique.

Interestingly, the test-log-manager test case only checks _get_dates for text events.
Comment 1 Debarshi Ray 2012-08-10 14:52:22 UTC
Created attachment 65391 [details] [review]
log-store-xml: Filter out duplicate dates in get_dates
Comment 2 Nicolas Dufresne 2012-08-16 18:26:05 UTC
Comment on attachment 65391 [details] [review]
log-store-xml: Filter out duplicate dates in get_dates

Review of attachment 65391 [details] [review]:
-----------------------------------------------------------------

::: telepathy-logger/log-store-xml.c
@@ +998,5 @@
> +        }
> +      else
> +        l = m;
> +    }
> +

Here I would improve the style using something like (not tested):

/* Filter out duplicate dates in-place */
for (l = dates; g_list_next (l) != NULL; l = g_list_next (l))
  {
    GList *next = g_list_next (l);

    if (g_date_compare ((GDate *) next->data, (GDate *) l->date) == 0)
      {
        g_date_free (GDate *) next->data;
        l = g_list_delete_link (l, next);
      }
   }
Comment 3 Debarshi Ray 2012-08-17 13:39:42 UTC
Created attachment 65694 [details] [review]
log-store-xml: Filter out duplicate dates in get_dates

Yes, what you suggest looks better. Here it is in git format-patch format, attributed to you.

Works for me, passes the test suite. The test cases for the walker will fail without this fix.
Comment 4 Debarshi Ray 2012-08-29 20:34:05 UTC
commit 27cfd34a0476aeb34673d26e96f2dbb23684c300
Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Date:   Fri Aug 10 16:52:11 2012 +0200

    log-store-xml: Filter out duplicate dates in get_dates
    
    Fixes: https://bugs.freedesktop.org/53345

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.