mirror of git://git.sysmocom.de/ofono
Refactor: Make option_process more typesafe
option_process was declared with two gpointer arguments for the sole reason of being used as a GFunc. Casting to a GFunc or re-writing the foreach as a loop is preferable.
This commit is contained in:
parent
60d96505dc
commit
5e8a9c2941
|
@ -935,8 +935,11 @@ static guint8 pppcp_process_configure_request(struct pppcp_data *data,
|
|||
* when the ppp goes down.
|
||||
*/
|
||||
if (action->option_process) {
|
||||
g_list_foreach(data->acceptable_options,
|
||||
action->option_process, data);
|
||||
GList *l;
|
||||
|
||||
for (l = data->acceptable_options; l; l = l->next)
|
||||
action->option_process(data, l->data);
|
||||
|
||||
g_list_foreach(data->acceptable_options, remove_config_option,
|
||||
data);
|
||||
}
|
||||
|
@ -986,7 +989,7 @@ static guint8 pppcp_process_configure_ack(struct pppcp_data *data,
|
|||
* the config_options list.
|
||||
*/
|
||||
if (action->option_process)
|
||||
action->option_process(acked_option, data);
|
||||
action->option_process(data, acked_option);
|
||||
|
||||
g_free(list->data);
|
||||
data->config_options =
|
||||
|
|
|
@ -42,7 +42,8 @@ struct pppcp_action {
|
|||
void (*this_layer_finished)(struct pppcp_data *data);
|
||||
enum option_rval (*option_scan)(struct ppp_option *option,
|
||||
gpointer user_data);
|
||||
void (*option_process)(gpointer option, gpointer user_data);
|
||||
void (*option_process)(struct pppcp_data *data,
|
||||
struct ppp_option *option);
|
||||
};
|
||||
|
||||
struct pppcp_packet {
|
||||
|
|
|
@ -122,10 +122,9 @@ static guint ipcp_option_scan(struct ppp_option *option, gpointer user)
|
|||
/*
|
||||
* act on an acceptable option
|
||||
*/
|
||||
static void ipcp_option_process(gpointer data, gpointer user)
|
||||
static void ipcp_option_process(struct pppcp_data *pppcp,
|
||||
struct ppp_option *option)
|
||||
{
|
||||
struct ppp_option *option = data;
|
||||
struct pppcp_data *pppcp = user;
|
||||
struct ipcp_data *ipcp = pppcp_get_data(pppcp);
|
||||
|
||||
switch (option->type) {
|
||||
|
|
|
@ -107,10 +107,9 @@ static guint lcp_option_scan(struct ppp_option *option, gpointer user)
|
|||
* We need to use a default case here because this option type value
|
||||
* could be anything.
|
||||
*/
|
||||
static void lcp_option_process(gpointer data, gpointer user)
|
||||
static void lcp_option_process(struct pppcp_data *pppcp,
|
||||
struct ppp_option *option)
|
||||
{
|
||||
struct ppp_option *option = data;
|
||||
struct pppcp_data *pppcp = user;
|
||||
GAtPPP *ppp = pppcp->ppp;
|
||||
guint32 magic;
|
||||
|
||||
|
|
Loading…
Reference in New Issue