On 26/11/2014 10:02 am, Joel Sherrill wrote:
From: Josh Oguin <josh.og...@oarcorp.com>

This was flagged by CodeSonar. It should be impossible to get an
incorrect baud number back but ensure this in debug mode. The _Assert()
keeps their scanner from evaluating for divide by 0 past this point.
---
  c/src/libchip/serial/ns16550-context.c | 4 ++++
  c/src/libchip/serial/ns16550.c         | 3 +++
  c/src/libchip/serial/z85c30.c          | 8 +++++++-
  3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/c/src/libchip/serial/ns16550-context.c 
b/c/src/libchip/serial/ns16550-context.c
index 00ad89c..087627a 100644
--- a/c/src/libchip/serial/ns16550-context.c
+++ b/c/src/libchip/serial/ns16550-context.c
@@ -592,9 +592,13 @@ static bool ns16550_set_attributes(

    /*
     *  Calculate the baud rate divisor
+   *
+   *  Assert ensures there is no division by 0.
     */

    baud_requested = rtems_termios_baud_to_number(t->c_cflag);
+  _Assert( baud_requested != 0 );
+

Should this return an error or the value should be tested in an upper layer. I will raise a ticket to have the upper layers reject B0 as a baud rate.

Chris
_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to