Fix -Wformat in AnimationBase.cpp
authormcatanzaro@igalia.com <mcatanzaro@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Apr 2015 02:15:36 +0000 (02:15 +0000)
committermcatanzaro@igalia.com <mcatanzaro@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Apr 2015 02:15:36 +0000 (02:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=143541

Reviewed by Simon Fraser.

* page/animation/AnimationBase.cpp:
(WebCore::nameForStateInput): Added. Converts an AnimationBase::AnimationStateInput to a
string.
(WebCore::AnimationBase::updateStateMachine): Print AnimationBase::AnimationStateInput as a
string, instead of passing it to %d and assuming that works, to silence GCC's -Wformat.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182580 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/page/animation/AnimationBase.cpp

index b73639d..0fb1c6d 100644 (file)
@@ -1,3 +1,16 @@
+2015-04-08  Michael Catanzaro  <mcatanzaro@igalia.com>
+
+        Fix -Wformat in AnimationBase.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=143541
+
+        Reviewed by Simon Fraser.
+
+        * page/animation/AnimationBase.cpp:
+        (WebCore::nameForStateInput): Added. Converts an AnimationBase::AnimationStateInput to a
+        string.
+        (WebCore::AnimationBase::updateStateMachine): Print AnimationBase::AnimationStateInput as a
+        string, instead of passing it to %d and assuming that works, to silence GCC's -Wformat.
+
 2015-04-08  Brady Eidson  <beidson@apple.com>
 
         Expose the "Share" menu for links, images, and media.
index 88d62a5..79c9754 100644 (file)
@@ -131,6 +131,26 @@ static const char* nameForState(AnimationBase::AnimationState state)
     }
     return "";
 }
+
+static const char* nameForStateInput(AnimationBase::AnimationStateInput input)
+{
+    switch (input) {
+    case AnimationBase::AnimationStateInput::MakeNew: return "MakeNew";
+    case AnimationBase::AnimationStateInput::StartAnimation: return "StartAnimation";
+    case AnimationBase::AnimationStateInput::RestartAnimation: return "RestartAnimation";
+    case AnimationBase::AnimationStateInput::StartTimerFired: return "StartTimerFired";
+    case AnimationBase::AnimationStateInput::StyleAvailable: return "StyleAvailable";
+    case AnimationBase::AnimationStateInput::StartTimeSet: return "StartTimeSet";
+    case AnimationBase::AnimationStateInput::LoopTimerFired: return "LoopTimerFired";
+    case AnimationBase::AnimationStateInput::EndTimerFired: return "EndTimerFired";
+    case AnimationBase::AnimationStateInput::PauseOverride: return "PauseOverride";
+    case AnimationBase::AnimationStateInput::ResumeOverride: return "ResumeOverride";
+    case AnimationBase::AnimationStateInput::PlayStateRunning: return "PlayStateRunning";
+    case AnimationBase::AnimationStateInput::PlayStatePaused: return "PlayStatePaused";
+    case AnimationBase::AnimationStateInput::EndAnimation: return "EndAnimation";
+    }
+    return "";
+}
 #endif
 
 void AnimationBase::updateStateMachine(AnimationStateInput input, double param)
@@ -318,7 +338,7 @@ void AnimationBase::updateStateMachine(AnimationStateInput input, double param)
         case AnimationState::Ending:
 #if !LOG_DISABLED
             if (input != AnimationStateInput::EndTimerFired && input != AnimationStateInput::PlayStatePaused)
-                LOG_ERROR("State is AnimationState::Ending, but input is not AnimationStateInput::EndTimerFired or AnimationStateInput::PlayStatePaused. It is %d.", input);
+                LOG_ERROR("State is AnimationState::Ending, but input is not AnimationStateInput::EndTimerFired or AnimationStateInput::PlayStatePaused. It is %s.", nameForStateInput(input));
 #endif
             if (input == AnimationStateInput::EndTimerFired) {