Skip to content

Commit 47b4fd0

Browse files
committed
profiler: rtlib: fix gcc warnings
- gcc warns about snprintf() writing more than it has space for in optimized / non-debug builds - quiet the warning by ensuring values are in range by clamping the values using modulo 10000 for the 4 digit year and modulo 100 for the other 2 digit date / time values
1 parent a3df859 commit 47b4fd0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/rtlib/profile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,8 @@ FB_PROFILER_GLOBAL *PROFILER_GLOBAL_create( void ) {
397397
ptm = localtime( &rawtime );
398398
snprintf( fb_profiler->launch_time, sizeof(fb_profiler->launch_time),
399399
"%02d-%02d-%04d, %02d:%02d:%02d",
400-
(int)(1+ptm->tm_mon), (int)(ptm->tm_mday), (int)(1900+ptm->tm_year),
401-
(int)ptm->tm_hour, (int)ptm->tm_min, (int)ptm->tm_sec );
400+
(int)(1+ptm->tm_mon)%100u, (int)(ptm->tm_mday)%100u, (int)(1900+ptm->tm_year)%10000u,
401+
(int)ptm->tm_hour%100u, (int)ptm->tm_min%100u, (int)ptm->tm_sec%100u );
402402
fb_profiler->launch_time[sizeof(fb_profiler->launch_time)-1] = '\0';
403403
}
404404
return fb_profiler;

0 commit comments

Comments
 (0)