All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] huawei, util: Fix a couple of implicit enum conversions
@ 2020-12-20 11:18 richard.rojfors
  2020-12-22 16:33 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: richard.rojfors @ 2020-12-20 11:18 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2701 bytes --]

From: Richard Röjfors <richard@puffinpack.se>

GCC 10 warns about a couple of implicit conversions;

huawei: Member from the incorrect enum was returned,
both had the value 0, so the code would still work.

drivers/huaweimodem/radio-settings.c: In function ‘band_gsm_from_huawei’:
drivers/huaweimodem/radio-settings.c:107:10: error: implicit conversion from ‘enum ofono_radio_band_umts’ to ‘enum ofono_radio_band_gsm’ [-Werror=enum-conversion]
  107 |   return OFONO_RADIO_BAND_UMTS_ANY;

util: smsutil and util has an enum each for representing
the same thing; The SMS alphabet. They share the same
values, so an explicit type cast makes GCC happy.

src/smsutil.c: In function ‘sms_text_prepare_with_alphabet’:
src/smsutil.c:3594:8: error: implicit conversion from ‘enum sms_alphabet’ to ‘enum gsm_dialect’ [-Werror=enum-conversion]
 3594 |        alphabet, &used_locking,
---
 drivers/huaweimodem/radio-settings.c | 2 +-
 src/smsutil.c                        | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/huaweimodem/radio-settings.c b/drivers/huaweimodem/radio-settings.c
index c8ebcba0..b3f31e56 100644
--- a/drivers/huaweimodem/radio-settings.c
+++ b/drivers/huaweimodem/radio-settings.c
@@ -104,7 +104,7 @@ static enum ofono_radio_band_gsm band_gsm_from_huawei(unsigned int band)
 	size_t i;
 
 	if (band == HUAWEI_BAND_ANY)
-		return OFONO_RADIO_BAND_UMTS_ANY;
+		return OFONO_RADIO_BAND_GSM_ANY;
 
 	for (i = ARRAY_SIZE(huawei_band_gsm_table) - 1; i > 0; i--) {
 		if (huawei_band_gsm_table[i].band_huawei & band)
diff --git a/src/smsutil.c b/src/smsutil.c
index 450a1d38..e6556df6 100644
--- a/src/smsutil.c
+++ b/src/smsutil.c
@@ -3575,6 +3575,7 @@ GSList *sms_text_prepare_with_alphabet(const char *to, const char *utf8,
 	GSList *r = NULL;
 	enum gsm_dialect used_locking;
 	enum gsm_dialect used_single;
+	enum gsm_dialect dialect;
 
 	memset(&template, 0, sizeof(struct sms));
 	template.type = SMS_TYPE_SUBMIT;
@@ -3586,12 +3587,14 @@ GSList *sms_text_prepare_with_alphabet(const char *to, const char *utf8,
 	template.submit.vp.relative = 0xA7; /* 24 Hours */
 	sms_address_from_string(&template.submit.daddr, to);
 
+	/* There are two enums for the same thing */
+	dialect = (enum gsm_dialect)alphabet;
 	/*
 	 * UDHI, UDL, UD and DCS actually depend on the contents of
 	 * the text, and also on the GSM dialect we use to encode it.
 	 */
 	gsm_encoded = convert_utf8_to_gsm_best_lang(utf8, -1, NULL, &written, 0,
-							alphabet, &used_locking,
+							dialect, &used_locking,
 							&used_single);
 	if (!gsm_encoded) {
 		size_t converted;
-- 
2.27.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] huawei, util: Fix a couple of implicit enum conversions
  2020-12-20 11:18 [PATCH] huawei, util: Fix a couple of implicit enum conversions richard.rojfors
@ 2020-12-22 16:33 ` Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2020-12-22 16:33 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1268 bytes --]

Hi Richard,

On 12/20/20 5:18 AM, richard.rojfors(a)gmail.com wrote:
> From: Richard Röjfors <richard@puffinpack.se>
> 
> GCC 10 warns about a couple of implicit conversions;
> 
> huawei: Member from the incorrect enum was returned,
> both had the value 0, so the code would still work.
> 
> drivers/huaweimodem/radio-settings.c: In function ‘band_gsm_from_huawei’:
> drivers/huaweimodem/radio-settings.c:107:10: error: implicit conversion from ‘enum ofono_radio_band_umts’ to ‘enum ofono_radio_band_gsm’ [-Werror=enum-conversion]
>    107 |   return OFONO_RADIO_BAND_UMTS_ANY;
> 
> util: smsutil and util has an enum each for representing
> the same thing; The SMS alphabet. They share the same
> values, so an explicit type cast makes GCC happy.
> 
> src/smsutil.c: In function ‘sms_text_prepare_with_alphabet’:
> src/smsutil.c:3594:8: error: implicit conversion from ‘enum sms_alphabet’ to ‘enum gsm_dialect’ [-Werror=enum-conversion]
>   3594 |        alphabet, &used_locking,
> ---
>   drivers/huaweimodem/radio-settings.c | 2 +-
>   src/smsutil.c                        | 5 ++++-
>   2 files changed, 5 insertions(+), 2 deletions(-)
> 

I split this into two commits and applied.  Thanks!

Regards,
-Denis

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-22 16:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-20 11:18 [PATCH] huawei, util: Fix a couple of implicit enum conversions richard.rojfors
2020-12-22 16:33 ` Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.