summaryrefslogtreecommitdiff
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorLiming Gao <liming.gao@intel.com>2015-12-04 03:15:08 +0000
committerlgao4 <lgao4@Edk2>2015-12-04 03:15:08 +0000
commit4d454c54d1dbd92745b825d3156d8b4ced949461 (patch)
treee23fd9cec1f04851b607e6af66e6feee15dd7b26 /MdeModulePkg
parentd76946e328c51ab236de5d34edec774b0b01e4f5 (diff)
downloadedk2-4d454c54d1dbd92745b825d3156d8b4ced949461.zip
edk2-4d454c54d1dbd92745b825d3156d8b4ced949461.tar.gz
edk2-4d454c54d1dbd92745b825d3156d8b4ced949461.tar.bz2
MdeModulePkg: Fix VS2015 warning C4311 & C4312 in RegularExpressionDxe
warning C4311: pointer truncation from 'void *' to 'unsigned long' warning C4312: conversion from 'unsigned long' to 'void *' of greater size Update code to convert type to UINTN first, then convert it to other type. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Samer El-Haj-Mahmoud <samer.el-haj-mahmoud@hpe.com> Acked-by: Michael Kinney <michael.d.kinney@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19114 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/enc/unicode.c22
-rw-r--r--MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/regexec.c36
-rw-r--r--MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/regint.h4
-rw-r--r--MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/regparse.c16
4 files changed, 39 insertions, 39 deletions
diff --git a/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/enc/unicode.c b/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/enc/unicode.c
index 70a1a52..a906670 100644
--- a/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/enc/unicode.c
+++ b/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/enc/unicode.c
@@ -10920,12 +10920,12 @@ static int init_case_fold_table(void)
if (ONIG_IS_NULL(FoldTable)) return ONIGERR_MEMORY;
for (i = 0; i < (int )(sizeof(CaseFold)/sizeof(CaseFold_11_Type)); i++) {
p = &CaseFold[i];
- st_add_direct(FoldTable, (st_data_t )p->from, (st_data_t )&(p->to));
+ st_add_direct(FoldTable, (st_data_t )p->from, (st_data_t )(UINTN)&(p->to));
}
for (i = 0; i < (int )(sizeof(CaseFold_Locale)/sizeof(CaseFold_11_Type));
i++) {
p = &CaseFold_Locale[i];
- st_add_direct(FoldTable, (st_data_t )p->from, (st_data_t )&(p->to));
+ st_add_direct(FoldTable, (st_data_t )p->from, (st_data_t )(UINTN)&(p->to));
}
Unfold1Table = st_init_numtable_with_size(1000);
@@ -10934,13 +10934,13 @@ static int init_case_fold_table(void)
for (i = 0; i < (int )(sizeof(CaseUnfold_11)/sizeof(CaseUnfold_11_Type));
i++) {
p1 = &CaseUnfold_11[i];
- st_add_direct(Unfold1Table, (st_data_t )p1->from, (st_data_t )&(p1->to));
+ st_add_direct(Unfold1Table, (st_data_t )p1->from, (st_data_t )(UINTN)&(p1->to));
}
for (i = 0;
i < (int )(sizeof(CaseUnfold_11_Locale)/sizeof(CaseUnfold_11_Type));
i++) {
p1 = &CaseUnfold_11_Locale[i];
- st_add_direct(Unfold1Table, (st_data_t )p1->from, (st_data_t )&(p1->to));
+ st_add_direct(Unfold1Table, (st_data_t )p1->from, (st_data_t )(UINTN)&(p1->to));
}
Unfold2Table = st_init_table_with_size(&type_code2_hash, 200);
@@ -10949,13 +10949,13 @@ static int init_case_fold_table(void)
for (i = 0; i < (int )(sizeof(CaseUnfold_12)/sizeof(CaseUnfold_12_Type));
i++) {
p2 = &CaseUnfold_12[i];
- st_add_direct(Unfold2Table, (st_data_t )p2->from, (st_data_t )(&p2->to));
+ st_add_direct(Unfold2Table, (st_data_t )(UINTN)p2->from, (st_data_t )(UINTN)(&p2->to));
}
for (i = 0;
i < (int )(sizeof(CaseUnfold_12_Locale)/sizeof(CaseUnfold_12_Type));
i++) {
p2 = &CaseUnfold_12_Locale[i];
- st_add_direct(Unfold2Table, (st_data_t )p2->from, (st_data_t )(&p2->to));
+ st_add_direct(Unfold2Table, (st_data_t )(UINTN)p2->from, (st_data_t )(UINTN)(&p2->to));
}
Unfold3Table = st_init_table_with_size(&type_code3_hash, 30);
@@ -10964,7 +10964,7 @@ static int init_case_fold_table(void)
for (i = 0; i < (int )(sizeof(CaseUnfold_13)/sizeof(CaseUnfold_13_Type));
i++) {
p3 = &CaseUnfold_13[i];
- st_add_direct(Unfold3Table, (st_data_t )p3->from, (st_data_t )(&p3->to));
+ st_add_direct(Unfold3Table, (st_data_t )(UINTN)p3->from, (st_data_t )(UINTN)(&p3->to));
}
@@ -11265,7 +11265,7 @@ onigenc_unicode_get_case_fold_codes_by_str(OnigEncoding enc,
}
}
- if (onig_st_lookup(Unfold2Table, (st_data_t )to->code,
+ if (onig_st_lookup(Unfold2Table, (st_data_t )(UINTN)to->code,
(void* )&z2) != 0) {
for (i = 0; i < z2->n; i++) {
if (z2->code[i] == code) continue;
@@ -11291,7 +11291,7 @@ onigenc_unicode_get_case_fold_codes_by_str(OnigEncoding enc,
}
}
- if (onig_st_lookup(Unfold3Table, (st_data_t )to->code,
+ if (onig_st_lookup(Unfold3Table, (st_data_t )(UINTN)to->code,
(void* )&z2) != 0) {
for (i = 0; i < z2->n; i++) {
if (z2->code[i] == code) continue;
@@ -11336,7 +11336,7 @@ onigenc_unicode_get_case_fold_codes_by_str(OnigEncoding enc,
clen = enclen(enc, p);
len += clen;
- if (onig_st_lookup(Unfold2Table, (st_data_t )codes, (void* )&z2) != 0) {
+ if (onig_st_lookup(Unfold2Table, (st_data_t )(UINTN)codes, (void* )&z2) != 0) {
for (i = 0; i < z2->n; i++) {
items[n].byte_len = len;
items[n].code_len = 1;
@@ -11357,7 +11357,7 @@ onigenc_unicode_get_case_fold_codes_by_str(OnigEncoding enc,
clen = enclen(enc, p);
len += clen;
- if (onig_st_lookup(Unfold3Table, (st_data_t )codes,
+ if (onig_st_lookup(Unfold3Table, (st_data_t )(UINTN)codes,
(void* )&z2) != 0) {
for (i = 0; i < z2->n; i++) {
items[n].byte_len = len;
diff --git a/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/regexec.c b/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/regexec.c
index 5e3ffa1..160c995 100644
--- a/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/regexec.c
+++ b/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/regexec.c
@@ -863,7 +863,7 @@ stack_double(OnigStackType** arg_stk_base, OnigStackType** arg_stk_end,
if (BIT_STATUS_AT(reg->bt_mem_end, k->u.mem.num))\
endp = STACK_AT(k->u.mem.end)->u.mem.pstr;\
else\
- endp = (UChar* )k->u.mem.end;\
+ endp = (UChar* )(UINTN)k->u.mem.end;\
if (STACK_AT(k->u.mem.start)->u.mem.pstr != endp) {\
(isnull) = 0; break;\
}\
@@ -904,7 +904,7 @@ stack_double(OnigStackType** arg_stk_base, OnigStackType** arg_stk_end,
if (BIT_STATUS_AT(reg->bt_mem_end, k->u.mem.num))\
endp = STACK_AT(k->u.mem.end)->u.mem.pstr;\
else\
- endp = (UChar* )k->u.mem.end;\
+ endp = (UChar* )(UINTN)k->u.mem.end;\
if (STACK_AT(k->u.mem.start)->u.mem.pstr != endp) {\
(isnull) = 0; break;\
}\
@@ -1344,11 +1344,11 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
if (BIT_STATUS_AT(reg->bt_mem_start, i))
rmt[i].rm_so = (regoff_t)(STACK_AT(mem_start_stk[i])->u.mem.pstr - str);
else
- rmt[i].rm_so = (regoff_t)((UChar* )((void* )(mem_start_stk[i])) - str);
+ rmt[i].rm_so = (regoff_t)((UChar* )((void* )(UINTN)(mem_start_stk[i])) - str);
rmt[i].rm_eo = (regoff_t)((BIT_STATUS_AT(reg->bt_mem_end, i)
? STACK_AT(mem_end_stk[i])->u.mem.pstr
- : (UChar* )((void* )mem_end_stk[i])) - str);
+ : (UChar* )((void* )(UINTN)mem_end_stk[i])) - str);
}
else {
rmt[i].rm_so = rmt[i].rm_eo = ONIG_REGION_NOTPOS;
@@ -1364,11 +1364,11 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
if (BIT_STATUS_AT(reg->bt_mem_start, i))
region->beg[i] = (int)(STACK_AT(mem_start_stk[i])->u.mem.pstr - str);
else
- region->beg[i] = (int)((UChar* )((void* )mem_start_stk[i]) - str);
+ region->beg[i] = (int)((UChar* )((void* )(UINTN)mem_start_stk[i]) - str);
region->end[i] = (int)((BIT_STATUS_AT(reg->bt_mem_end, i)
? STACK_AT(mem_end_stk[i])->u.mem.pstr
- : (UChar* )((void* )mem_end_stk[i])) - str);
+ : (UChar* )((void* )(UINTN)mem_end_stk[i])) - str);
}
else {
region->beg[i] = region->end[i] = ONIG_REGION_NOTPOS;
@@ -2082,7 +2082,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
case OP_MEMORY_START: MOP_IN(OP_MEMORY_START);
GET_MEMNUM_INC(mem, p);
- mem_start_stk[mem] = (OnigStackIndex )((void* )s);
+ mem_start_stk[mem] = (OnigStackIndex )(UINTN)((void* )s);
MOP_OUT;
continue;
break;
@@ -2096,7 +2096,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
case OP_MEMORY_END: MOP_IN(OP_MEMORY_END);
GET_MEMNUM_INC(mem, p);
- mem_end_stk[mem] = (OnigStackIndex )((void* )s);
+ mem_end_stk[mem] = (OnigStackIndex )(UINTN)((void* )s);
MOP_OUT;
continue;
break;
@@ -2113,13 +2113,13 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
case OP_MEMORY_END_REC: MOP_IN(OP_MEMORY_END_REC);
GET_MEMNUM_INC(mem, p);
- mem_end_stk[mem] = (OnigStackIndex )((void* )s);
+ mem_end_stk[mem] = (OnigStackIndex )(UINTN)((void* )s);
STACK_GET_MEM_START(mem, stkp);
if (BIT_STATUS_AT(reg->bt_mem_start, mem))
mem_start_stk[mem] = GET_STACK_INDEX(stkp);
else
- mem_start_stk[mem] = (OnigStackIndex )((void* )stkp->u.mem.pstr);
+ mem_start_stk[mem] = (OnigStackIndex )(UINTN)((void* )stkp->u.mem.pstr);
STACK_PUSH_MEM_END_MARK(mem);
MOP_OUT;
@@ -2153,11 +2153,11 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
if (BIT_STATUS_AT(reg->bt_mem_start, mem))
pstart = STACK_AT(mem_start_stk[mem])->u.mem.pstr;
else
- pstart = (UChar* )((void* )mem_start_stk[mem]);
+ pstart = (UChar* )((void* )(UINTN)mem_start_stk[mem]);
pend = (BIT_STATUS_AT(reg->bt_mem_end, mem)
? STACK_AT(mem_end_stk[mem])->u.mem.pstr
- : (UChar* )((void* )mem_end_stk[mem]));
+ : (UChar* )((void* )(UINTN)mem_end_stk[mem]));
n = (int)(pend - pstart);
DATA_ENSURE(n);
sprev = s;
@@ -2185,11 +2185,11 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
if (BIT_STATUS_AT(reg->bt_mem_start, mem))
pstart = STACK_AT(mem_start_stk[mem])->u.mem.pstr;
else
- pstart = (UChar* )((void* )mem_start_stk[mem]);
+ pstart = (UChar* )((void* )(UINTN)mem_start_stk[mem]);
pend = (BIT_STATUS_AT(reg->bt_mem_end, mem)
? STACK_AT(mem_end_stk[mem])->u.mem.pstr
- : (UChar* )((void* )mem_end_stk[mem]));
+ : (UChar* )((void* )(UINTN)mem_end_stk[mem]));
n = (int)(pend - pstart);
DATA_ENSURE(n);
sprev = s;
@@ -2217,11 +2217,11 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
if (BIT_STATUS_AT(reg->bt_mem_start, mem))
pstart = STACK_AT(mem_start_stk[mem])->u.mem.pstr;
else
- pstart = (UChar* )((void* )mem_start_stk[mem]);
+ pstart = (UChar* )((void* )(UINTN)mem_start_stk[mem]);
pend = (BIT_STATUS_AT(reg->bt_mem_end, mem)
? STACK_AT(mem_end_stk[mem])->u.mem.pstr
- : (UChar* )((void* )mem_end_stk[mem]));
+ : (UChar* )((void* )(UINTN)mem_end_stk[mem]));
n = (int)(pend - pstart);
DATA_ENSURE(n);
sprev = s;
@@ -2256,11 +2256,11 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
if (BIT_STATUS_AT(reg->bt_mem_start, mem))
pstart = STACK_AT(mem_start_stk[mem])->u.mem.pstr;
else
- pstart = (UChar* )((void* )mem_start_stk[mem]);
+ pstart = (UChar* )((void* )(UINTN)mem_start_stk[mem]);
pend = (BIT_STATUS_AT(reg->bt_mem_end, mem)
? STACK_AT(mem_end_stk[mem])->u.mem.pstr
- : (UChar* )((void* )mem_end_stk[mem]));
+ : (UChar* )((void* )(UINTN)mem_end_stk[mem]));
n = (int)(pend - pstart);
DATA_ENSURE(n);
sprev = s;
diff --git a/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/regint.h b/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/regint.h
index 44589bf..f48c557 100644
--- a/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/regint.h
+++ b/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/regint.h
@@ -233,13 +233,13 @@
#define GET_ALIGNMENT_PAD_SIZE(addr,pad_size) do {\
(pad_size) = WORD_ALIGNMENT_SIZE \
- - ((unsigned int )(addr) % WORD_ALIGNMENT_SIZE);\
+ - ((unsigned int )(UINTN)(addr) % WORD_ALIGNMENT_SIZE);\
if ((pad_size) == WORD_ALIGNMENT_SIZE) (pad_size) = 0;\
} while (0)
#define ALIGNMENT_RIGHT(addr) do {\
(addr) += (WORD_ALIGNMENT_SIZE - 1);\
- (addr) -= ((unsigned int )(addr) % WORD_ALIGNMENT_SIZE);\
+ (addr) -= ((unsigned int )(UINTN)(addr) % WORD_ALIGNMENT_SIZE);\
} while (0)
#endif /* PLATFORM_UNALIGNED_WORD_ACCESS */
diff --git a/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/regparse.c b/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/regparse.c
index 01ac2b3..4be2f22 100644
--- a/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/regparse.c
+++ b/MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/regparse.c
@@ -369,7 +369,7 @@ onig_st_lookup_strend(hash_table_type* table, const UChar* str_key,
key.s = (UChar* )str_key;
key.end = (UChar* )end_key;
- return onig_st_lookup(table, (st_data_t )(&key), value);
+ return onig_st_lookup(table, (st_data_t )(UINTN)(&key), value);
}
extern int
@@ -382,7 +382,7 @@ onig_st_insert_strend(hash_table_type* table, const UChar* str_key,
key = (st_str_end_key* )xmalloc(sizeof(st_str_end_key));
key->s = (UChar* )str_key;
key->end = (UChar* )end_key;
- result = onig_st_insert(table, (st_data_t )key, value);
+ result = onig_st_insert(table, (st_data_t )(UINTN)key, value);
if (result) {
xfree(key);
}
@@ -534,7 +534,7 @@ onig_foreach_name(regex_t* reg,
narg.reg = reg;
narg.arg = arg;
narg.enc = reg->enc; /* should be pattern encoding. */
- onig_st_foreach(t, i_names, (HashDataType )&narg);
+ onig_st_foreach(t, i_names, (HashDataType )(UINTN)&narg);
}
return narg.ret;
}
@@ -562,7 +562,7 @@ onig_renumber_name_table(regex_t* reg, GroupNumRemap* map)
NameTable* t = (NameTable* )reg->name_table;
if (IS_NOT_NULL(t)) {
- onig_st_foreach(t, i_renumber_name, (HashDataType )map);
+ onig_st_foreach(t, i_renumber_name, (HashDataType )(UINTN)map);
}
return 0;
}
@@ -742,7 +742,7 @@ name_add(regex_t* reg, UChar* name, UChar* name_end, int backref, ScanEnv* env)
xfree(e); return ONIGERR_MEMORY;
}
onig_st_insert_strend(t, e->name, (e->name + (name_end - name)),
- (HashDataType )e);
+ (HashDataType )(UINTN)e);
e->name_len = (int)(name_end - name);
e->back_num = 0;
@@ -5217,7 +5217,7 @@ parse_exp(Node** np, OnigToken* tok, int term,
}
}
else {
- if (onig_st_lookup(OnigTypeCClassTable, (st_data_t )&key,
+ if (onig_st_lookup(OnigTypeCClassTable, (st_data_t )(UINTN)&key,
(st_data_t* )np)) {
THREAD_ATOMIC_END;
break;
@@ -5235,8 +5235,8 @@ parse_exp(Node** np, OnigToken* tok, int term,
NCCLASS_SET_SHARE(cc);
new_key = (type_cclass_key* )xmalloc(sizeof(type_cclass_key));
xmemcpy(new_key, &key, sizeof(type_cclass_key));
- onig_st_add_direct(OnigTypeCClassTable, (st_data_t )new_key,
- (st_data_t )*np);
+ onig_st_add_direct(OnigTypeCClassTable, (st_data_t )(UINTN)new_key,
+ (st_data_t )(UINTN)*np);
THREAD_ATOMIC_END;
}