This is an automated email from the ASF dual-hosted git repository.

GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit 8bf430eb29f280bd41a1fa06f59d2293f2bb8146
Author: zhangshuai39 <[email protected]>
AuthorDate: Tue Jun 16 15:32:17 2026 +0800

    netutils/ftpd: remove dead code in ftpd_command_port
    
    Remove the unused #else branch guarded by #if 1 in ftpd_command_port.
    This dead code path (getpeername-based address resolution) was never
    compiled and introduced an unused ret variable.
    
    Signed-off-by: zhangshuai39 <[email protected]>
    Assisted-by: Kiro:claude-opus-4
---
 netutils/ftpd/ftpd.c | 39 ---------------------------------------
 1 file changed, 39 deletions(-)

diff --git a/netutils/ftpd/ftpd.c b/netutils/ftpd/ftpd.c
index 4899c3fc7..bd8b20909 100644
--- a/netutils/ftpd/ftpd.c
+++ b/netutils/ftpd/ftpd.c
@@ -2763,7 +2763,6 @@ static int ftpd_command_port(FAR struct ftpd_session_s 
*session)
   int temp;
   FAR char *str;
   int index;
-  int ret;
 
   index = 0;
   while (index < 6)
@@ -2807,8 +2806,6 @@ static int ftpd_command_port(FAR struct ftpd_session_s 
*session)
 
   ftpd_dataclose(session);
 
-#if 1 /* Follow param */
-
   memset(&session->data.addr, 0, sizeof(session->data.addr));
 
   session->data.addr.in4.sin_family = AF_INET;
@@ -2822,42 +2819,6 @@ static int ftpd_command_port(FAR struct ftpd_session_s 
*session)
   utemp = ((unsigned int)value[4] << 8) | (unsigned int)value[5];
   session->data.addr.in4.sin_port = htons((short)utemp);
 
-#else /* Follow command socket address */
-
-  session->data.addrlen = sizeof(session->data.addr);
-  ret = getpeername(session->cmd.sd, (struct sockaddr *)&session->data.addr,
-                   &session->data.addrlen);
-  if (ret >= 0)
-    {
-      if (session->data.addr.ss.ss_family != AF_INET)
-        {
-          memset(&session->data.addr, 0, sizeof(session->data.addr));
-
-          session->data.addr.in4.sin_family = AF_INET;
-
-          utemp = (value[0] << 24) | (value[1] << 16) |
-                  (value[2] << 8) | (value[3]);
-          session->data.addr.in4.sin_addr.s_addr = htonl(utemp);
-        }
-
-      utemp = (value[4] << 8) | (value[5]);
-      session->data.addr.in4.sin_port = htons(utemp);
-    }
-  else
-    {
-      memset(&session->data.addr, 0, sizeof(session->data.addr));
-
-      session->data.addr.in4.sin_family = AF_INET;
-
-      utemp = (value[0] << 24) | (value[1] << 16) |
-              (value[2] << 8) | (value[3]);
-      session->data.addr.in4.sin_addr.s_addr = htonl(utemp);
-    }
-
-  utemp = (value[4] << 8) | (value[5]);
-  session->data.addr.in4.sin_port = htons(utemp);
-#endif
-
   return ftpd_response(session->cmd.sd, session->txtimeout,
                        g_respfmt1, 200, ' ',
                        "PORT command successful");

Reply via email to