xiaoxiang781216 commented on code in PR #21144:
URL: https://github.com/apache/nuttx/pull/21144#discussion_r4435793405


##########
drivers/serial/serial_dma.c:
##########
@@ -59,27 +59,46 @@
 static int uart_recvchars_check_special(FAR uart_dev_t *dev)
 {
   FAR struct uart_dmaxfer_s *xfer = &dev->dmarx;
+  size_t nfirst;
+  size_t nsecond;
+  size_t n;
   int signo;
+  int sig;
 
   /* Check if the valid DMAed data is in one or two contiguous regions */
 
   if (xfer->nbytes <= xfer->length)
     {
-      return uart_check_special(dev, xfer->buffer, xfer->nbytes);
+      nfirst = xfer->nbytes;
+      signo  = uart_check_special(dev, xfer->buffer, &nfirst);
+      xfer->nbytes = nfirst;
+      return signo;
     }
-  else
+
+  nfirst  = xfer->length;
+  nsecond = xfer->nbytes - xfer->length;
+  signo   = uart_check_special(dev, xfer->buffer, &nfirst);
+  sig     = uart_check_special(dev, xfer->nbuffer, &nsecond);
+  if (signo == 0)
     {
-      /* REVISIT:  Additional signals could be in the second region. */
+      signo = sig;
+    }
 
-      signo = uart_check_special(dev, xfer->buffer, xfer->length);
-      if (signo != 0)
-        {
-          return signo;
-        }
+  /* Close the gap at the end of the first region with the start of the
+   * second region, then move the rest of the second region to its start.
+   */
 
-      return uart_check_special(dev, xfer->nbuffer,
-                                xfer->nbytes - xfer->length);
+  n = xfer->length - nfirst;
+  if (n > nsecond)
+    {
+      n = nsecond;
     }
+
+  memcpy(&xfer->buffer[nfirst], xfer->nbuffer, n);

Review Comment:
   let's skip copy if n equals 0



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to