On 10.06.2022 10:33, Michal Orzel wrote: > All the members of struct tm are defined as integers but the format tags > used in console driver for snprintf wrongly expect unsigned values. Fix > the tags to expect integers.
Perhaps do things the other way around - convert field types to unsigned unless negative values can be stored there? This would match our general aim of using unsigned types when only non-negative values can be held in variables / parameters / fields. Jan > --- a/xen/drivers/char/console.c > +++ b/xen/drivers/char/console.c > @@ -844,7 +844,7 @@ static void printk_start_of_line(const char *prefix) > /* nothing */; > else if ( mode == TSM_DATE ) > { > - snprintf(tstr, sizeof(tstr), "[%04u-%02u-%02u %02u:%02u:%02u] ", > + snprintf(tstr, sizeof(tstr), "[%04d-%02d-%02d %02d:%02d:%02d] ", > 1900 + tm.tm_year, tm.tm_mon + 1, tm.tm_mday, > tm.tm_hour, tm.tm_min, tm.tm_sec); > break; > @@ -852,7 +852,7 @@ static void printk_start_of_line(const char *prefix) > else > { > snprintf(tstr, sizeof(tstr), > - "[%04u-%02u-%02u %02u:%02u:%02u.%03"PRIu64"] ", > + "[%04d-%02d-%02d %02d:%02d:%02d.%03"PRIu64"] ", > 1900 + tm.tm_year, tm.tm_mon + 1, tm.tm_mday, > tm.tm_hour, tm.tm_min, tm.tm_sec, nsec / 1000000); > break;