summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2015-02-11 10:23:23 -0500
committerAndreas Hansson <andreas.hansson@arm.com>2015-02-11 10:23:23 -0500
commitc9b8616c515f7689baf0706a9c17d3f9d625ef04 (patch)
treec4fff2a4328144c81860d92080c7a5a22f39d136 /src
parent431a6d708b4346ec81bade79033cc34308a5144f (diff)
downloadgem5-c9b8616c515f7689baf0706a9c17d3f9d625ef04.tar.xz
base: Do not dereference NULL in CompoundFlag creation
This patch fixes the CompoundFlag constructor, ensuring that it does not dereference NULL. Doing so has undefined behaviuor, and both clang and gcc's undefined-behaviour sanitiser was rather unhappy.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/SConscript4
-rw-r--r--src/base/debug.hh26
2 files changed, 15 insertions, 15 deletions
diff --git a/src/SConscript b/src/SConscript
index f85ed7a62..cffc4d157 100755
--- a/src/SConscript
+++ b/src/SConscript
@@ -852,9 +852,9 @@ namespace Debug {
last = len(compound) - 1
for i,flag in enumerate(compound):
if i != last:
- comp_code('$flag,')
+ comp_code('&$flag,')
else:
- comp_code('$flag);')
+ comp_code('&$flag);')
comp_code.dedent()
code.append(comp_code)
diff --git a/src/base/debug.hh b/src/base/debug.hh
index 20bf8e76d..5a03574f1 100644
--- a/src/base/debug.hh
+++ b/src/base/debug.hh
@@ -81,24 +81,24 @@ class CompoundFlag : public SimpleFlag
{
protected:
void
- addFlag(Flag &f)
+ addFlag(Flag *f)
{
- if (&f != NULL)
- _kids.push_back(&f);
+ if (f != nullptr)
+ _kids.push_back(f);
}
public:
CompoundFlag(const char *name, const char *desc,
- Flag &f00 = *(Flag *)0, Flag &f01 = *(Flag *)0,
- Flag &f02 = *(Flag *)0, Flag &f03 = *(Flag *)0,
- Flag &f04 = *(Flag *)0, Flag &f05 = *(Flag *)0,
- Flag &f06 = *(Flag *)0, Flag &f07 = *(Flag *)0,
- Flag &f08 = *(Flag *)0, Flag &f09 = *(Flag *)0,
- Flag &f10 = *(Flag *)0, Flag &f11 = *(Flag *)0,
- Flag &f12 = *(Flag *)0, Flag &f13 = *(Flag *)0,
- Flag &f14 = *(Flag *)0, Flag &f15 = *(Flag *)0,
- Flag &f16 = *(Flag *)0, Flag &f17 = *(Flag *)0,
- Flag &f18 = *(Flag *)0, Flag &f19 = *(Flag *)0)
+ Flag *f00 = nullptr, Flag *f01 = nullptr,
+ Flag *f02 = nullptr, Flag *f03 = nullptr,
+ Flag *f04 = nullptr, Flag *f05 = nullptr,
+ Flag *f06 = nullptr, Flag *f07 = nullptr,
+ Flag *f08 = nullptr, Flag *f09 = nullptr,
+ Flag *f10 = nullptr, Flag *f11 = nullptr,
+ Flag *f12 = nullptr, Flag *f13 = nullptr,
+ Flag *f14 = nullptr, Flag *f15 = nullptr,
+ Flag *f16 = nullptr, Flag *f17 = nullptr,
+ Flag *f18 = nullptr, Flag *f19 = nullptr)
: SimpleFlag(name, desc)
{
addFlag(f00); addFlag(f01); addFlag(f02); addFlag(f03); addFlag(f04);