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
This commit is contained in:
Gina Peter Banyard 2025-04-03 20:35:04 +01:00
parent 1dd788acdc
commit 8033b058a9
2 changed files with 3 additions and 6 deletions

View file

@ -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) 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; int size;
char *data; char data[FTP_BUFSIZE];
if (strpbrk(cmd, "\r\n")) { if (strpbrk(cmd, "\r\n")) {
return false; 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")) { if (strpbrk(args, "\r\n")) {
return 0; 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 { } else {
/* "cmd\r\n\0" */ /* "cmd\r\n\0" */
if (cmd_len + 3 > FTP_BUFSIZE) { if (cmd_len + 3 > FTP_BUFSIZE) {
return false; 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 */ /* Clear the inbuf and extra-lines buffer */
ftp->inbuf[0] = '\0'; ftp->inbuf[0] = '\0';
ftp->extra = NULL; ftp->extra = NULL;

View file

@ -60,7 +60,6 @@ typedef struct ftpbuf
char inbuf[FTP_BUFSIZE]; /* last response text */ char inbuf[FTP_BUFSIZE]; /* last response text */
char *extra; /* extra characters */ char *extra; /* extra characters */
int extralen; /* number of extra chars */ int extralen; /* number of extra chars */
char outbuf[FTP_BUFSIZE]; /* command output buffer */
char *pwd; /* cached pwd */ char *pwd; /* cached pwd */
char *syst; /* cached system type */ char *syst; /* cached system type */
ftptype_t type; /* current transfer type */ ftptype_t type; /* current transfer type */