aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2020-03-28 16:08:02 +0100
committerAleksander Morgado <aleksander@aleksander.es>2020-04-08 16:35:08 +0200
commit3a2466a3638390260a6149f15f81f3129371d7fd (patch)
treee17d34ba85410ac037b83b37bd1c68ac73c19058
parentb7d728696396da9645aae508c565ea0e094915a5 (diff)
port-serial: assert on totally unexpected serial settings
The bits/parity/stopbits serial settings are set by the daemon, so if any of them are not expected, assert, not just warn.
-rw-r--r--src/mm-port-serial.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/mm-port-serial.c b/src/mm-port-serial.c
index 5e8db484..d5980189 100644
--- a/src/mm-port-serial.c
+++ b/src/mm-port-serial.c
@@ -290,7 +290,7 @@ parse_baudrate (guint baudrate_num,
static int
parse_bits (guint i)
{
- int bits;
+ int bits = -1;
switch (i) {
case 5:
@@ -306,8 +306,7 @@ parse_bits (guint i)
bits = CS8;
break;
default:
- mm_warn ("Invalid bits (%d). Valid values are 5, 6, 7, 8.", i);
- bits = CS8;
+ g_assert_not_reached ();
}
return bits;
@@ -316,7 +315,7 @@ parse_bits (guint i)
static int
parse_parity (char c)
{
- int parity;
+ int parity = -1;
switch (c) {
case 'n':
@@ -332,8 +331,7 @@ parse_parity (char c)
parity = PARENB | PARODD;
break;
default:
- mm_warn ("Invalid parity (%c). Valid values are n, e, o", c);
- parity = 0;
+ g_assert_not_reached ();
}
return parity;
@@ -342,7 +340,7 @@ parse_parity (char c)
static int
parse_stopbits (guint i)
{
- int stopbits;
+ int stopbits = -1;
switch (i) {
case 1:
@@ -352,8 +350,7 @@ parse_stopbits (guint i)
stopbits = CSTOPB;
break;
default:
- mm_warn ("Invalid stop bits (%d). Valid values are 1 and 2)", i);
- stopbits = 0;
+ g_assert_not_reached ();
}
return stopbits;