Re: d3d8: Adjust D3DCOLOR_ARGB to avoid shift overflow.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Am 2015-09-13 um 22:56 schrieb Gerald Pfeifer:
-#define D3DCOLOR_ARGB(a,r,g,b) ((D3DCOLOR)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff))) +#define D3DCOLOR_ARGB(a,r,g,b) ((D3DCOLOR)((((a)&0xffu)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff))) Wouldn't it make sense to make the masks for the other channels unsigned too?
Are there any possible side effects when compiling code with winelib? The native header uses a signed 0xff. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJV9o1AAAoJEN0/YqbEcdMwVwUP/3G2g6LM41sKgJt3/mxlhkQ4 BdxJ+Oj2Sz1FdefWNzohcRGI5V8AaRSfoCyCQCvSvFRUm72VY9aMKvK3Nhg7gku0 OmP9z81GEDIb13eLNGrcGNmU97wsqk69MtahHFZ3tj8gYLEWVW3sZPwU64VOa89g 7eLLrx5xXGAhoyzN/q85rV7oGj6xmCzv8YKzasv7BAQIdARVwoSVzmyH2kqbuJFf ENVHyoPSJpphYBc4vxSOLVelgVCGEeAdAECnaGpGG+UfT8Sha3GTFu5q6Nn8P9Gx 3irwIPv7nfgqgdBFDRZUOuck/P5mirM9K3YQLB5309usVh7czusvR6LRWR7g5/gD aCf3fub02sfVe0+Sl2NBMfjF361qaOcMpv63e6+QGToKRIXSE9Ht/v4oUeblNi+h H6K/ljyv/kXr9mDUQBRbRUFlcKtp9Cm49xHAK7cT2xDrIj9z18mExKeARz+V1hiF Fs9W/sJao6F+LN9p1XpdZ+Ha10zvFUrsF3OPj09nyv/C+lXdIt5WgFIiI6gzsD/Z +vKFEoiYWnea9xBO9hUprnr4HTNlCMCZroQrvgeJm3xVxhcZZ9d7XQk7Q+oS1UlU S1g4FJL/Ea8EPNW5bq35F9x50azgZVKmdgIDe1ZtogDF+tgGwuuHN5DiqHAhU2cM deINoftjzz/ztYWqm2Yh =kZgE -----END PGP SIGNATURE-----
On Mon, 14 Sep 2015, Stefan Dösinger wrote:
Am 2015-09-13 um 22:56 schrieb Gerald Pfeifer:
-#define D3DCOLOR_ARGB(a,r,g,b) ((D3DCOLOR)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff))) +#define D3DCOLOR_ARGB(a,r,g,b) ((D3DCOLOR)((((a)&0xffu)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff))) Wouldn't it make sense to make the masks for the other channels unsigned too?
We could make all unsigned. The problem here only is with the first since the <<24 may lead to an overflow of signed, but you have a good point that consistency may be better. I'll submit a patch shortly.
Are there any possible side effects when compiling code with winelib? The native header uses a signed 0xff.
I can't think of one, since the & and | operators are bitwise, as is the shift. Thanks for the feedback, and sorry for the slow response now. Gerald
participants (2)
-
Gerald Pfeifer -
Stefan Dösinger