From 8033b058a97a59aa467f6031d313110f26c714b5 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Thu, 3 Apr 2025 20:35:04 +0100 Subject: [PATCH] ext/ftp: Remove output field of ftpbuf_t struct It was only used once, and removing it reduces the size of a userland FTP object by 4096 bytes --- ext/ftp/ftp.c | 8 +++----- ext/ftp/ftp.h | 1 - 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c index 39555d8c7e3..f37ee686176 100644 --- a/ext/ftp/ftp.c +++ b/ext/ftp/ftp.c @@ -1181,7 +1181,7 @@ bool ftp_site(ftpbuf_t *ftp, const char *cmd, const size_t cmd_len) static bool ftp_putcmd(ftpbuf_t *ftp, const char *cmd, const size_t cmd_len, const char *args, const size_t args_len) { int size; - char *data; + char data[FTP_BUFSIZE]; if (strpbrk(cmd, "\r\n")) { return false; @@ -1195,17 +1195,15 @@ static bool ftp_putcmd(ftpbuf_t *ftp, const char *cmd, const size_t cmd_len, con if (strpbrk(args, "\r\n")) { return 0; } - size = slprintf(ftp->outbuf, sizeof(ftp->outbuf), "%s %s\r\n", cmd, args); + size = slprintf(data, sizeof(data), "%s %s\r\n", cmd, args); } else { /* "cmd\r\n\0" */ if (cmd_len + 3 > FTP_BUFSIZE) { return false; } - size = slprintf(ftp->outbuf, sizeof(ftp->outbuf), "%s\r\n", cmd); + size = slprintf(data, sizeof(data), "%s\r\n", cmd); } - data = ftp->outbuf; - /* Clear the inbuf and extra-lines buffer */ ftp->inbuf[0] = '\0'; ftp->extra = NULL; diff --git a/ext/ftp/ftp.h b/ext/ftp/ftp.h index 5f01f202b8e..241f92f57ec 100644 --- a/ext/ftp/ftp.h +++ b/ext/ftp/ftp.h @@ -60,7 +60,6 @@ typedef struct ftpbuf char inbuf[FTP_BUFSIZE]; /* last response text */ char *extra; /* extra characters */ int extralen; /* number of extra chars */ - char outbuf[FTP_BUFSIZE]; /* command output buffer */ char *pwd; /* cached pwd */ char *syst; /* cached system type */ ftptype_t type; /* current transfer type */