On 09/03/14 06:39, Scott Duplichan wrote:
> EDK2 builds with 'warning level 4' when using Microsoft tools. For the
> most part, that enables desirable warnings similar to those provided by
> gcc -Wall. There is one major difference though, Microsoft warning level
> 4 warns about the routine practice of assigning a larger size integer to
> a smaller size integer. The Microsoft warning looks like:
> 
> warning C4244: conversion from 'UINT32' to 'UINT8', possible loss of data
> 
> Gcc has a warning option that is similar to Microsoft C4244: -WConversion
> But the gcc option -Wall does _not_ enable -Wconversion. In fact, gcc
> option -Wextra doesn't even enable -Wconversion. That suggests that
> -Wconversion is a specialty warning not suitable for general use. EDK2
> gcc builds do not enable -Wconversion.
> 
> I think Microsoft warning C4244 (and similar) should be removed from
> EDK2 so that Microsoft warning settings are more consistent with gcc
> warning settings. But that might be a difficult change to push through.
> While it would be interesting to see what others think, completely
> removing Microsoft Warning C4244 is a discussion for another day.
> 
> The immediate problem should be a lot easier to get agreement on. The
> problem is that warning C4244 is buggy/imperfect in older Microsoft
> compilers (DDK3790, VS2003, VS2005). As a result, some builds fail
> with those compilers, but pass with newer ones. Here are examples:
> 
> OvmfPkg\Library\LoadLinuxLib\Linux.c(387)
> OvmfPkg\Library\LoadLinuxLib\Linux.c(388)
> OvmfPkg\VirtioBlkDxe\VirtioBlk.c(773)
> OvmfPkg\VirtioBlkDxe\VirtioBlk.c(774)
> OvmfPkg\VirtioNetDxe\DriverBinding.c(132)
> OvmfPkg\VirtioScsiDxe\VirtioScsi.c(751)
> StdLib\BsdSocketLib\res_mkupdate.c(186)
> 
> Here are code snippets that demonstrate the warning C4344 problem 
> with older Microsoft compilers:
> 
> #if defined (__GNUC__)
> #include <stdint.h>
> #else
> #define uint16_t unsigned __int16
> #define uint32_t unsigned __int32
> #define uint64_t unsigned __int64
> #endif
> char test1 (int x) {return !x;}
> char test2 (int x) {return x == 1;}
> char test3 (int x) {return x & 1;}
> uint32_t test4 (uint64_t x) {return x >> 32;}
> uint32_t test5 (uint64_t x) {return x && 0xFFFFFFFF;}

You wanted to write "&" rather than "&&", but this mistake only makes
your point more clear. :)

> enum {a=1, b=2}; uint16_t test6 (int x) {return x ? a : b;}
> 
> /*
>                             W A R N I N G   C O U N T S
> Tool chain               test1  test2  test3  test4  test5  test6
> DDK3790 /W4                1      1      1      1      0      1    
> VS2003  /W4                1      1      1      1      0      1
> VS2005  /W4                1      1      1      1      0      0
> VS2008  /W4                0      0      0      0      0      0
> VS2010  /W4                0      0      0      0      0      0
> VS2012  /W4                0      0      0      0      0      0
> VS2013  /W4                0      0      0      0      0      0
> 
> With VS2008 and newer, Microsoft compilers eliminate several
> causes of unwanted warnings.
> 
> If others agree, I can make a BaseTools\Conf\tools_def.template patch to
> disable warning C4244 for DDK3790, VS2003, and VS2005.

I'd appreciate if such a patch was applied.

Thanks
Laszlo


------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to