[haiku-commits] r40876 - haiku/trunk/src/apps/mediaconverter

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 8 Mar 2011 21:23:04 +0100 (CET)

Author: stippi
Date: 2011-03-08 21:23:03 +0100 (Tue, 08 Mar 2011)
New Revision: 40876
Changeset: http://dev.haiku-os.org/changeset/40876
Ticket: http://dev.haiku-os.org/ticket/7341

Modified:
   haiku/trunk/src/apps/mediaconverter/MediaConverterApp.cpp
   haiku/trunk/src/apps/mediaconverter/MediaFileInfo.cpp
Log:
Patch by starsseed from ticket #7341: Use correct format strings
in sprintf() invokations, specifically to avoid reading more
bytes than are contained in the passed arguments. Thanks! Small
cleanups of the touced code by myself included.


Modified: haiku/trunk/src/apps/mediaconverter/MediaConverterApp.cpp
===================================================================
--- haiku/trunk/src/apps/mediaconverter/MediaConverterApp.cpp   2011-03-08 
17:47:58 UTC (rev 40875)
+++ haiku/trunk/src/apps/mediaconverter/MediaConverterApp.cpp   2011-03-08 
20:23:03 UTC (rev 40876)
@@ -549,11 +549,11 @@
                                break;
                        }
                        completePercent = (float)(i - start) / (float)(end - 
start) * 100;
-                       currPercent = (int16)floor(completePercent);
+                       currPercent = (int32)completePercent;
                        if (currPercent > lastPercent) {
                                lastPercent = currPercent;
                                snprintf(status.LockBuffer(128), 128,
-                                       B_TRANSLATE("Writing video track: %Ld 
%% complete"),
+                                       B_TRANSLATE("Writing video track: %ld%% 
complete"),
                                        currPercent);
                                status.UnlockBuffer();
                                SetStatusMessage(status.String());
@@ -607,11 +607,11 @@
                                break;
                        }
                        completePercent = (float)(i - start) / (float)(end - 
start) * 100;
-                       currPercent = (int16)floor(completePercent);
+                       currPercent = (int32)completePercent;
                        if (currPercent > lastPercent) {
                                lastPercent = currPercent;
                                snprintf(status.LockBuffer(128), 128,
-                                       B_TRANSLATE("Writing audio track: %Ld 
%% complete"),
+                                       B_TRANSLATE("Writing audio track: %ld%% 
complete"),
                                        currPercent);
                                status.UnlockBuffer();
                                SetStatusMessage(status.String());

Modified: haiku/trunk/src/apps/mediaconverter/MediaFileInfo.cpp
===================================================================
--- haiku/trunk/src/apps/mediaconverter/MediaFileInfo.cpp       2011-03-08 
17:47:58 UTC (rev 40875)
+++ haiku/trunk/src/apps/mediaconverter/MediaFileInfo.cpp       2011-03-08 
20:23:03 UTC (rev 40876)
@@ -70,7 +70,7 @@
 
                                BString details;
                                snprintf(details.LockBuffer(256), 256,
-                                               B_TRANSLATE_COMMENT("%Ld x %Ld, 
%Ld fps / %Ld frames",
+                                               B_TRANSLATE_COMMENT("%u x %u, 
%.2ffps / %Ld frames",
                                                "Width x Height, fps / frames"),
                                                format.Width(), format.Height(),
                                                rvf->field_rate / 
rvf->interlace, videoFrames);


Other related posts: