XinStellaris commented on code in PR #8052:
URL: https://github.com/apache/nuttx/pull/8052#discussion_r1065310572


##########
drivers/pipes/pipe_common.c:
##########
@@ -60,6 +60,26 @@
 #  define pipe_dumpbuffer(m,a,n)
 #endif
 
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: pipecommon_bufferused
+ ****************************************************************************/
+
+static pipe_ndx_t pipecommon_bufferused(FAR struct pipe_dev_s *dev)

Review Comment:
   In my opinion, the POLLOUT handling is simple enough. Adding a new function 
may help, but it seems like an overkill.
   
   Also, in pipecommon_iotcl:
   
         nbytes = pipecommon_bufferused(dev);
   
         /* Notify the POLLOUT event if the pipe buffer can accept
          * more than d_polloutthrd bytes, but only if
          * there is readers.
          */
   
         eventset = 0;
         if ((filep->f_oflags & O_WROK) &&
             nbytes < (dev->d_bufsize - dev->d_polloutthrd))
           {
             eventset |= POLLOUT;
           }
   
         /* Notify the POLLIN event if buffer used exceeds poll threshold */
   
         if ((filep->f_oflags & O_RDOK) && (nbytes > dev->d_pollinthrd))
           {
             eventset |= POLLIN;
           }
   
         /* Notify the POLLHUP event if the pipe is empty and no writers */
   
         if (nbytes == 0 && dev->d_nwriters <= 0)
           {
             eventset |= POLLHUP;
           }
   Adding a new pipecommon_bufferleft will lead to calculating buffer used 
bytes twice, since it is already done in pipecommon_bufferused. A little 
redundant?



-- 
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