[PATCH] no config file overwrite for dpkg

Denys Vlasenko vda.linux at googlemail.com
Sun Feb 21 12:28:28 UTC 2010


On Friday 19 February 2010 15:32, Rob Landley wrote:
> All modern compilers (and most obsolete ones) do simple dead code elimination, 
> where:
> 
>    if (0) {
>     code code code
>   }
> 
> Gets eliminated just like this would:
> 
>   #if 0
>     code code code
>   #endif
> 
> It also works the other way:
> 
>   if (1) {
>     code code code
>   }

In console-tools/loadfont.c, we now have this:

#if !ENABLE_FEATURE_LOADFONT_PSF2
#define do_loadtable(fd, inbuf, tailsz, fontsize, psf2) \
        do_loadtable(fd, inbuf, tailsz, fontsize)
#endif
static void do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize, int psf2)
{
#if !ENABLE_FEATURE_LOADFONT_PSF2
/* gcc 4.3.1 code size: */
# define psf2 0 /* +0 bytes */
//      const int psf2 = 0; /* +8 bytes */
//      enum { psf2 = 0 }; /* +13 bytes */
#endif

Theretically, both #ifs are not necessary - compiler is able to deduce that
psf2 is 0 if !ENABLE_FEATURE_LOADFONT_PSF2.

Or rather, it is SUPPOSED TO be able to deduce it.
I definitely see that gcc 4.3.1 is not really able to do it.

The second #if is even more funny. literal 0, "const int" 0 and enum 0
should be the same, right? Well, they are not.

Basically, compilers are not as good as we'd want them to be,
however they do gradually get better.
-- 
vda


More information about the busybox mailing list