Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
f600524c
Commit
f600524c
authored
Apr 30, 2008
by
Matthias Braun
Browse files
avoid dangerous use of memcmp
[r19467]
parent
bc79a622
Changes
2
Hide whitespace changes
Inline
Side-by-side
ir/be/bearch_t.h
View file @
f600524c
...
...
@@ -33,6 +33,7 @@
#include
"bemachine.h"
#include
"beirg.h"
#include
"beabi.h"
#include
"raw_bitset.h"
/**
* A register.
...
...
@@ -139,6 +140,32 @@ struct arch_register_req_t {
(must_be_different) */
};
static
INLINE
int
reg_reqs_equal
(
const
arch_register_req_t
*
req1
,
const
arch_register_req_t
*
req2
)
{
if
(
req1
==
req2
)
return
1
;
if
(
req1
->
type
!=
req2
->
type
||
req1
->
cls
!=
req2
->
cls
||
req1
->
other_same
!=
req2
->
other_same
||
req1
->
other_different
!=
req2
->
other_different
)
return
0
;
if
(
req1
->
limited
!=
NULL
)
{
size_t
n_regs
;
if
(
req2
->
limited
==
NULL
)
return
0
;
n_regs
=
arch_register_class_n_regs
(
req1
->
cls
);
if
(
!
rbitset_equal
(
req1
->
limited
,
req2
->
limited
,
n_regs
))
return
0
;
}
return
1
;
}
/**
* An inverse operation returned by the backend
*/
...
...
ir/be/benode.c
View file @
f600524c
...
...
@@ -167,8 +167,8 @@ static int _node_cmp_attr(const be_node_attr_t *a, const be_node_attr_t *b) {
len
=
ARR_LEN
(
a
->
reg_data
);
for
(
i
=
0
;
i
<
len
;
++
i
)
{
if
(
a
->
reg_data
[
i
].
reg
!=
b
->
reg_data
[
i
].
reg
||
memcmp
(
&
a
->
reg_data
[
i
].
in_req
,
&
b
->
reg_data
[
i
].
in_req
,
sizeof
(
b
->
reg_data
[
i
].
in_req
)
)
||
memcmp
(
&
a
->
reg_data
[
i
].
req
,
&
b
->
reg_data
[
i
].
req
,
sizeof
(
a
->
reg_data
[
i
].
req
)
))
!
reg_reqs_equal
(
&
a
->
reg_data
[
i
].
in_req
,
&
b
->
reg_data
[
i
].
in_req
)
||
!
reg_reqs_equal
(
&
a
->
reg_data
[
i
].
req
,
&
b
->
reg_data
[
i
].
req
))
return
1
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment