From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Thu, 13 Dec 2012 14:12:31 +0100 Subject: [U-Boot] [PATCH 1/2] FAT: remove ifdefs to make the code more readable In-Reply-To: References: <50BE21CC.4030603@denx.de> <201212131346.32912.marex@denx.de> Message-ID: <201212131412.32065.marex@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Richard Genoud, > 2012/12/13 Marek Vasut : > > Dear Richard Genoud, > > > >> ifdefs in the code are making it harder to read. > >> The use of simple if(VFAT_ENABLED) makes no more code and is cleaner. > >> (the code is discarded by the compiler and linker instead of the > >> preprocessor.) > >> > >> and bonus, now the code compiles even if CONFIG_SUPPORT_VFAT is not > >> defined. > >> > >> Signed-off-by: Richard Genoud > >> --- > >> > >> fs/fat/fat.c | 55 > >> > >> +++++++++++++++++++++++++++------------------------ fs/fat/fat_write.c | > >> 11 ++------- > >> > >> 2 files changed, 32 insertions(+), 34 deletions(-) > >> > >> diff --git a/fs/fat/fat.c b/fs/fat/fat.c > >> index 393c378..c79e3e3 100644 > >> --- a/fs/fat/fat.c > >> +++ b/fs/fat/fat.c > >> @@ -34,6 +34,12 @@ > >> > >> #include > >> #include > >> > >> +#ifdef CONFIG_SUPPORT_VFAT > >> +#define VFAT_ENABLED 1 > >> +#else > >> +#define VFAT_ENABLED 0 > >> +#endif > > > > [...] > > > > Make it static const int maybe ? > > I hesitate to make them static const, I can't figure why it's better > to use static const variable instead of defines. > Could you enlighten me ? Because you get the type-checking. Preprocessor is evil ;-) Best regards, Marek Vasut