Commit 8392079c authored by thakis@chromium.org's avatar thakis@chromium.org

clang/win: Fix a few warnings.

__THROW is not some magical thing, don't pretend it is. Don't add it to
extern "C" functions. Replace it with "throw ()" on the functions where it's
correct since it was defined to nothing on windows (the only place where this
file is used).

Fix an inconsequential enum constant mix-up in media (both enum constants
evaluated to the same value, and the enums had the same size, so it shouldn't
make a difference in practice, but the old code was comparing enum variables
with enum constants from a different enum).

BUG=82385
TBR=dalecurtis

Review URL: https://codereview.chromium.org/419323002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285838 0039d316-1c4b-4281-b951-d872f2087c98
parent 8d88980e
...@@ -16,13 +16,6 @@ ...@@ -16,13 +16,6 @@
// TODO(mbelshe): Ensure that all calls to tcmalloc have the proper call depth // TODO(mbelshe): Ensure that all calls to tcmalloc have the proper call depth
// from the "user code" so that debugging tools (HeapChecker) can work. // from the "user code" so that debugging tools (HeapChecker) can work.
// __THROW is defined in glibc systems. It means, counter-intuitively,
// "This function will never throw an exception." It's an optional
// optimization tool, but we may need to use it to match glibc prototypes.
#ifndef __THROW // I guess we're not on a glibc system
# define __THROW // __THROW is just an optimization, so ok to make it ""
#endif
// new_mode behaves similarly to MSVC's _set_new_mode. // new_mode behaves similarly to MSVC's _set_new_mode.
// If flag is 0 (default), calls to malloc will behave normally. // If flag is 0 (default), calls to malloc will behave normally.
// If flag is 1, calls to malloc will behave like calls to new, // If flag is 1, calls to malloc will behave like calls to new,
...@@ -102,7 +95,7 @@ inline bool call_new_handler(bool nothrow) { ...@@ -102,7 +95,7 @@ inline bool call_new_handler(bool nothrow) {
} }
extern "C" { extern "C" {
void* malloc(size_t size) __THROW { void* malloc(size_t size) {
void* ptr; void* ptr;
for (;;) { for (;;) {
switch (allocator) { switch (allocator) {
...@@ -124,7 +117,7 @@ void* malloc(size_t size) __THROW { ...@@ -124,7 +117,7 @@ void* malloc(size_t size) __THROW {
return ptr; return ptr;
} }
void free(void* p) __THROW { void free(void* p) {
switch (allocator) { switch (allocator) {
case WINHEAP: case WINHEAP:
case WINLFH: case WINLFH:
...@@ -136,7 +129,7 @@ void free(void* p) __THROW { ...@@ -136,7 +129,7 @@ void free(void* p) __THROW {
} }
} }
void* realloc(void* ptr, size_t size) __THROW { void* realloc(void* ptr, size_t size) {
// Webkit is brittle for allocators that return NULL for malloc(0). The // Webkit is brittle for allocators that return NULL for malloc(0). The
// realloc(0, 0) code path does not guarantee a non-NULL return, so be sure // realloc(0, 0) code path does not guarantee a non-NULL return, so be sure
// to call malloc for this case. // to call malloc for this case.
...@@ -168,7 +161,7 @@ void* realloc(void* ptr, size_t size) __THROW { ...@@ -168,7 +161,7 @@ void* realloc(void* ptr, size_t size) __THROW {
} }
// TODO(mbelshe): Implement this for other allocators. // TODO(mbelshe): Implement this for other allocators.
void malloc_stats(void) __THROW { void malloc_stats(void) {
switch (allocator) { switch (allocator) {
case WINHEAP: case WINHEAP:
case WINLFH: case WINLFH:
......
...@@ -28,7 +28,7 @@ void* __cdecl operator new(size_t size) { ...@@ -28,7 +28,7 @@ void* __cdecl operator new(size_t size) {
return generic_cpp_alloc(size, false); return generic_cpp_alloc(size, false);
} }
void operator delete(void* p) __THROW { void operator delete(void* p) throw() {
free(p); free(p);
} }
...@@ -36,15 +36,15 @@ void* operator new[](size_t size) { ...@@ -36,15 +36,15 @@ void* operator new[](size_t size) {
return generic_cpp_alloc(size, false); return generic_cpp_alloc(size, false);
} }
void operator delete[](void* p) __THROW { void operator delete[](void* p) throw() {
free(p); free(p);
} }
void* operator new(size_t size, const std::nothrow_t& nt) __THROW { void* operator new(size_t size, const std::nothrow_t& nt) throw() {
return generic_cpp_alloc(size, true); return generic_cpp_alloc(size, true);
} }
void* operator new[](size_t size, const std::nothrow_t& nt) __THROW { void* operator new[](size_t size, const std::nothrow_t& nt) throw() {
return generic_cpp_alloc(size, true); return generic_cpp_alloc(size, true);
} }
...@@ -53,7 +53,7 @@ void* operator new[](size_t size, const std::nothrow_t& nt) __THROW { ...@@ -53,7 +53,7 @@ void* operator new[](size_t size, const std::nothrow_t& nt) __THROW {
// If flag is 1, calls to malloc will behave like calls to new, // If flag is 1, calls to malloc will behave like calls to new,
// and the std_new_handler will be invoked on failure. // and the std_new_handler will be invoked on failure.
// Returns the previous mode. // Returns the previous mode.
int _set_new_mode(int flag) __THROW { int _set_new_mode(int flag) throw() {
int old_mode = new_mode; int old_mode = new_mode;
new_mode = flag; new_mode = flag;
return old_mode; return old_mode;
...@@ -63,7 +63,7 @@ int _set_new_mode(int flag) __THROW { ...@@ -63,7 +63,7 @@ int _set_new_mode(int flag) __THROW {
extern "C" { extern "C" {
void* calloc(size_t n, size_t elem_size) __THROW { void* calloc(size_t n, size_t elem_size) {
// Overflow check // Overflow check
const size_t size = n * elem_size; const size_t size = n * elem_size;
if (elem_size != 0 && size / elem_size != n) return NULL; if (elem_size != 0 && size / elem_size != n) return NULL;
......
...@@ -148,7 +148,7 @@ bool LaunchProcess(const string16& cmdline, ...@@ -148,7 +148,7 @@ bool LaunchProcess(const string16& cmdline,
} }
if (options.empty_desktop_name) if (options.empty_desktop_name)
startup_info->lpDesktop = L""; startup_info->lpDesktop = const_cast<wchar_t*>(L"");
startup_info->dwFlags = STARTF_USESHOWWINDOW; startup_info->dwFlags = STARTF_USESHOWWINDOW;
startup_info->wShowWindow = options.start_hidden ? SW_HIDE : SW_SHOW; startup_info->wShowWindow = options.start_hidden ? SW_HIDE : SW_SHOW;
......
...@@ -174,7 +174,7 @@ base::FilePath::StringType NumberOfCoresAsFilePathString() { ...@@ -174,7 +174,7 @@ base::FilePath::StringType NumberOfCoresAsFilePathString() {
SYSTEM_INFO system_info; SYSTEM_INFO system_info;
GetSystemInfo(&system_info); GetSystemInfo(&system_info);
#if TELEMETRY #if TELEMETRY
fprintf(stderr, "browser says nprocessors = %d\n", fprintf(stderr, "browser says nprocessors = %lu\n",
system_info.dwNumberOfProcessors); system_info.dwNumberOfProcessors);
fflush(NULL); fflush(NULL);
#endif #endif
......
...@@ -146,12 +146,12 @@ STDMETHODIMP AudioDeviceListenerWin::OnDefaultDeviceChanged( ...@@ -146,12 +146,12 @@ STDMETHODIMP AudioDeviceListenerWin::OnDefaultDeviceChanged(
// Grab a pointer to the appropriate ID member. // Grab a pointer to the appropriate ID member.
// Note that there are three "?:"'s here to select the right ID. // Note that there are three "?:"'s here to select the right ID.
std::string* current_device_id = std::string* current_device_id =
role == eRender ? ( role == eConsole ? (
flow == eConsole ? flow == eRender ?
&default_render_device_id_ : &default_render_device_id_ :
&default_communications_render_device_id_ &default_communications_render_device_id_
) : ( ) : (
flow == eConsole ? flow == eRender ?
&default_capture_device_id_ : &default_capture_device_id_ :
&default_communications_capture_device_id_ &default_communications_capture_device_id_
); );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment