Fix problems discovered with gcc 4.9.1.

BUG=
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/538233002
This commit is contained in:
Mark Mentovai 2014-09-05 12:39:09 -04:00
parent 4f74716f6d
commit 35865a00d5
4 changed files with 24 additions and 5 deletions

View File

@ -362,7 +362,7 @@ void ExpectSeveralThreads(ThreadMap* thread_map,
thread.stack_region_address >= other_thread.stack_region_address && thread.stack_region_address >= other_thread.stack_region_address &&
thread.stack_region_address < other_thread_stack_region_end); thread.stack_region_address < other_thread_stack_region_end);
EXPECT_FALSE( EXPECT_FALSE(
thread_stack_region_end > other_thread.stack_region_address & thread_stack_region_end > other_thread.stack_region_address &&
thread_stack_region_end <= other_thread_stack_region_end); thread_stack_region_end <= other_thread_stack_region_end);
} }
} }

View File

@ -86,7 +86,11 @@ class InitializationState {
void set_state(State state) { state_ = state; } void set_state(State state) { state_ = state; }
private: private:
State state_; // state_ is volatile to ensure that itll be set by the destructor when it
// runs. Otherwise, optimizations might prevent it from ever being set to
// kStateDestroyed, limiting this class ability to catch use-after-free
// errors.
volatile State state_;
DISALLOW_COPY_AND_ASSIGN(InitializationState); DISALLOW_COPY_AND_ASSIGN(InitializationState);
}; };

View File

@ -164,15 +164,29 @@ class InitializationStateDcheck : public InitializationState {
// objects of the DCHECK_IS_ON InitializationStateDcheck class above. // objects of the DCHECK_IS_ON InitializationStateDcheck class above.
typedef bool InitializationStateDcheck[0]; typedef bool InitializationStateDcheck[0];
namespace internal {
// This function exists to make use of the InitializationStateDcheck object so
// that it appears to be used. It always returns true, so that it can be used
// as the argument to a no-op DCHECK.
inline bool EatInitializationState(const InitializationStateDcheck*) {
return true;
}
} // namepspace internal
// The contents of these DCHECKs will never be evaluated, but they make use of // The contents of these DCHECKs will never be evaluated, but they make use of
// initialization_state_dcheck to avoid triggering -Wunused-private-field // initialization_state_dcheck to avoid triggering -Wunused-private-field
// warnings. // warnings.
#define INITIALIZATION_STATE_SET_INITIALIZING(initialization_state_dcheck) \ #define INITIALIZATION_STATE_SET_INITIALIZING(initialization_state_dcheck) \
DCHECK(&(initialization_state_dcheck)) DCHECK(::crashpad::internal::EatInitializationState( \
&(initialization_state_dcheck)))
#define INITIALIZATION_STATE_SET_VALID(initialization_state_dcheck) \ #define INITIALIZATION_STATE_SET_VALID(initialization_state_dcheck) \
DCHECK(&(initialization_state_dcheck)) DCHECK(::crashpad::internal::EatInitializationState( \
&(initialization_state_dcheck)))
#define INITIALIZATION_STATE_DCHECK_VALID(initialization_state_dcheck) \ #define INITIALIZATION_STATE_DCHECK_VALID(initialization_state_dcheck) \
DCHECK(&(initialization_state_dcheck)) DCHECK(::crashpad::internal::EatInitializationState( \
&(initialization_state_dcheck)))
#endif #endif

View File

@ -17,6 +17,7 @@
#include <dirent.h> #include <dirent.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <limits.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>