diff options
author | Denis Kenzior <denkenz@gmail.com> | 2010-04-05 14:25:14 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-04-05 14:25:14 -0500 |
commit | 5e8a9c29414fb7d9d59a25f6d9e8d523baac95cc (patch) | |
tree | cb82445eda2165ad76c106a2c8b2844440d36869 /gatchat | |
parent | 60d96505dce4f11da7c307b03557a6f2ee8c139d (diff) | |
download | ofono-5e8a9c29414fb7d9d59a25f6d9e8d523baac95cc.tar.bz2 |
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.
Diffstat (limited to 'gatchat')
-rw-r--r-- | gatchat/ppp_cp.c | 9 | ||||
-rw-r--r-- | gatchat/ppp_cp.h | 3 | ||||
-rw-r--r-- | gatchat/ppp_ipcp.c | 5 | ||||
-rw-r--r-- | gatchat/ppp_lcp.c | 5 |
4 files changed, 12 insertions, 10 deletions
diff --git a/gatchat/ppp_cp.c b/gatchat/ppp_cp.c index c24d6122..9d3d18bb 100644 --- a/gatchat/ppp_cp.c +++ b/gatchat/ppp_cp.c @@ -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 = diff --git a/gatchat/ppp_cp.h b/gatchat/ppp_cp.h index acd5329e..2cbda54b 100644 --- a/gatchat/ppp_cp.h +++ b/gatchat/ppp_cp.h @@ -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 { diff --git a/gatchat/ppp_ipcp.c b/gatchat/ppp_ipcp.c index 922681bd..2a59b840 100644 --- a/gatchat/ppp_ipcp.c +++ b/gatchat/ppp_ipcp.c @@ -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) { diff --git a/gatchat/ppp_lcp.c b/gatchat/ppp_lcp.c index aee7b104..7dab019b 100644 --- a/gatchat/ppp_lcp.c +++ b/gatchat/ppp_lcp.c @@ -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; |