From f024f7900b966402d73c9516a9b7e6fe7e98684c Mon Sep 17 00:00:00 2001 From: "thakis@chromium.org" Date: Wed, 4 Aug 2010 04:27:19 +0000 Subject: Mac: Some clang appeasing. BUG=TEST=none Review URL: http://codereview.chromium.org/3089004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54870 0039d316-1c4b-4281-b951-d872f2087c98 --- base/string_piece.cc | 4 ++-- chrome/browser/autocomplete/autocomplete_popup_model.cc | 4 ++-- chrome/browser/cocoa/bookmark_bar_controller.h | 2 +- chrome/browser/cocoa/bookmark_bubble_controller.mm | 1 + chrome/browser/cocoa/bookmark_button.h | 6 +++--- chrome/browser/cocoa/bookmark_button.mm | 6 +++--- chrome/browser/cocoa/fullscreen_controller.h | 4 ++-- chrome/browser/cocoa/fullscreen_controller.mm | 4 ++-- chrome/browser/cocoa/location_bar/ev_bubble_decoration.mm | 2 +- chrome/browser/cocoa/popup_blocked_animation_mac.mm | 1 - chrome/browser/net/gaia/token_service.cc | 6 +++--- chrome/browser/net/gaia/token_service.h | 6 +++--- chrome/default_plugin/plugin_impl_gtk.h | 2 +- chrome/default_plugin/plugin_impl_mac.h | 4 ++-- chrome/default_plugin/plugin_impl_win.h | 2 +- gpu/command_buffer/service/program_manager.cc | 3 ++- net/base/cookie_monster.cc | 2 +- net/base/mime_sniffer.cc | 3 ++- net/http/http_auth_gssapi_posix.h | 4 ++-- skia/ext/canvas_paint_mac.h | 2 +- webkit/glue/glue_serialize.cc | 4 +++- 21 files changed, 38 insertions(+), 34 deletions(-) diff --git a/base/string_piece.cc b/base/string_piece.cc index 082e3c2..3ccb4f0 100644 --- a/base/string_piece.cc +++ b/base/string_piece.cc @@ -54,7 +54,7 @@ size_type StringPiece::find(char c, size_type pos) const { return npos; const char* result = std::find(ptr_ + pos, ptr_ + length_, c); - return result != ptr_ + length_ ? result - ptr_ : npos; + return result != ptr_ + length_ ? static_cast(result - ptr_) : npos; } size_type StringPiece::rfind(const StringPiece& s, size_type pos) const { @@ -66,7 +66,7 @@ size_type StringPiece::rfind(const StringPiece& s, size_type pos) const { const char* last = ptr_ + std::min(length_ - s.length_, pos) + s.length_; const char* result = std::find_end(ptr_, last, s.ptr_, s.ptr_ + s.length_); - return result != last ? result - ptr_ : npos; + return result != last ? static_cast(result - ptr_) : npos; } size_type StringPiece::rfind(char c, size_type pos) const { diff --git a/chrome/browser/autocomplete/autocomplete_popup_model.cc b/chrome/browser/autocomplete/autocomplete_popup_model.cc index eb99c3d..795c03a 100644 --- a/chrome/browser/autocomplete/autocomplete_popup_model.cc +++ b/chrome/browser/autocomplete/autocomplete_popup_model.cc @@ -275,8 +275,8 @@ void AutocompletePopupModel::Observe(NotificationType type, const AutocompleteResult* result = Details(details).ptr(); - selected_line_ = (result->default_match() == result->end()) ? - kNoMatch : (result->default_match() - result->begin()); + selected_line_ = result->default_match() == result->end() ? + kNoMatch : static_cast(result->default_match() - result->begin()); // There had better not be a nonempty result set with no default match. CHECK((selected_line_ != kNoMatch) || result->empty()); // If we're going to trim the window size to no longer include the hovered diff --git a/chrome/browser/cocoa/bookmark_bar_controller.h b/chrome/browser/cocoa/bookmark_bar_controller.h index ae40517..587cac8 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller.h +++ b/chrome/browser/cocoa/bookmark_bar_controller.h @@ -200,7 +200,7 @@ willAnimateFromState:(bookmarks::VisualState)oldState NSRect originalImportBookmarksRect_; // Original, pre-resized field rect. // "Other bookmarks" button on the right side. - scoped_nsobject otherBookmarksButton_; + scoped_nsobject otherBookmarksButton_; // We have a special menu for folder buttons. This starts as a copy // of the bar menu. diff --git a/chrome/browser/cocoa/bookmark_bubble_controller.mm b/chrome/browser/cocoa/bookmark_bubble_controller.mm index 0884d75..641c37e 100644 --- a/chrome/browser/cocoa/bookmark_bubble_controller.mm +++ b/chrome/browser/cocoa/bookmark_bubble_controller.mm @@ -3,6 +3,7 @@ // found in the LICENSE file. #import "chrome/browser/cocoa/bookmark_bubble_controller.h" + #include "app/l10n_util_mac.h" #include "base/mac_util.h" #include "base/sys_string_conversions.h" diff --git a/chrome/browser/cocoa/bookmark_button.h b/chrome/browser/cocoa/bookmark_button.h index 60dd2a6..3459809 100644 --- a/chrome/browser/cocoa/bookmark_button.h +++ b/chrome/browser/cocoa/bookmark_button.h @@ -215,14 +215,14 @@ class ThemeProvider; namespace bookmark_button { // Notifications for pulsing of bookmarks. -extern const NSString* kPulseBookmarkButtonNotification; +extern NSString* const kPulseBookmarkButtonNotification; // Key for userInfo dict of a kPulseBookmarkButtonNotification. // Value is a [NSValue valueWithPointer:]; pointer is a (const BookmarkNode*). -extern const NSString* kBookmarkKey; +extern NSString* const kBookmarkKey; // Key for userInfo dict of a kPulseBookmarkButtonNotification. // Value is a [NSNumber numberWithBool:] to turn pulsing on or off. -extern const NSString* kBookmarkPulseFlagKey; +extern NSString* const kBookmarkPulseFlagKey; }; diff --git a/chrome/browser/cocoa/bookmark_button.mm b/chrome/browser/cocoa/bookmark_button.mm index f823405..b5f9b86 100644 --- a/chrome/browser/cocoa/bookmark_button.mm +++ b/chrome/browser/cocoa/bookmark_button.mm @@ -16,10 +16,10 @@ static const CGFloat kDragImageOpacity = 0.7; namespace bookmark_button { -const NSString* kPulseBookmarkButtonNotification = +NSString* const kPulseBookmarkButtonNotification = @"PulseBookmarkButtonNotification"; -const NSString* kBookmarkKey = @"BookmarkKey"; -const NSString* kBookmarkPulseFlagKey = @"BookmarkPulseFlagKey"; +NSString* const kBookmarkKey = @"BookmarkKey"; +NSString* const kBookmarkPulseFlagKey = @"BookmarkPulseFlagKey"; }; diff --git a/chrome/browser/cocoa/fullscreen_controller.h b/chrome/browser/cocoa/fullscreen_controller.h index 1e90a62..f213fa3 100644 --- a/chrome/browser/cocoa/fullscreen_controller.h +++ b/chrome/browser/cocoa/fullscreen_controller.h @@ -116,7 +116,7 @@ @end // Notification posted when we're about to enter or leave fullscreen. -extern const NSString* kWillEnterFullscreenNotification; -extern const NSString* kWillLeaveFullscreenNotification; +extern NSString* const kWillEnterFullscreenNotification; +extern NSString* const kWillLeaveFullscreenNotification; #endif // CHROME_BROWSER_COCOA_FULLSCREEN_CONTROLLER_H_ diff --git a/chrome/browser/cocoa/fullscreen_controller.mm b/chrome/browser/cocoa/fullscreen_controller.mm index f5d66bf..452b996 100644 --- a/chrome/browser/cocoa/fullscreen_controller.mm +++ b/chrome/browser/cocoa/fullscreen_controller.mm @@ -9,9 +9,9 @@ #import "chrome/browser/cocoa/browser_window_controller.h" #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" -const NSString* kWillEnterFullscreenNotification = +NSString* const kWillEnterFullscreenNotification = @"WillEnterFullscreenNotification"; -const NSString* kWillLeaveFullscreenNotification = +NSString* const kWillLeaveFullscreenNotification = @"WillLeaveFullscreenNotification"; namespace { diff --git a/chrome/browser/cocoa/location_bar/ev_bubble_decoration.mm b/chrome/browser/cocoa/location_bar/ev_bubble_decoration.mm index 990c4b9..434009a 100644 --- a/chrome/browser/cocoa/location_bar/ev_bubble_decoration.mm +++ b/chrome/browser/cocoa/location_bar/ev_bubble_decoration.mm @@ -31,7 +31,7 @@ const float kMaxBubbleFraction = 0.5; // TODO(shess): This is ugly, find a better way. Using it right now // so that I can crib from gtk and still be able to see that I'm using // the same values easily. -const NSColor* ColorWithRGBBytes(int rr, int gg, int bb) { +NSColor* ColorWithRGBBytes(int rr, int gg, int bb) { DCHECK_LE(rr, 255); DCHECK_LE(bb, 255); DCHECK_LE(gg, 255); diff --git a/chrome/browser/cocoa/popup_blocked_animation_mac.mm b/chrome/browser/cocoa/popup_blocked_animation_mac.mm index d0f5644..44a765b 100644 --- a/chrome/browser/cocoa/popup_blocked_animation_mac.mm +++ b/chrome/browser/cocoa/popup_blocked_animation_mac.mm @@ -108,7 +108,6 @@ class PopupBlockedAnimationObserver : public NotificationObserver { [parentWindow addChildWindow:animation_ ordered:NSWindowAbove]; // Start the animation from the center of the window. - NSRect contentFrame = [[animation_ contentView] frame]; [animation_ setStartFrame:CGRectMake(0, imageHeight / 2, imageWidth, diff --git a/chrome/browser/net/gaia/token_service.cc b/chrome/browser/net/gaia/token_service.cc index 8420fb2..0a87dfe 100644 --- a/chrome/browser/net/gaia/token_service.cc +++ b/chrome/browser/net/gaia/token_service.cc @@ -20,11 +20,11 @@ void TokenService::Initialize( talk_token_fetcher_.reset(new GaiaAuthenticator2(this, source_, getter)); } -const bool TokenService::AreCredentialsValid() const { +bool TokenService::AreCredentialsValid() const { return !credentials_.lsid.empty() && !credentials_.sid.empty(); } -const bool TokenService::HasLsid() const { +bool TokenService::HasLsid() const { return !credentials_.lsid.empty(); } @@ -44,7 +44,7 @@ void TokenService::StartFetchingTokens() { // Services dependent on a token will check if a token is available. // If it isn't, they'll go to sleep until they get a token event. -const bool TokenService::HasTokenForService(const char* const service) const { +bool TokenService::HasTokenForService(const char* const service) const { return token_map_.count(service) > 0; } diff --git a/chrome/browser/net/gaia/token_service.h b/chrome/browser/net/gaia/token_service.h index bad80f5..cf13699 100644 --- a/chrome/browser/net/gaia/token_service.h +++ b/chrome/browser/net/gaia/token_service.h @@ -61,7 +61,7 @@ class TokenService : public GaiaAuthConsumer { // For legacy services with their own auth routines, they can just read // the LSID out directly. Deprecated. - const bool HasLsid() const; + bool HasLsid() const; const std::string& GetLsid() const; // On login, StartFetchingTokens() should be called to kick off token @@ -69,7 +69,7 @@ class TokenService : public GaiaAuthConsumer { // Tokens will be fetched for all services(sync, talk) in the background. // Results come back via event channel. Services can also poll. void StartFetchingTokens(); - const bool HasTokenForService(const char* const service) const; + bool HasTokenForService(const char* const service) const; const std::string& GetTokenForService(const char* const service) const; // Callbacks from the fetchers. @@ -80,7 +80,7 @@ class TokenService : public GaiaAuthConsumer { private: // Did we get a proper LSID? - const bool AreCredentialsValid() const; + bool AreCredentialsValid() const; // Gaia request source for Gaia accounting. std::string source_; diff --git a/chrome/default_plugin/plugin_impl_gtk.h b/chrome/default_plugin/plugin_impl_gtk.h index a699e05..2035384 100644 --- a/chrome/default_plugin/plugin_impl_gtk.h +++ b/chrome/default_plugin/plugin_impl_gtk.h @@ -162,7 +162,7 @@ class PluginInstallerImpl { } // Getter for the NPP instance member. - const NPP instance() const { + NPP instance() const { return instance_; } diff --git a/chrome/default_plugin/plugin_impl_mac.h b/chrome/default_plugin/plugin_impl_mac.h index 6718ee0..267cf9f 100644 --- a/chrome/default_plugin/plugin_impl_mac.h +++ b/chrome/default_plugin/plugin_impl_mac.h @@ -12,7 +12,7 @@ #include "gfx/native_widget_types.h" #include "third_party/npapi/bindings/npapi.h" -#ifdef __OBJ__ +#ifdef __OBJC__ @class NSImage; @class NSString; #else @@ -168,7 +168,7 @@ class PluginInstallerImpl { } // Getter for the NPP instance member. - const NPP instance() const { + NPP instance() const { return instance_; } diff --git a/chrome/default_plugin/plugin_impl_win.h b/chrome/default_plugin/plugin_impl_win.h index 512f9a8..d07207d 100644 --- a/chrome/default_plugin/plugin_impl_win.h +++ b/chrome/default_plugin/plugin_impl_win.h @@ -174,7 +174,7 @@ class PluginInstallerImpl : public gfx::WindowImpl { } // Getter for the NPP instance member. - const NPP instance() const { + NPP instance() const { return instance_; } diff --git a/gpu/command_buffer/service/program_manager.cc b/gpu/command_buffer/service/program_manager.cc index d9ad80e..7210bdb 100644 --- a/gpu/command_buffer/service/program_manager.cc +++ b/gpu/command_buffer/service/program_manager.cc @@ -204,7 +204,8 @@ const ProgramManager::ProgramInfo::UniformInfo* UniformInfo& info = uniform_infos_.back(); info.element_locations.resize(size); info.element_locations[0] = location; - size_t num_texture_units = info.IsSampler() ? size : 0u; + DCHECK_GE(size, 0); + size_t num_texture_units = info.IsSampler() ? static_cast(size) : 0u; info.texture_units.clear(); info.texture_units.resize(num_texture_units, 0); diff --git a/net/base/cookie_monster.cc b/net/base/cookie_monster.cc index 8b0f591..bd86772 100644 --- a/net/base/cookie_monster.cc +++ b/net/base/cookie_monster.cc @@ -1614,7 +1614,7 @@ CookieMonster::CanonicalCookie* CookieMonster::CanonicalCookie::Create( return NULL; std::string cookie_domain; if (!GetCookieDomainKeyWithString(url, parsed_domain, &cookie_domain)) - return false; + return NULL; std::string parsed_path = ParsedCookie::ParseValueString(path); if (parsed_path != path) diff --git a/net/base/mime_sniffer.cc b/net/base/mime_sniffer.cc index 1961107..4ad4e1d 100644 --- a/net/base/mime_sniffer.cc +++ b/net/base/mime_sniffer.cc @@ -228,7 +228,8 @@ static bool MatchMagicNumber(const char* content, size_t size, // pretend the length is content_size. const char* end = static_cast(memchr(content, '\0', size)); - const size_t content_strlen = (end != NULL) ? (end - content) : size; + const size_t content_strlen = + (end != NULL) ? static_cast(end - content) : size; bool match = false; if (magic_entry->is_string) { diff --git a/net/http/http_auth_gssapi_posix.h b/net/http/http_auth_gssapi_posix.h index 094a784..71ff555 100644 --- a/net/http/http_auth_gssapi_posix.h +++ b/net/http/http_auth_gssapi_posix.h @@ -20,7 +20,7 @@ class GURL; namespace net { -class HttpRequestInfo; +struct HttpRequestInfo; extern gss_OID CHROME_GSS_C_NT_HOSTBASED_SERVICE_X; extern gss_OID CHROME_GSS_C_NT_HOSTBASED_SERVICE; @@ -205,7 +205,7 @@ class ScopedSecurityContext { explicit ScopedSecurityContext(GSSAPILibrary* gssapi_lib); ~ScopedSecurityContext(); - const gss_ctx_id_t get() const { return security_context_; } + gss_ctx_id_t get() const { return security_context_; } gss_ctx_id_t* receive() { return &security_context_; } private: diff --git a/skia/ext/canvas_paint_mac.h b/skia/ext/canvas_paint_mac.h index 5fc8256..ae1fda8 100644 --- a/skia/ext/canvas_paint_mac.h +++ b/skia/ext/canvas_paint_mac.h @@ -85,7 +85,7 @@ class CanvasPaintT : public T { if (!T::initialize(rectangle_.size.width, rectangle_.size.height, opaque, NULL)) { // Cause a deliberate crash; - *(char*) 0 = 0; + *(volatile char*) 0 = 0; } // Need to translate so that the dirty region appears at the origin of the diff --git a/webkit/glue/glue_serialize.cc b/webkit/glue/glue_serialize.cc index caf37b45..d0b9a86 100644 --- a/webkit/glue/glue_serialize.cc +++ b/webkit/glue/glue_serialize.cc @@ -191,7 +191,9 @@ inline WebString ReadString(const SerializeObject* obj) { // In version 2, the length field was the length in WebUChars. // In version 1 and 3 it is the length in bytes. - int bytes = ((obj->version == 2) ? length * sizeof(WebUChar) : length); + int bytes = length; + if (obj->version == 2) + bytes *= sizeof(WebUChar); const void* data; if (!ReadBytes(obj, &data, bytes)) -- cgit v1.1