Hi Daniel,
> >> +static gint compare_interval(gconstpointer a, gconstpointer b)
> >> +{
> >> + guint i = GPOINTER_TO_UINT(a);
> >> + guint j = GPOINTER_TO_UINT(b);
> >> +
> >> + return i - j;
> >> +}
> >
> > So personally I would do val_a - val_b to give some relation to the
> > pointer, but i and j work as well.
>
> I went out of good names. Changed to val_a, val_b.
I know that feeling with these compare method.
> >> +unsigned int __connman_rtnl_update_interval_add(unsigned int interval)
> >> +{
> >> + guint min;
> >> +
> >> + if (interval == 0)
> >> + return 0;
> >> +
> >> + update_list = g_slist_insert_sorted(update_list,
> >> + GUINT_TO_POINTER(interval), compare_interval);
> >> +
> >> + min = GPOINTER_TO_UINT(g_slist_nth_data(update_list, 0));
> >> + if (min< update_interval) {
> >> + update_interval_callback(min);
> >> + __connman_rtnl_request_update();
> >> + }
> >> +
> >> + return update_interval;
> >> +}
> >> +
> >> +unsigned int __connman_rtnl_update_interval_remove(unsigned int interval)
> >> +{
> >> + guint min = G_MAXUINT;
> >> +
> >> + if (interval == 0)
> >> + return 0;
> >> +
> >> + update_list = g_slist_remove(update_list, GINT_TO_POINTER(interval));
> >> +
> >> + if (g_slist_length(update_list) != 0)
> >> + min = GPOINTER_TO_UINT(g_slist_nth_data(update_list, 0));
> >
> > I do prefer checks like g_slist_length()> 0. However in this case
> > actually checking for update_list != NULL might be better.
>
> g_lists_length() > 0: done.
>
> g_slist_remove and g_slist_length do nothing if NULL is passed in.
> So it's not really necessary to check update_list, but I agree it's
> more clear with a update_list != NULL. Do you still want me to add
> it?
Yes please. There is also a BKM somewhere that says that the NULL check
is preferred instead checking for length equals zero.
Regards
Marcel
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman