On 2015/12/17 18:00, Ard Biesheuvel wrote:
LcrParity and LcrStop may end up being referenced without being
initialized, so make sure they always have a value.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheu...@linaro.org>
---
  PcAtChipsetPkg/Library/SerialIoLib/SerialPortLib.c | 8 ++------
  1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/PcAtChipsetPkg/Library/SerialIoLib/SerialPortLib.c 
b/PcAtChipsetPkg/Library/SerialIoLib/SerialPortLib.c
index 8656785347b2..5698e935b01f 100644
--- a/PcAtChipsetPkg/Library/SerialIoLib/SerialPortLib.c
+++ b/PcAtChipsetPkg/Library/SerialIoLib/SerialPortLib.c
@@ -432,6 +432,7 @@ SerialPortSetAttributes (

    switch (*Parity) {
      case NoParity:
+    case DefaultParity:
        LcrParity = 0;
        break;

@@ -450,13 +451,11 @@ SerialPortSetAttributes (
      case MarkParity:
        LcrParity = 5;
        break;
-
-    default:
-      break;
    }

    switch (*StopBits) {
      case OneStopBit:
+    case DefaultStopBits:
        LcrStop = 0;
        break;

@@ -464,9 +463,6 @@ SerialPortSetAttributes (
      case TwoStopBits:
        LcrStop = 1;
        break;
-
-    default:
-      break;
    }

    //


At the beginning of SerialPortSetAttributes(), there has been already code below. The uninitialized case should never happen, is the compiler not intelligent enough to catch logic?

  if (*Parity == DefaultParity) {
    *Parity = NoParity;
  }

  if (*StopBits == DefaultStopBits) {
    *StopBits = OneStopBit;
  }

Thanks,
Star


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to