* [PATCH 1/6] sim: Drop glib use from sim_efli_format
@ 2024-02-13 15:35 Denis Kenzior
2024-02-13 15:35 ` [PATCH 2/6] smsutil: Move iso639_2_from_language to util Denis Kenzior
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Denis Kenzior @ 2024-02-13 15:35 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
Change the return signature to use bool instead of gboolean.
Also, change g_ascii_isalpha use to l_ascii_isalpha.
While here, also update array subscripts to follow the coding style,
item M3
---
src/sim.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/sim.c b/src/sim.c
index 33d00ac9a615..55ff5f448647 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -2155,15 +2155,15 @@ static void sim_efli_read_cb(int ok, int length, int record,
}
/* Detect whether the file is in EFli format, as opposed to 51.011 EFlp */
-static gboolean sim_efli_format(const unsigned char *ef, int length)
+static bool sim_efli_format(const unsigned char *ef, int length)
{
int i;
if (length & 1)
- return FALSE;
+ return false;
for (i = 0; i < length; i += 2) {
- if (ef[i] == 0xff && ef[i+1] == 0xff)
+ if (ef[i] == 0xff && ef[i + 1] == 0xff)
continue;
/*
@@ -2171,14 +2171,14 @@ static gboolean sim_efli_format(const unsigned char *ef, int length)
* characters while CB DCS language codes are in ranges
* (0 - 15) or (32 - 47), so the ranges don't overlap
*/
- if (g_ascii_isalpha(ef[i]) == 0)
- return FALSE;
+ if (l_ascii_isalpha(ef[i]) == 0)
+ return false;
- if (g_ascii_isalpha(ef[i+1]) == 0)
- return FALSE;
+ if (l_ascii_isalpha(ef[i + 1]) == 0)
+ return false;
}
- return TRUE;
+ return true;
}
static GSList *parse_language_list(const unsigned char *ef, int length)
@@ -2261,7 +2261,7 @@ static void sim_efpl_read_cb(int ok, int length, int record,
struct ofono_sim *sim = userdata;
const char *path = __ofono_atom_get_path(sim->atom);
DBusConnection *conn = ofono_dbus_get_connection();
- gboolean efli_format = TRUE;
+ bool efli_format = true;
GSList *efli = NULL;
GSList *efpl = NULL;
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/6] smsutil: Move iso639_2_from_language to util
2024-02-13 15:35 [PATCH 1/6] sim: Drop glib use from sim_efli_format Denis Kenzior
@ 2024-02-13 15:35 ` Denis Kenzior
2024-02-13 15:35 ` [PATCH 3/6] sim: Move EFli and EFlp parsers to simutil Denis Kenzior
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Denis Kenzior @ 2024-02-13 15:35 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
Also while here, convert to using stdbool instead of gboolean
---
src/sim.c | 2 +-
src/smsutil.c | 111 --------------------------------------------------
src/smsutil.h | 27 +-----------
src/util.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/util.h | 26 ++++++++++++
5 files changed, 140 insertions(+), 137 deletions(-)
diff --git a/src/sim.c b/src/sim.c
index 55ff5f448647..fedd000923b9 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -2211,7 +2211,7 @@ static GSList *parse_eflp(const unsigned char *eflp, int length)
GSList *ret = NULL;
for (i = 0; i < length; i++) {
- if (iso639_2_from_language(eflp[i], code) == FALSE)
+ if (!iso639_2_from_language(eflp[i], code))
continue;
ret = g_slist_prepend(ret, g_strdup(code));
diff --git a/src/smsutil.c b/src/smsutil.c
index f46507f00e1c..d4f28c01bd79 100644
--- a/src/smsutil.c
+++ b/src/smsutil.c
@@ -3937,117 +3937,6 @@ gboolean cbs_extract_app_port(const struct cbs *cbs, int *dst, int *src,
return extract_app_port_common(&iter, dst, src, is_8bit);
}
-gboolean iso639_2_from_language(enum cbs_language lang, char *iso639)
-{
- switch (lang) {
- case CBS_LANGUAGE_GERMAN:
- iso639[0] = 'd';
- iso639[1] = 'e';
- iso639[2] = '\0';
- return TRUE;
- case CBS_LANGUAGE_ENGLISH:
- iso639[0] = 'e';
- iso639[1] = 'n';
- iso639[2] = '\0';
- return TRUE;
- case CBS_LANGUAGE_ITALIAN:
- iso639[0] = 'i';
- iso639[1] = 't';
- iso639[2] = '\0';
- return TRUE;
- case CBS_LANGUAGE_FRENCH:
- iso639[0] = 'f';
- iso639[1] = 'r';
- iso639[2] = '\0';
- return TRUE;
- case CBS_LANGUAGE_SPANISH:
- iso639[0] = 'e';
- iso639[1] = 's';
- iso639[2] = '\0';
- return TRUE;
- case CBS_LANGUAGE_DUTCH:
- iso639[0] = 'n';
- iso639[1] = 'l';
- iso639[2] = '\0';
- return TRUE;
- case CBS_LANGUAGE_SWEDISH:
- iso639[0] = 's';
- iso639[1] = 'v';
- iso639[2] = '\0';
- return TRUE;
- case CBS_LANGUAGE_DANISH:
- iso639[0] = 'd';
- iso639[1] = 'a';
- iso639[2] = '\0';
- return TRUE;
- case CBS_LANGUAGE_PORTUGESE:
- iso639[0] = 'p';
- iso639[1] = 't';
- iso639[2] = '\0';
- return TRUE;
- case CBS_LANGUAGE_FINNISH:
- iso639[0] = 'f';
- iso639[1] = 'i';
- iso639[2] = '\0';
- return TRUE;
- case CBS_LANGUAGE_NORWEGIAN:
- iso639[0] = 'n';
- iso639[1] = 'o';
- iso639[2] = '\0';
- return TRUE;
- case CBS_LANGUAGE_GREEK:
- iso639[0] = 'e';
- iso639[1] = 'l';
- iso639[2] = '\0';
- return TRUE;
- case CBS_LANGUAGE_TURKISH:
- iso639[0] = 't';
- iso639[1] = 'r';
- iso639[2] = '\0';
- return TRUE;
- case CBS_LANGUAGE_HUNGARIAN:
- iso639[0] = 'h';
- iso639[1] = 'u';
- iso639[2] = '\0';
- return TRUE;
- case CBS_LANGUAGE_POLISH:
- iso639[0] = 'p';
- iso639[1] = 'l';
- iso639[2] = '\0';
- return TRUE;
- case CBS_LANGUAGE_CZECH:
- iso639[0] = 'c';
- iso639[1] = 's';
- iso639[2] = '\0';
- return TRUE;
- case CBS_LANGUAGE_HEBREW:
- iso639[0] = 'h';
- iso639[1] = 'e';
- iso639[2] = '\0';
- return TRUE;
- case CBS_LANGUAGE_ARABIC:
- iso639[0] = 'a';
- iso639[1] = 'r';
- iso639[2] = '\0';
- return TRUE;
- case CBS_LANGUAGE_RUSSIAN:
- iso639[0] = 'r';
- iso639[1] = 'u';
- iso639[2] = '\0';
- return TRUE;
- case CBS_LANGUAGE_ICELANDIC:
- iso639[0] = 'i';
- iso639[1] = 's';
- iso639[2] = '\0';
- return TRUE;
- default:
- iso639[0] = '\0';
- break;
- }
-
- return FALSE;
-}
-
char *cbs_decode_text(GSList *cbs_list, char *iso639_lang)
{
GSList *l;
diff --git a/src/smsutil.h b/src/smsutil.h
index 01487de4b67c..5389757c309c 100644
--- a/src/smsutil.h
+++ b/src/smsutil.h
@@ -19,6 +19,8 @@
*
*/
+enum cbs_language;
+
#define CBS_MAX_GSM_CHARS 93
#define SMS_MSGID_LEN 20
@@ -196,30 +198,6 @@ enum sms_pid_type {
SMS_PID_TYPE_USIM_DOWNLOAD = 0x7f,
};
-enum cbs_language {
- CBS_LANGUAGE_GERMAN = 0x0,
- CBS_LANGUAGE_ENGLISH = 0x1,
- CBS_LANGUAGE_ITALIAN = 0x2,
- CBS_LANGUAGE_FRENCH = 0x3,
- CBS_LANGUAGE_SPANISH = 0x4,
- CBS_LANGUAGE_DUTCH = 0x5,
- CBS_LANGUAGE_SWEDISH = 0x6,
- CBS_LANGUAGE_DANISH = 0x7,
- CBS_LANGUAGE_PORTUGESE = 0x8,
- CBS_LANGUAGE_FINNISH = 0x9,
- CBS_LANGUAGE_NORWEGIAN = 0xA,
- CBS_LANGUAGE_GREEK = 0xB,
- CBS_LANGUAGE_TURKISH = 0xC,
- CBS_LANGUAGE_HUNGARIAN = 0xD,
- CBS_LANGUAGE_POLISH = 0xE,
- CBS_LANGUAGE_UNSPECIFIED = 0xF,
- CBS_LANGUAGE_CZECH = 0x20,
- CBS_LANGUAGE_HEBREW = 0x21,
- CBS_LANGUAGE_ARABIC = 0x22,
- CBS_LANGUAGE_RUSSIAN = 0x23,
- CBS_LANGUAGE_ICELANDIC = 0x24
-};
-
enum cbs_geo_scope {
CBS_GEO_SCOPE_CELL_IMMEDIATE,
CBS_GEO_SCOPE_PLMN,
@@ -576,7 +554,6 @@ gboolean cbs_dcs_decode(guint8 dcs, gboolean *udhi, enum sms_class *cls,
enum sms_charset *charset, gboolean *compressed,
enum cbs_language *language, gboolean *iso639);
-gboolean iso639_2_from_language(enum cbs_language lang, char *iso639);
gboolean cbs_decode(const unsigned char *pdu, int len, struct cbs *out);
gboolean cbs_encode(const struct cbs *cbs, int *len, unsigned char *pdu);
gboolean cbs_extract_app_port(const struct cbs *cbs, int *dst, int *src,
diff --git a/src/util.c b/src/util.c
index 627be7eec097..0a5212a2bca4 100644
--- a/src/util.c
+++ b/src/util.c
@@ -3753,3 +3753,114 @@ unsigned char *convert_ucs2_to_gsm(const unsigned char *text, long len,
GSM_DIALECT_DEFAULT,
GSM_DIALECT_DEFAULT);
}
+
+bool iso639_2_from_language(enum cbs_language lang, char *iso639)
+{
+ switch (lang) {
+ case CBS_LANGUAGE_GERMAN:
+ iso639[0] = 'd';
+ iso639[1] = 'e';
+ iso639[2] = '\0';
+ return true;
+ case CBS_LANGUAGE_ENGLISH:
+ iso639[0] = 'e';
+ iso639[1] = 'n';
+ iso639[2] = '\0';
+ return true;
+ case CBS_LANGUAGE_ITALIAN:
+ iso639[0] = 'i';
+ iso639[1] = 't';
+ iso639[2] = '\0';
+ return true;
+ case CBS_LANGUAGE_FRENCH:
+ iso639[0] = 'f';
+ iso639[1] = 'r';
+ iso639[2] = '\0';
+ return true;
+ case CBS_LANGUAGE_SPANISH:
+ iso639[0] = 'e';
+ iso639[1] = 's';
+ iso639[2] = '\0';
+ return true;
+ case CBS_LANGUAGE_DUTCH:
+ iso639[0] = 'n';
+ iso639[1] = 'l';
+ iso639[2] = '\0';
+ return true;
+ case CBS_LANGUAGE_SWEDISH:
+ iso639[0] = 's';
+ iso639[1] = 'v';
+ iso639[2] = '\0';
+ return true;
+ case CBS_LANGUAGE_DANISH:
+ iso639[0] = 'd';
+ iso639[1] = 'a';
+ iso639[2] = '\0';
+ return true;
+ case CBS_LANGUAGE_PORTUGESE:
+ iso639[0] = 'p';
+ iso639[1] = 't';
+ iso639[2] = '\0';
+ return true;
+ case CBS_LANGUAGE_FINNISH:
+ iso639[0] = 'f';
+ iso639[1] = 'i';
+ iso639[2] = '\0';
+ return true;
+ case CBS_LANGUAGE_NORWEGIAN:
+ iso639[0] = 'n';
+ iso639[1] = 'o';
+ iso639[2] = '\0';
+ return true;
+ case CBS_LANGUAGE_GREEK:
+ iso639[0] = 'e';
+ iso639[1] = 'l';
+ iso639[2] = '\0';
+ return true;
+ case CBS_LANGUAGE_TURKISH:
+ iso639[0] = 't';
+ iso639[1] = 'r';
+ iso639[2] = '\0';
+ return true;
+ case CBS_LANGUAGE_HUNGARIAN:
+ iso639[0] = 'h';
+ iso639[1] = 'u';
+ iso639[2] = '\0';
+ return true;
+ case CBS_LANGUAGE_POLISH:
+ iso639[0] = 'p';
+ iso639[1] = 'l';
+ iso639[2] = '\0';
+ return true;
+ case CBS_LANGUAGE_CZECH:
+ iso639[0] = 'c';
+ iso639[1] = 's';
+ iso639[2] = '\0';
+ return true;
+ case CBS_LANGUAGE_HEBREW:
+ iso639[0] = 'h';
+ iso639[1] = 'e';
+ iso639[2] = '\0';
+ return true;
+ case CBS_LANGUAGE_ARABIC:
+ iso639[0] = 'a';
+ iso639[1] = 'r';
+ iso639[2] = '\0';
+ return true;
+ case CBS_LANGUAGE_RUSSIAN:
+ iso639[0] = 'r';
+ iso639[1] = 'u';
+ iso639[2] = '\0';
+ return true;
+ case CBS_LANGUAGE_ICELANDIC:
+ iso639[0] = 'i';
+ iso639[1] = 's';
+ iso639[2] = '\0';
+ return true;
+ default:
+ iso639[0] = '\0';
+ break;
+ }
+
+ return false;
+}
diff --git a/src/util.h b/src/util.h
index 3e7dfea3e8bc..a70fb49f7ae5 100644
--- a/src/util.h
+++ b/src/util.h
@@ -38,6 +38,30 @@ enum gsm_dialect {
GSM_DIALECT_URDU,
};
+enum cbs_language {
+ CBS_LANGUAGE_GERMAN = 0x0,
+ CBS_LANGUAGE_ENGLISH = 0x1,
+ CBS_LANGUAGE_ITALIAN = 0x2,
+ CBS_LANGUAGE_FRENCH = 0x3,
+ CBS_LANGUAGE_SPANISH = 0x4,
+ CBS_LANGUAGE_DUTCH = 0x5,
+ CBS_LANGUAGE_SWEDISH = 0x6,
+ CBS_LANGUAGE_DANISH = 0x7,
+ CBS_LANGUAGE_PORTUGESE = 0x8,
+ CBS_LANGUAGE_FINNISH = 0x9,
+ CBS_LANGUAGE_NORWEGIAN = 0xA,
+ CBS_LANGUAGE_GREEK = 0xB,
+ CBS_LANGUAGE_TURKISH = 0xC,
+ CBS_LANGUAGE_HUNGARIAN = 0xD,
+ CBS_LANGUAGE_POLISH = 0xE,
+ CBS_LANGUAGE_UNSPECIFIED = 0xF,
+ CBS_LANGUAGE_CZECH = 0x20,
+ CBS_LANGUAGE_HEBREW = 0x21,
+ CBS_LANGUAGE_ARABIC = 0x22,
+ CBS_LANGUAGE_RUSSIAN = 0x23,
+ CBS_LANGUAGE_ICELANDIC = 0x24
+};
+
char *convert_gsm_to_utf8(const unsigned char *text, long len, long *items_read,
long *items_written, unsigned char terminator);
@@ -105,3 +129,5 @@ unsigned char *convert_ucs2_to_gsm_with_lang(const unsigned char *text,
unsigned char *convert_ucs2_to_gsm(const unsigned char *text, long len,
long *items_read, long *items_written,
unsigned char terminator);
+
+bool iso639_2_from_language(enum cbs_language lang, char *iso639);
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/6] sim: Move EFli and EFlp parsers to simutil
2024-02-13 15:35 [PATCH 1/6] sim: Drop glib use from sim_efli_format Denis Kenzior
2024-02-13 15:35 ` [PATCH 2/6] smsutil: Move iso639_2_from_language to util Denis Kenzior
@ 2024-02-13 15:35 ` Denis Kenzior
2024-02-13 15:35 ` [PATCH 4/6] unit: Add unit tests for language list parsers Denis Kenzior
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Denis Kenzior @ 2024-02-13 15:35 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
While here, convert from using g_slist to l_strv utilities and remove
other GLib usage.
---
src/sim.c | 105 ++++++++++++++------------------------------------
src/simutil.c | 62 +++++++++++++++++++++++++++++
src/simutil.h | 3 ++
3 files changed, 93 insertions(+), 77 deletions(-)
diff --git a/src/sim.c b/src/sim.c
index fedd000923b9..1873eccccf2e 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -2181,76 +2181,33 @@ static bool sim_efli_format(const unsigned char *ef, int length)
return true;
}
-static GSList *parse_language_list(const unsigned char *ef, int length)
+static char **concat_lang_prefs(char **a, char **b)
{
- int i;
- GSList *ret = NULL;
-
- for (i = 0; i < length; i += 2) {
- if (ef[i] > 0x7f || ef[i+1] > 0x7f)
- continue;
-
- /*
- * ISO 639 codes contain only characters that are coded
- * identically in SMS 7 bit charset, ASCII or UTF8 so
- * no conversion.
- */
- ret = g_slist_prepend(ret, g_ascii_strdown((char *)ef + i, 2));
- }
-
- if (ret)
- ret = g_slist_reverse(ret);
-
- return ret;
-}
-
-static GSList *parse_eflp(const unsigned char *eflp, int length)
-{
- int i;
- char code[3];
- GSList *ret = NULL;
-
- for (i = 0; i < length; i++) {
- if (!iso639_2_from_language(eflp[i], code))
- continue;
-
- ret = g_slist_prepend(ret, g_strdup(code));
- }
-
- if (ret)
- ret = g_slist_reverse(ret);
-
- return ret;
-}
-
-static char **concat_lang_prefs(GSList *a, GSList *b)
-{
- GSList *l, *k;
char **ret;
- int i = 0;
- int total = g_slist_length(a) + g_slist_length(b);
+ int i;
+ int j;
+ int total = l_strv_length(a) + l_strv_length(b);
if (total == 0)
return NULL;
- ret = g_new0(char *, total + 1);
-
- for (l = a; l; l = l->next)
- ret[i++] = g_strdup(l->data);
-
- for (l = b; l; l = l->next) {
- gboolean duplicate = FALSE;
+ ret = l_new(char *, total + 1);
- for (k = a; k; k = k->next)
- if (!strcmp(k->data, l->data))
- duplicate = TRUE;
+ for (i = 0; a && a[i]; i++)
+ ret[i] = a[i];
- if (duplicate)
+ for (j = 0; b && b[j]; j++) {
+ if (l_strv_contains(a, b[j])) {
+ l_free(b[j]);
continue;
+ }
- ret[i++] = g_strdup(l->data);
+ ret[i++] = b[j];
}
+ l_free(a);
+ l_free(b);
+
return ret;
}
@@ -2262,22 +2219,23 @@ static void sim_efpl_read_cb(int ok, int length, int record,
const char *path = __ofono_atom_get_path(sim->atom);
DBusConnection *conn = ofono_dbus_get_connection();
bool efli_format = true;
- GSList *efli = NULL;
- GSList *efpl = NULL;
+ char **efli = NULL;
+ char **efpl = NULL;
if (!ok || length < 2)
goto skip_efpl;
- efpl = parse_language_list(data, length);
+ efpl = sim_parse_language_list(data, length);
skip_efpl:
if (sim->efli && sim->efli_length > 0) {
efli_format = sim_efli_format(sim->efli, sim->efli_length);
if (efli_format)
- efli = parse_language_list(sim->efli, sim->efli_length);
+ efli = sim_parse_language_list(sim->efli,
+ sim->efli_length);
else
- efli = parse_eflp(sim->efli, sim->efli_length);
+ efli = sim_parse_eflp(sim->efli, sim->efli_length);
}
/*
@@ -2293,13 +2251,14 @@ skip_efpl:
*/
if (efli_format) {
if (sim->efli_length >= 2 && sim->efli[0] == 0xff &&
- sim->efli[1] == 0xff)
- sim->language_prefs = concat_lang_prefs(NULL, efpl);
- else
- sim->language_prefs = concat_lang_prefs(efli, efpl);
- } else {
+ sim->efli[1] == 0xff) {
+ l_strfreev(efli);
+ efli = NULL;
+ }
+
+ sim->language_prefs = concat_lang_prefs(efli, efpl);
+ } else
sim->language_prefs = concat_lang_prefs(efpl, efli);
- }
if (sim->efli) {
g_free(sim->efli);
@@ -2307,14 +2266,6 @@ skip_efpl:
sim->efli_length = 0;
}
- if (efli) {
- g_slist_free_full(efli, g_free);
- }
-
- if (efpl) {
- g_slist_free_full(efpl, g_free);
- }
-
if (sim->language_prefs != NULL)
ofono_dbus_signal_array_property_changed(conn, path,
OFONO_SIM_MANAGER_INTERFACE,
diff --git a/src/simutil.c b/src/simutil.c
index 0354cafd087f..7345f38db571 100644
--- a/src/simutil.c
+++ b/src/simutil.c
@@ -1827,3 +1827,65 @@ gboolean sim_parse_gsm_authenticate(const unsigned char *buffer, int len,
gsm_end:
return FALSE;
}
+
+char **sim_parse_language_list(const unsigned char *ef, int length)
+{
+ int i;
+ size_t n_languages = 0;
+ char **ret;
+
+ for (i = 0; i + 1 < length; i += 2) {
+ if (ef[i] > 0x7f || ef[i + 1] > 0x7f)
+ continue;
+
+ n_languages += 1;
+ }
+
+ if (!n_languages)
+ return NULL;
+
+ ret = l_new(char *, n_languages + 1);
+
+ for (i = 0, n_languages = 0; i + 1 < length; i += 2) {
+ if (ef[i] > 0x7f || ef[i + 1] > 0x7f)
+ continue;
+
+ /*
+ * ISO 639 codes contain only characters that are coded
+ * identically in SMS 7 bit charset, ASCII or UTF8 so
+ * no conversion.
+ */
+ ret[n_languages++] = l_ascii_strdown((const char *)ef + i, 2);
+ }
+
+ return ret;
+}
+
+char **sim_parse_eflp(const unsigned char *eflp, int length)
+{
+ int i;
+ char code[3];
+ char **ret;
+ size_t n_languages = 0;
+
+ for (i = 0; i < length; i++) {
+ if (!iso639_2_from_language(eflp[i], code))
+ continue;
+
+ n_languages += 1;
+ }
+
+ if (!n_languages)
+ return NULL;
+
+ ret = l_new(char *, n_languages + 1);
+
+ for (i = 0, n_languages = 0; i < length; i++) {
+ if (!iso639_2_from_language(eflp[i], code))
+ continue;
+
+ ret[n_languages++] = l_strdup(code);
+ }
+
+ return ret;
+}
diff --git a/src/simutil.h b/src/simutil.h
index fd3967ffd336..9584d4d9cd62 100644
--- a/src/simutil.h
+++ b/src/simutil.h
@@ -541,3 +541,6 @@ gboolean sim_parse_umts_authenticate(const unsigned char *buffer, int len,
gboolean sim_parse_gsm_authenticate(const unsigned char *buffer, int len,
const unsigned char **sres, const unsigned char **kc);
+
+char **sim_parse_language_list(const unsigned char *ef, int length);
+char **sim_parse_eflp(const unsigned char *eflp, int length);
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/6] unit: Add unit tests for language list parsers
2024-02-13 15:35 [PATCH 1/6] sim: Drop glib use from sim_efli_format Denis Kenzior
2024-02-13 15:35 ` [PATCH 2/6] smsutil: Move iso639_2_from_language to util Denis Kenzior
2024-02-13 15:35 ` [PATCH 3/6] sim: Move EFli and EFlp parsers to simutil Denis Kenzior
@ 2024-02-13 15:35 ` Denis Kenzior
2024-02-13 15:35 ` [PATCH 5/6] common: Convert use of g_ascii* to ell Denis Kenzior
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Denis Kenzior @ 2024-02-13 15:35 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
Add unit tests for the newly moved sim_parse_language_list and
sim_parse_eflp functions.
---
unit/test-simutil.c | 57 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/unit/test-simutil.c b/unit/test-simutil.c
index 8364f200c665..4199991a4d2a 100644
--- a/unit/test-simutil.c
+++ b/unit/test-simutil.c
@@ -695,6 +695,59 @@ static void test_auth_build_parse(void)
g_assert(!memcmp(kc_b.data, kc, sizeof(kc)));
}
+static void test_parse_language_list(void)
+{
+ static const unsigned char empty[] = {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+ };
+ static const unsigned char efpl[] = {
+ 'e', 'n', 0xff, 0xff, 'd', 'e', 'f', 'r', 0xff, 0xff, 'n', 'l'
+ };
+
+ char **parsed;
+ char *joined;
+
+ parsed = sim_parse_language_list(empty, sizeof(empty));
+ assert(!parsed);
+
+ parsed = sim_parse_language_list(efpl, sizeof(efpl));
+ assert(parsed);
+ joined = l_strjoinv(parsed, ':');
+ assert(!strcmp(joined, "en:de:fr:nl"));
+ l_strfreev(parsed);
+ l_free(joined);
+
+ parsed = sim_parse_language_list(efpl, sizeof(efpl) - 1);
+ assert(parsed);
+ joined = l_strjoinv(parsed, ':');
+ assert(!strcmp(joined, "en:de:fr"));
+ l_strfreev(parsed);
+ l_free(joined);
+}
+
+static void test_parse_eflp(void)
+{
+ static const unsigned char empty[] = {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+ };
+ static const unsigned char eflp[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05
+ };
+
+ char **parsed;
+ char *joined;
+
+ parsed = sim_parse_eflp(empty, sizeof(empty));
+ assert(!parsed);
+
+ parsed = sim_parse_eflp(eflp, sizeof(eflp));
+ assert(parsed);
+ joined = l_strjoinv(parsed, ':');
+ assert(!strcmp(joined, "de:en:it:fr:es:nl"));
+ l_strfreev(parsed);
+ l_free(joined);
+}
+
int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
@@ -716,5 +769,9 @@ int main(int argc, char **argv)
g_test_add_func("/testsimutil/2G path", test_get_2g_path);
g_test_add_func("/testsimutil/auth build parse", test_auth_build_parse);
+ g_test_add_func("/testsimutil/parse_language_list",
+ test_parse_language_list);
+ g_test_add_func("/testsimutil/parse_efpl", test_parse_eflp);
+
return g_test_run();
}
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/6] common: Convert use of g_ascii* to ell
2024-02-13 15:35 [PATCH 1/6] sim: Drop glib use from sim_efli_format Denis Kenzior
` (2 preceding siblings ...)
2024-02-13 15:35 ` [PATCH 4/6] unit: Add unit tests for language list parsers Denis Kenzior
@ 2024-02-13 15:35 ` Denis Kenzior
2024-02-13 15:35 ` [PATCH 6/6] voicecall: " Denis Kenzior
2024-02-14 16:20 ` [PATCH 1/6] sim: Drop glib use from sim_efli_format patchwork-bot+ofono
5 siblings, 0 replies; 7+ messages in thread
From: Denis Kenzior @ 2024-02-13 15:35 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
Also remove the glib header include since no other GLib use remains.
---
src/common.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/common.c b/src/common.c
index 859f146702ec..aff356da3330 100644
--- a/src/common.c
+++ b/src/common.c
@@ -27,7 +27,6 @@
#include <string.h>
#include <errno.h>
-#include <glib.h>
#include <ell/ell.h>
#include <ofono/types.h>
@@ -561,7 +560,7 @@ gboolean parse_ss_control_string(char *str, int *ss_type,
goto out;
for (i = 0; i < strlen(*sc); i++)
- if (!g_ascii_isdigit((*sc)[i]))
+ if (!l_ascii_isdigit((*sc)[i]))
goto out;
NEXT_FIELD(c, *sia);
@@ -681,7 +680,7 @@ gboolean is_valid_apn(const char *apn)
return FALSE;
for (i = 0; apn[i] != '\0'; i++) {
- if (g_ascii_isalnum(apn[i]))
+ if (l_ascii_isalnum(apn[i]))
continue;
if (apn[i] == '-')
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 6/6] voicecall: Convert use of g_ascii* to ell
2024-02-13 15:35 [PATCH 1/6] sim: Drop glib use from sim_efli_format Denis Kenzior
` (3 preceding siblings ...)
2024-02-13 15:35 ` [PATCH 5/6] common: Convert use of g_ascii* to ell Denis Kenzior
@ 2024-02-13 15:35 ` Denis Kenzior
2024-02-14 16:20 ` [PATCH 1/6] sim: Drop glib use from sim_efli_format patchwork-bot+ofono
5 siblings, 0 replies; 7+ messages in thread
From: Denis Kenzior @ 2024-02-13 15:35 UTC (permalink / raw)
To: ofono; +Cc: Denis Kenzior
---
src/voicecall.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/src/voicecall.c b/src/voicecall.c
index fcfbfcb24513..6d677a9a7487 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -340,7 +340,7 @@ static int tone_queue(struct ofono_voicecall *vc, const char *tone_str,
* and p for Pause.
*/
for (i = 0; tone_str[i]; i++)
- if (!g_ascii_isdigit(tone_str[i]) && tone_str[i] != 'p' &&
+ if (!l_ascii_isdigit(tone_str[i]) && tone_str[i] != 'p' &&
tone_str[i] != 'P' && tone_str[i] != '*' &&
tone_str[i] != '#' && (tone_str[i] < 'A' ||
tone_str[i] > 'D'))
@@ -2196,11 +2196,9 @@ static DBusMessage *manager_tone(DBusConnection *conn,
if (len == 0)
return __ofono_error_invalid_format(msg);
- tones = g_ascii_strup(in_tones, len);
-
+ tones = l_ascii_strup(in_tones, len);
err = tone_queue(vc, tones, tone_callback, vc, NULL);
-
- g_free(tones);
+ l_free(tones);
if (err < 0)
return __ofono_error_invalid_format(msg);
@@ -3440,7 +3438,7 @@ static void emulator_vts_cb(struct ofono_emulator *em,
if (str == NULL)
break;
- if (!g_ascii_isdigit(str[0]) && str[0] != '*' &&
+ if (!l_ascii_isdigit(str[0]) && str[0] != '*' &&
str[0] != '#' && (str[0] < 'A' || str[0] > 'D'))
break;
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/6] sim: Drop glib use from sim_efli_format
2024-02-13 15:35 [PATCH 1/6] sim: Drop glib use from sim_efli_format Denis Kenzior
` (4 preceding siblings ...)
2024-02-13 15:35 ` [PATCH 6/6] voicecall: " Denis Kenzior
@ 2024-02-14 16:20 ` patchwork-bot+ofono
5 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+ofono @ 2024-02-14 16:20 UTC (permalink / raw)
To: Denis Kenzior; +Cc: ofono
Hello:
This series was applied to ofono.git (master)
by Denis Kenzior <denkenz@gmail.com>:
On Tue, 13 Feb 2024 09:35:05 -0600 you wrote:
> Change the return signature to use bool instead of gboolean.
> Also, change g_ascii_isalpha use to l_ascii_isalpha.
> While here, also update array subscripts to follow the coding style,
> item M3
> ---
> src/sim.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
Here is the summary with links:
- [1/6] sim: Drop glib use from sim_efli_format
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=085637842bf1
- [2/6] smsutil: Move iso639_2_from_language to util
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=f7fc3fb342e7
- [3/6] sim: Move EFli and EFlp parsers to simutil
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=dcc67adb9a01
- [4/6] unit: Add unit tests for language list parsers
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=43989a59566a
- [5/6] common: Convert use of g_ascii* to ell
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=ad10d7b0189c
- [6/6] voicecall: Convert use of g_ascii* to ell
https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=a1e492c39bae
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-02-14 16:20 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-13 15:35 [PATCH 1/6] sim: Drop glib use from sim_efli_format Denis Kenzior
2024-02-13 15:35 ` [PATCH 2/6] smsutil: Move iso639_2_from_language to util Denis Kenzior
2024-02-13 15:35 ` [PATCH 3/6] sim: Move EFli and EFlp parsers to simutil Denis Kenzior
2024-02-13 15:35 ` [PATCH 4/6] unit: Add unit tests for language list parsers Denis Kenzior
2024-02-13 15:35 ` [PATCH 5/6] common: Convert use of g_ascii* to ell Denis Kenzior
2024-02-13 15:35 ` [PATCH 6/6] voicecall: " Denis Kenzior
2024-02-14 16:20 ` [PATCH 1/6] sim: Drop glib use from sim_efli_format patchwork-bot+ofono
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox