yamt commented on code in PR #10925:
URL: https://github.com/apache/nuttx/pull/10925#discussion_r1365137085


##########
net/tcp/tcp_conn.c:
##########
@@ -579,27 +579,26 @@ int tcp_selectport(uint8_t domain,
                    uint16_t portno)
 {
   static uint16_t g_last_tcp_port;
-  ssize_t ret;
 
   /* Generate port base dynamically */
 
   if (g_last_tcp_port == 0)
     {
-      ret = getrandom(&g_last_tcp_port, sizeof(uint16_t), 0);
+#if defined(CONFIG_DEV_URANDOM) || defined(CONFIG_DEV_RANDOM)
+      ssize_t ret = getrandom(&g_last_tcp_port, sizeof(uint16_t), 0);
       if (ret < 0)
         {
           ret = getrandom(&g_last_tcp_port, sizeof(uint16_t), GRND_RANDOM);
         }
 
       if (ret != sizeof(uint16_t))
+#endif
         {
-          g_last_tcp_port = clock_systime_ticks() % 32000;
-        }
-      else
-        {
-          g_last_tcp_port = g_last_tcp_port % 32000;
+          g_last_tcp_port = (uint16_t)clock_systime_ticks();
         }
 
+      g_last_tcp_port = g_last_tcp_port % 32000;

Review Comment:
   `clock_systime_ticks() % 32000` and `((uint16_t)clock_systime_ticks()) % 
32000` are different.
   is it intentional?
   



##########
net/tcp/tcp_seqno.c:
##########
@@ -163,14 +162,13 @@ void tcp_initsequence(FAR uint8_t *seqno)
        */
 
       if (ret != sizeof(uint32_t))
+#endif
         {
-          g_tcpsequence = clock_systime_ticks() % 2000000000;
-        }
-      else
-        {
-          g_tcpsequence = g_tcpsequence % 2000000000;
+          g_tcpsequence = (uint32_t)clock_systime_ticks();
         }
 
+      g_tcpsequence = g_tcpsequence % 2000000000;

Review Comment:
   ditto



-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to