From 3a2466a3638390260a6149f15f81f3129371d7fd Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Sat, 28 Mar 2020 16:08:02 +0100 Subject: [PATCH] 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. --- src/mm-port-serial.c | 15 ++++++--------- 1 file 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;