Bug 1205533 - Fix and disallow warnings in gfx/qcms/. r=jrmuizel.

This patch fixes various warnings from MSVC.

- Several "truncation from 'double' to 'float'" warnings, easily fixed by
  appending 'f' to literals.

- Some "signed/unsigned mismatch" warnings. In read_tag_lutType(), MSVC is
  apparently promoting the multiplication of a uint8_t and a uint16_t to an
  int32_t, oddly enough. A uint32_t cast fixes the warning.

- |offset| was unused in qcms_data_create_rbg_with_gamma().

- A couple of "overflow in floating-point constant arithmetic" warnings
  involving INFINITY in transform_util.c. There is some type confusion here --
  in C99 HUGE_VAL is a double and INFINITY is a float. So the HUGE_VAL here
  should actualy be HUGE_VALF. But, strangely enough, that isn't enough to
  avoid the warning, I don't know why. However, it turns out that any
  non-positive value for |interval| will have the same effect, so I just
  removed all the INFINITY/HUGE_VAL stuff and used -1 instead.

It also fixes an ARM-only GCC warning.

- "'__force_align_arg_pointer__' attribute directive ignored". This is an
  x86-only attribute. Instead of disabling it on x86-64, instead enable it on
  i386 (which avoids enabling it uselessly on ARM).
This commit is contained in:
Nicholas Nethercote 2015-09-17 17:11:27 -07:00
parent ad0bf874cf
commit b0500a35e3
4 changed files with 18 additions and 27 deletions

View File

@ -312,17 +312,17 @@ qcms_bool qcms_profile_is_bogus(qcms_profile *profile)
sum[2] = rZ + gZ + bZ; sum[2] = rZ + gZ + bZ;
// Build our target vector (see mozilla bug 460629) // Build our target vector (see mozilla bug 460629)
target[0] = 0.96420; target[0] = 0.96420f;
target[1] = 1.00000; target[1] = 1.00000f;
target[2] = 0.82491; target[2] = 0.82491f;
// Our tolerance vector - Recommended by Chris Murphy based on // Our tolerance vector - Recommended by Chris Murphy based on
// conversion from the LAB space criterion of no more than 3 in any one // conversion from the LAB space criterion of no more than 3 in any one
// channel. This is similar to, but slightly more tolerant than Adobe's // channel. This is similar to, but slightly more tolerant than Adobe's
// criterion. // criterion.
tolerance[0] = 0.02; tolerance[0] = 0.02f;
tolerance[1] = 0.02; tolerance[1] = 0.02f;
tolerance[2] = 0.04; tolerance[2] = 0.04f;
// Compare with our tolerance // Compare with our tolerance
for (i = 0; i < 3; ++i) { for (i = 0; i < 3; ++i) {
@ -751,7 +751,7 @@ static struct lutType *read_tag_lutType(struct mem_source *src, struct tag_index
lut->e21 = read_s15Fixed16Number(src, offset+40); lut->e21 = read_s15Fixed16Number(src, offset+40);
lut->e22 = read_s15Fixed16Number(src, offset+44); lut->e22 = read_s15Fixed16Number(src, offset+44);
for (i = 0; i < lut->num_input_table_entries * in_chan; i++) { for (i = 0; i < (uint32_t)(lut->num_input_table_entries * in_chan); i++) {
if (type == LUT8_TYPE) { if (type == LUT8_TYPE) {
lut->input_table[i] = uInt8Number_to_float(read_uInt8Number(src, offset + 52 + i * entry_size)); lut->input_table[i] = uInt8Number_to_float(read_uInt8Number(src, offset + 52 + i * entry_size));
} else { } else {
@ -773,7 +773,7 @@ static struct lutType *read_tag_lutType(struct mem_source *src, struct tag_index
} }
output_offset = clut_offset + clut_size * out_chan * entry_size; output_offset = clut_offset + clut_size * out_chan * entry_size;
for (i = 0; i < lut->num_output_table_entries * out_chan; i++) { for (i = 0; i < (uint32_t)(lut->num_output_table_entries * out_chan); i++) {
if (type == LUT8_TYPE) { if (type == LUT8_TYPE) {
lut->output_table[i] = uInt8Number_to_float(read_uInt8Number(src, output_offset + i*entry_size)); lut->output_table[i] = uInt8Number_to_float(read_uInt8Number(src, output_offset + i*entry_size));
} else { } else {
@ -1310,7 +1310,7 @@ void qcms_data_from_unicode_path(const wchar_t *path, void **mem, size_t *size)
#define ICC_PROFILE_HEADER_LENGTH 128 #define ICC_PROFILE_HEADER_LENGTH 128
void qcms_data_create_rgb_with_gamma(qcms_CIE_xyY white_point, qcms_CIE_xyYTRIPLE primaries, float gamma, void **mem, size_t *size) void qcms_data_create_rgb_with_gamma(qcms_CIE_xyY white_point, qcms_CIE_xyYTRIPLE primaries, float gamma, void **mem, size_t *size)
{ {
uint32_t length, offset, index, xyz_count, trc_count; uint32_t length, index, xyz_count, trc_count;
size_t tag_table_offset, tag_data_offset; size_t tag_table_offset, tag_data_offset;
void *data; void *data;
struct matrix colorants; struct matrix colorants;

View File

@ -17,9 +17,6 @@ SOURCES += [
'transform_util.c', 'transform_util.c',
] ]
# XXX: We should fix these warnings.
ALLOW_COMPILER_WARNINGS = True
FINAL_LIBRARY = 'xul' FINAL_LIBRARY = 'xul'
if CONFIG['GNU_CC']: if CONFIG['GNU_CC']:

View File

@ -259,9 +259,9 @@ static struct matrix
adaption_matrix(struct CIE_XYZ source_illumination, struct CIE_XYZ target_illumination) adaption_matrix(struct CIE_XYZ source_illumination, struct CIE_XYZ target_illumination)
{ {
struct matrix lam_rigg = {{ // Bradford matrix struct matrix lam_rigg = {{ // Bradford matrix
{ 0.8951, 0.2664, -0.1614 }, { 0.8951f, 0.2664f, -0.1614f },
{ -0.7502, 1.7135, 0.0367 }, { -0.7502f, 1.7135f, 0.0367f },
{ 0.0389, -0.0685, 1.0296 } { 0.0389f, -0.0685f, 1.0296f }
}}; }};
return compute_chromatic_adaption(source_illumination, target_illumination, lam_rigg); return compute_chromatic_adaption(source_illumination, target_illumination, lam_rigg);
} }
@ -1394,7 +1394,7 @@ qcms_transform* qcms_transform_create(
return transform; return transform;
} }
#if defined(__GNUC__) && !defined(__x86_64__) && !defined(__amd64__) #if defined(__GNUC__) && defined(__i386__)
/* we need this to avoid crashes when gcc assumes the stack is 128bit aligned */ /* we need this to avoid crashes when gcc assumes the stack is 128bit aligned */
__attribute__((__force_align_arg_pointer__)) __attribute__((__force_align_arg_pointer__))
#endif #endif

View File

@ -1,5 +1,3 @@
#define _ISOC99_SOURCE /* for INFINITY */
#include <math.h> #include <math.h>
#include <assert.h> #include <assert.h>
#include <string.h> //memcpy #include <string.h> //memcpy
@ -7,10 +5,6 @@
#include "transform_util.h" #include "transform_util.h"
#include "matrix.h" #include "matrix.h"
#if !defined(INFINITY)
#define INFINITY HUGE_VAL
#endif
#define PARAMETRIC_CURVE_TYPE 0x70617261 //'para' #define PARAMETRIC_CURVE_TYPE 0x70617261 //'para'
/* value must be a value between 0 and 1 */ /* value must be a value between 0 and 1 */
@ -131,7 +125,7 @@ void compute_curve_gamma_table_type_parametric(float gamma_table[256], float par
c = 0; c = 0;
e = 0; e = 0;
f = 0; f = 0;
interval = -INFINITY; interval = -1;
} else if(count == 1) { } else if(count == 1) {
a = parameter[1]; a = parameter[1];
b = parameter[2]; b = parameter[2];
@ -167,12 +161,12 @@ void compute_curve_gamma_table_type_parametric(float gamma_table[256], float par
c = 0; c = 0;
e = 0; e = 0;
f = 0; f = 0;
interval = -INFINITY; interval = -1;
} }
for (X = 0; X < 256; X++) { for (X = 0; X < 256; X++) {
if (X >= interval) { if (X >= interval) {
// XXX The equations are not exactly as definied in the spec but are // XXX The equations are not exactly as defined in the spec but are
// algebraic equivilent. // algebraically equivalent.
// TODO Should division by 255 be for the whole expression. // TODO Should division by 255 be for the whole expression.
gamma_table[X] = clamp_float(pow(a * X / 255. + b, y) + c + e); gamma_table[X] = clamp_float(pow(a * X / 255. + b, y) + c + e);
} else { } else {