From ec3a59afb6d97de1d100ad6d05a2982c3f3e18e0 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Mon, 30 Oct 2017 12:25:06 -0500 Subject: [PATCH] sim: Use gcc's bitfield instead of managing flags --- src/sim.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/sim.c b/src/sim.c index 6e59b225..4a97d26c 100644 --- a/src/sim.c +++ b/src/sim.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -46,8 +47,6 @@ #include "simfs.h" #include "stkutil.h" -#define SIM_FLAG_READING_SPN 0x1 - /* * A new session object will be created if a USim/ISim applications are * found during app discovery. Any concurrent file/logical access to @@ -69,8 +68,6 @@ struct ofono_sim_aid_session { }; struct ofono_sim { - int flags; - /* Contents of the SIM file system, in rough initialization order */ char *iccid; @@ -140,6 +137,7 @@ struct ofono_sim { GSList *aid_sessions; GSList *aid_list; char *impi; + bool reading_spn : 1; }; struct msisdn_set_request { @@ -2499,7 +2497,7 @@ static void sim_spn_close(struct ofono_sim *sim) sim->cphs_spn_short_watch = 0; } - sim->flags &= ~SIM_FLAG_READING_SPN; + sim->reading_spn = false; g_free(sim->spn); sim->spn = NULL; @@ -2783,7 +2781,7 @@ static inline void spn_watches_notify(struct ofono_sim *sim) if (sim->spn_watches->items) g_slist_foreach(sim->spn_watches->items, spn_watch_cb, sim); - sim->flags &= ~SIM_FLAG_READING_SPN; + sim->reading_spn = false; } static void sim_spn_set(struct ofono_sim *sim, const void *data, int length, @@ -2899,10 +2897,10 @@ static void sim_spn_changed(int id, void *userdata) { struct ofono_sim *sim = userdata; - if (sim->flags & SIM_FLAG_READING_SPN) + if (sim->reading_spn) return; - sim->flags |= SIM_FLAG_READING_SPN; + sim->reading_spn = true; ofono_sim_read(sim->context, SIM_EFSPN_FILEID, OFONO_SIM_FILE_STRUCTURE_TRANSPARENT, sim_spn_read_cb, sim); @@ -2955,7 +2953,7 @@ ofono_bool_t ofono_sim_add_spn_watch(struct ofono_sim *sim, unsigned int *id, return TRUE; } - if (sim->flags & SIM_FLAG_READING_SPN) + if (sim->reading_spn) return TRUE; ((ofono_sim_spn_cb_t) item->notify)(sim->spn, sim->spn_dc,