Fix undefined-shift UBSAN errors
The expression "1 << 31" will cause UBSAN to complain with this error message: runtime error: left shift of 1 by 31 places cannot be represented in type 'int' The same operation on unsigned types is fine, however. This CL replaces the strings "1 <<" with "1U <<".
This commit is contained in:
parent
a8a6efa805
commit
c60ed9ef66
|
@ -254,7 +254,7 @@ static int compare (const void *a, const void *b)
|
||||||
#define MAX_LANG 1024
|
#define MAX_LANG 1024
|
||||||
#define MAX_LANG_SET_MAP ((MAX_LANG + 31) / 32)
|
#define MAX_LANG_SET_MAP ((MAX_LANG + 31) / 32)
|
||||||
|
|
||||||
#define BitSet(map, i) ((map)[(entries[i].id)>>5] |= ((FcChar32) 1 << ((entries[i].id) & 0x1f)))
|
#define BitSet(map, i) ((map)[(entries[i].id)>>5] |= ((FcChar32) 1U << ((entries[i].id) & 0x1f)))
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc FC_UNUSED, char **argv)
|
main (int argc FC_UNUSED, char **argv)
|
||||||
|
|
|
@ -1290,9 +1290,9 @@ FcFreeTypeQueryFaceInternal (const FT_Face face,
|
||||||
|
|
||||||
for (i = 0; i < master->num_axis; i++)
|
for (i = 0; i < master->num_axis; i++)
|
||||||
{
|
{
|
||||||
double min_value = master->axis[i].minimum / (double) (1 << 16);
|
double min_value = master->axis[i].minimum / (double) (1U << 16);
|
||||||
double def_value = master->axis[i].def / (double) (1 << 16);
|
double def_value = master->axis[i].def / (double) (1U << 16);
|
||||||
double max_value = master->axis[i].maximum / (double) (1 << 16);
|
double max_value = master->axis[i].maximum / (double) (1U << 16);
|
||||||
const char *elt = NULL;
|
const char *elt = NULL;
|
||||||
|
|
||||||
if (min_value > def_value || def_value > max_value || min_value == max_value)
|
if (min_value > def_value || def_value > max_value || min_value == max_value)
|
||||||
|
@ -1349,8 +1349,8 @@ FcFreeTypeQueryFaceInternal (const FT_Face face,
|
||||||
|
|
||||||
for (i = 0; i < master->num_axis; i++)
|
for (i = 0; i < master->num_axis; i++)
|
||||||
{
|
{
|
||||||
double value = instance->coords[i] / (double) (1 << 16);
|
double value = instance->coords[i] / (double) (1U << 16);
|
||||||
double default_value = master->axis[i].def / (double) (1 << 16);
|
double default_value = master->axis[i].def / (double) (1U << 16);
|
||||||
double mult = default_value ? value / default_value : 1;
|
double mult = default_value ? value / default_value : 1;
|
||||||
//printf ("named-instance, axis %d tag %lx value %g\n", i, master->axis[i].tag, value);
|
//printf ("named-instance, axis %d tag %lx value %g\n", i, master->axis[i].tag, value);
|
||||||
switch (master->axis[i].tag)
|
switch (master->axis[i].tag)
|
||||||
|
|
|
@ -242,7 +242,7 @@ typedef enum _FcOp {
|
||||||
} FcOp;
|
} FcOp;
|
||||||
|
|
||||||
typedef enum _FcOpFlags {
|
typedef enum _FcOpFlags {
|
||||||
FcOpFlagIgnoreBlanks = 1 << 0
|
FcOpFlagIgnoreBlanks = 1U << 0
|
||||||
} FcOpFlags;
|
} FcOpFlags;
|
||||||
|
|
||||||
#define FC_OP_GET_OP(_x_) ((_x_) & 0xffff)
|
#define FC_OP_GET_OP(_x_) ((_x_) & 0xffff)
|
||||||
|
|
10
src/fclang.c
10
src/fclang.c
|
@ -59,7 +59,7 @@ FcLangSetBitSet (FcLangSet *ls,
|
||||||
if (bucket >= ls->map_size)
|
if (bucket >= ls->map_size)
|
||||||
return; /* shouldn't happen really */
|
return; /* shouldn't happen really */
|
||||||
|
|
||||||
ls->map[bucket] |= ((FcChar32) 1 << (id & 0x1f));
|
ls->map[bucket] |= ((FcChar32) 1U << (id & 0x1f));
|
||||||
}
|
}
|
||||||
|
|
||||||
static FcBool
|
static FcBool
|
||||||
|
@ -87,7 +87,7 @@ FcLangSetBitReset (FcLangSet *ls,
|
||||||
if (bucket >= ls->map_size)
|
if (bucket >= ls->map_size)
|
||||||
return; /* shouldn't happen really */
|
return; /* shouldn't happen really */
|
||||||
|
|
||||||
ls->map[bucket] &= ~((FcChar32) 1 << (id & 0x1f));
|
ls->map[bucket] &= ~((FcChar32) 1U << (id & 0x1f));
|
||||||
}
|
}
|
||||||
|
|
||||||
FcLangSet *
|
FcLangSet *
|
||||||
|
@ -157,7 +157,7 @@ FcFreeTypeLangSet (const FcCharSet *charset,
|
||||||
if (map[i])
|
if (map[i])
|
||||||
{
|
{
|
||||||
for (j = 0; j < 32; j++)
|
for (j = 0; j < 32; j++)
|
||||||
if (map[i] & (1 << j))
|
if (map[i] & (1U << j))
|
||||||
printf (" %04x", ucs4 + i * 32 + j);
|
printf (" %04x", ucs4 + i * 32 + j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -848,7 +848,7 @@ FcNameUnparseLangSet (FcStrBuf *buf, const FcLangSet *ls)
|
||||||
if ((bits = ls->map[i]))
|
if ((bits = ls->map[i]))
|
||||||
{
|
{
|
||||||
for (bit = 0; bit <= 31; bit++)
|
for (bit = 0; bit <= 31; bit++)
|
||||||
if (bits & (1 << bit))
|
if (bits & (1U << bit))
|
||||||
{
|
{
|
||||||
int id = (i << 5) | bit;
|
int id = (i << 5) | bit;
|
||||||
if (!first)
|
if (!first)
|
||||||
|
@ -982,7 +982,7 @@ FcLangSetContains (const FcLangSet *lsa, const FcLangSet *lsb)
|
||||||
if (missing)
|
if (missing)
|
||||||
{
|
{
|
||||||
for (j = 0; j < 32; j++)
|
for (j = 0; j < 32; j++)
|
||||||
if (missing & (1 << j))
|
if (missing & (1U << j))
|
||||||
{
|
{
|
||||||
if (!FcLangSetContainsLang (lsa,
|
if (!FcLangSetContainsLang (lsa,
|
||||||
fcLangCharSets[fcLangCharSetIndicesInv[i*32 + j]].lang))
|
fcLangCharSets[fcLangCharSetIndicesInv[i*32 + j]].lang))
|
||||||
|
|
Loading…
Reference in New Issue