Modify the type of seconds since midnight and the cast type of curr_date_time
@@ -52,7 +52,7 @@ get_current_datetime(char *cdt)
{
char ymd[MAXSTRING];
struct tm *timeinfo;
- unsigned int seconds_since_midnight;
+ uint64_t seconds_since_midnight;
time_t curr_date_time;
curr_date_time = time(NULL);
@@ -62,13 +62,13 @@ get_current_datetime(char *cdt)
timeinfo = localtime(&curr_date_time);
- seconds_since_midnight = (unsigned int) curr_date_time % CONST_CDAY;
+ seconds_since_midnight = (uint64_t) curr_date_time % CONST_CDAY;
if (strftime(ymd, MAXSTRING - 1, "%Y%m%d", timeinfo) == 0) {
log_err("Something went wrong converting the current time info to ymd");
}
- sprintf(cdt, "%s-%05d", ymd, seconds_since_midnight);
+ snprintf(cdt, MAXSTRING, "%s-%05d", ymd, seconds_since_midnight);
}
/******************************************************************************
