Skip to content

migrate-catalogs: properly use time_t for localtime()

Pino Toscano requested to merge pinotree/gthumb:time_t into master

Commit ed219c77 changed the type of the date variable from time_t to long, to ensure the right type is handled by sscanf(). The problem is that, in case time_t is not the same as long, the wrong pointer is passed to localtime(), and more strict build flags (such as the defaults of GCC 14) cause the build to fail on such setups.

The ideal fix in this case would be to switch back the date variable to time_t and use the right format specifier for it in sscanf(); however, since this is an helper to convert very old format, this additional code is not much worth it. Hence, use a simpler fix: in case a date timestamp was read from the file, set it to a new time_t variable which is then used for localtime(). Since time_t is big at least as much as long, there is no precision/value loss.

There should be no behaviour change.

Merge request reports