Hi Denis,

> > +
> > +static void ril_cbs_set_topics(struct ofono_cbs *cbs, const char *topics,
> > +                                   ofono_cbs_set_cb_t cb, void *user_data) 
> > {
> > +   struct cbs_data *cd = ofono_cbs_get_data(cbs);
> > +   struct cb_data *cbd = cb_data_new(cb, user_data, cd);
> > +   int count = 0, from, to;
> > +   const char *p = topics;
> > +   const char *pto;
> > +   struct parcel rilp;
> > +
> > +   while (p) {
> > +           count++;
> > +           p = strchr(p, ',');
> > +           if (p)
> > +                   p++;
> > +   }
> > +
> 
> It might be simpler to just use g_strsplit here and free the result after the
> parcel has been built.
> 
Done.

Please have a look.
> > +   p = topics;
> > +   if (count > 0) {
> > +           if (atoi(p) == 0 && strchr(p, '0') == NULL) /* empty string */
> > +                   count--;
> > +   }
> 
> The passed in string should not contain any ',' at the very end.  So I'm not
> sure if this check is really necessary?
> 

In case of the topics is empty ("").

> > +
> > +   parcel_init(&rilp);
> > +   parcel_w_int32(&rilp, count);
> > +
> > +   while (count > 0) {
> > +           from = atoi(p);
> > +           to = from;
> > +
> > +           pto = strchr(p, '-');
> > +           if (pto)
> > +                   to = atoi(pto + 1);
> > +
> > +           parcel_w_int32(&rilp, from);
> > +           parcel_w_int32(&rilp, to);
> > +
> > +           parcel_w_int32(&rilp, 0);
> > +           parcel_w_int32(&rilp, 0xFF);
> > +
> > +           parcel_w_int32(&rilp, 1);
> > +
> > +           count--;
> > +           p = strchr(p, ',');
> > +           p++;
> > +   }
> > +
> > +   if (g_ril_send(cd->ril,
> RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG, &rilp,
> > +                   ril_cbs_set_cb, cbd, g_free) > 0)
> > +           return;

Regards,
Caiwen
_______________________________________________
ofono mailing list
[email protected]
https://lists.ofono.org/mailman/listinfo/ofono

Reply via email to