]> git.sesse.net Git - vlc/blobdiff - src/misc/mtime.c
secstotimestr: use int32_t not to overflow if int exceeds 32-bits
[vlc] / src / misc / mtime.c
index 8905be468edd5ec3c10173616925340acee0ad28..e6f9da637a47e2ca03954a633723f12ab0c38ebd 100644 (file)
@@ -125,7 +125,7 @@ char *mstrtime( char *psz_buffer, mtime_t date )
  * \param psz_buffer should be a buffer at least MSTRTIME_MAX_SIZE characters
  * \return psz_buffer is returned so this can be used as printf parameter.
  */
-char *secstotimestr( char *psz_buffer, int i_seconds )
+char *secstotimestr( char *psz_buffer, int32_t i_seconds )
 {
     div_t d;
 
@@ -134,11 +134,11 @@ char *secstotimestr( char *psz_buffer, int i_seconds )
     d = div( d.quot, 60 );
 
     if( d.quot )
-        snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%d:%2.2d:%2.2d",
+        snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%u:%02u:%02u",
                  d.quot, d.rem, i_seconds );
     else
-         snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%2.2d:%2.2d",
-                   d.quot, i_seconds );
+         snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%02u:%02u",
+                   d.rem, i_seconds );
     return psz_buffer;
 }