Skip to content

Commit 6e011e3

Browse files
committed
fix: FF_MAX_LFN collides with the fatfs macro of the same name
fatfs defines FF_MAX_LFN from CONFIG_FATFS_MAX_LFN. FtpServer.h defined it unconditionally and first, so a translation unit reaching both headers took a redefinition warning that no -Wno- suppresses. The FTP limit is FTP_MAX_LFN; the three sizes derived from it keep their values, and FTP_LEGACY_FF_MAX_LFN brings the old name back for a sketch that spells it.
1 parent db5a13d commit 6e011e3

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

FtpServer.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,18 @@
497497
#define FTP_DATA_PORT_DFLT 20 // Default data port in active mode
498498
#define FTP_DATA_PORT_PASV 50009 // Data port in passive mode
499499

500-
#define FF_MAX_LFN 255 // max size of a long file name
501-
#define FTP_CMD_SIZE FF_MAX_LFN+8 // max size of a command
502-
#define FTP_CWD_SIZE FF_MAX_LFN+8 // max size of a directory name
503-
#define FTP_FIL_SIZE FF_MAX_LFN // max size of a file name
500+
// fatfs owns the name FF_MAX_LFN and defines it from CONFIG_FATFS_MAX_LFN, so a translation
501+
// unit that reaches both headers takes a redefinition warning. FTP_LEGACY_FF_MAX_LFN restores
502+
// the old name for a sketch that spells it and never reaches fatfs.
503+
#ifdef FTP_LEGACY_FF_MAX_LFN
504+
# define FF_MAX_LFN 255
505+
# define FTP_MAX_LFN FF_MAX_LFN
506+
#else
507+
# define FTP_MAX_LFN 255 // max size of a long file name
508+
#endif
509+
#define FTP_CMD_SIZE FTP_MAX_LFN+8 // max size of a command
510+
#define FTP_CWD_SIZE FTP_MAX_LFN+8 // max size of a directory name
511+
#define FTP_FIL_SIZE FTP_MAX_LFN // max size of a file name
504512
#define FTP_CRED_SIZE 16 // max size of username and password
505513
// One rendered listing entry: the two names at the limits above, the widest a long prints,
506514
// the date makeDateTimeStrList() builds in its own char[25], the "Type=…;Size=…; " prefix,

0 commit comments

Comments
 (0)