migration: Remove time_t cast for OpenBSD
PATCH 1/1 migration: Remove time_t cast for OpenBSD
OpenBSD has supported 64-bit time_t across all archs since 5.5 released in 2014.
Remove a time_t cast that is no longer necessary.
migration/savevm.c +1 -2
@@ -2849,8 +2849,7 @@ bool save_snapshot(const char *name, bool overwrite, const char *vmstate,if (name) {pstrcpy (sn->name,sizeof (sn->name), name); }else { -/* cast below needed for OpenBSD where tv_sec is still 'long' */ -localtime_r ((const time_t *)&tv.tv_sec, &tm); +localtime_r (&tv.tv_sec, &tm);strftime (sn->name,sizeof (sn->name),"vm-%Y%m%d%H%M%S" , &tm); }
Quoted 12 lines · Brad Smith
OpenBSD has supported 64-bit
time_tacross all archs since 5.5 released in 2014.Remove a
time_tcast that is no longer necessary.Signed-off-by Brad Smith <[email protected]>migration/savevm.c +0
-0
migration/savevm.c bool save_snapshot(const char *name, bool overwrite, const char *vmstate, · line 2854
Quoted 8 lines
migration/savevm.c +1
-2@@ -2849,8 +2849,7 @@ bool save_snapshot(const char *name, bool overwrite, const char *vmstate,if (name) {pstrcpy (sn->name,sizeof (sn->name), name); }else { -/* cast below needed for OpenBSD where tv_sec is still 'long' */ -localtime_r ((const time_t *)&tv.tv_sec, &tm); +localtime_r (&tv.tv_sec, &tm);strftime (sn->name,sizeof (sn->name),"vm-%Y%m%d%H%M%S" , &tm); }
Please make sure to CC: the maintainers (see MAINTAINERS file). Done now.
Le 08/03/2021 à 12:46, Thomas Huth a écrit :
Quoted 8 lines · Brad Smith
Quoted 7 lines
OpenBSD has supported 64-bit
time_tacross all archs since 5.5 released in 2014.Remove a
time_tcast that is no longer necessary.Signed-off-by Brad Smith <[email protected]>
Quoted 14 lines
migration/savevm.c bool save_snapshot(const char *name, bool overwrite, const char *vmstate, · line 2854
Quoted 13 lines
migration/savevm.c +1
-2@@ -2849,8 +2849,7 @@ bool save_snapshot(const char *name, bool overwrite, const char *vmstate, if (name) { pstrcpy(sn->name, sizeof(sn->name), name); } else { - /* cast below needed for OpenBSD where tv_sec is still 'long' */ - localtime_r((const time_t *)&tv.tv_sec, &tm); + localtime_r(&tv.tv_sec, &tm); strftime(sn->name, sizeof(sn->name), "vm-%Y%m%d%H%M%S", &tm); }
but the qemu_timeval from "include/sysemu/os-win32.h" still uses a long: is this file compiled for win32?
Thanks,
Laurent
Quoted 24 lines · * Laurent Vivier ([email protected]) wrote:
Le 08/03/2021 à 12:46, Thomas Huth a écrit :
Quoted 8 lines · Brad Smith
Quoted 7 lines
OpenBSD has supported 64-bit
time_tacross all archs since 5.5 released in 2014.Remove a
time_tcast that is no longer necessary.Signed-off-by Brad Smith <[email protected]>Quoted 14 lines
migration/savevm.c bool save_snapshot(const char *name, bool overwrite, const char *vmstate, · line 2854
Quoted 13 lines
migration/savevm.c +1
-2@@ -2849,8 +2849,7 @@ bool save_snapshot(const char *name, bool overwrite, const char *vmstate, if (name) { pstrcpy(sn->name, sizeof(sn->name), name); } else { - /* cast below needed for OpenBSD where tv_sec is still 'long' */ - localtime_r((const time_t *)&tv.tv_sec, &tm); + localtime_r(&tv.tv_sec, &tm); strftime(sn->name, sizeof(sn->name), "vm-%Y%m%d%H%M%S", &tm); }
Quoted 2 lines
but the
qemu_timevalfrom "include/sysemu/os-win32.h" still uses a long: is this file compiled for win32?
Yep this fails for me when built with x86_64-w64-mingw32- (it's fine with i686-w64-mingw32- )
Dave
Quoted 3 lines
Thanks,
Laurent
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Quoted 25 lines · Dr. David Alan Gilbert
Quoted 24 lines · * Laurent Vivier ([email protected]) wrote:
Le 08/03/2021 à 12:46, Thomas Huth a écrit :
Quoted 22 lines · Brad Smith
Quoted 20 lines
OpenBSD has supported 64-bit
time_tacross all archs since 5.5 released in 2014.Remove a
time_tcast that is no longer necessary.Signed-off-by Brad Smith <[email protected]>migration/savevm.c +1
-2@@ -2849,8 +2849,7 @@ bool save_snapshot(const char *name, bool overwrite, const char *vmstate, if (name) { pstrcpy(sn->name, sizeof(sn->name), name); } else { - /* cast below needed for OpenBSD where tv_sec is still 'long' */ - localtime_r((const time_t *)&tv.tv_sec, &tm); + localtime_r(&tv.tv_sec, &tm); strftime(sn->name, sizeof(sn->name), "vm-%Y%m%d%H%M%S", &tm); }
Quoted 5 lines
Quoted 2 lines
but the
qemu_timevalfrom "include/sysemu/os-win32.h" still uses a long: is this file compiled for win32?Yep this fails for me when built with x86_64-w64-mingw32- (it's fine with i686-w64-mingw32- )
We could just switch the code to use GDateTime from GLib and thus avoid portability issues. I think this should be equivalent:
g_autoptr(GDateTime) now = g_date_time_new_now_local();
g_autofree char *nowstr = g_date_time_format(now, "vm-%Y%m%d%H%M%s");
strncpy(sn->name, sizeof(sn->name), nowstr);Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 26 lines · Daniel P. Berrangé
Quoted 25 lines · Dr. David Alan Gilbert
Quoted 24 lines · * Laurent Vivier ([email protected]) wrote:
Le 08/03/2021 à 12:46, Thomas Huth a écrit :
Quoted 8 lines · Brad Smith
Quoted 7 lines
OpenBSD has supported 64-bit
time_tacross all archs since 5.5 released in 2014.Remove a
time_tcast that is no longer necessary.Signed-off-by Brad Smith <[email protected]>Quoted 13 lines
migration/savevm.c bool save_snapshot(const char *name, bool overwrite, const char *vmstate, · line 2854
Quoted 13 lines
migration/savevm.c +1
-2@@ -2849,8 +2849,7 @@ bool save_snapshot(const char *name, bool overwrite, const char *vmstate, if (name) { pstrcpy(sn->name, sizeof(sn->name), name); } else { - /* cast below needed for OpenBSD where tv_sec is still 'long' */ - localtime_r((const time_t *)&tv.tv_sec, &tm); + localtime_r(&tv.tv_sec, &tm); strftime(sn->name, sizeof(sn->name), "vm-%Y%m%d%H%M%S", &tm); }but the
qemu_timevalfrom "include/sysemu/os-win32.h" still uses a long: is this file compiled for win32?
Quoted 8 lines
Quoted 2 lines
Yep this fails for me when built with x86_64-w64-mingw32- (it's fine with i686-w64-mingw32- )
We could just switch the code to use GDateTime from GLib and thus avoid portability issues. I think this should be equivalent:
g_autoptr(GDateTime) now = g_date_time_new_now_local(); g_autofree char *nowstr = g_date_time_format(now, "vm-%Y%m%d%H%M%s"); strncpy(sn->name, sizeof(sn->name), nowstr);
Which way do you guys want to go? Something like above, remove the comment or some variation on the comment but not mentioning OpenBSD since it is no longer relevant?
Quoted 34 lines · Brad Smith
Quoted 33 lines · Daniel P. Berrangé
Quoted 27 lines · Dr. David Alan Gilbert
Quoted 18 lines · * Laurent Vivier ([email protected]) wrote:
Le 08/03/2021 à 12:46, Thomas Huth a écrit :
Quoted 17 lines · Brad Smith
Quoted 16 lines
OpenBSD has supported 64-bit
time_tacross all archs since 5.5 released in 2014.Remove a
time_tcast that is no longer necessary.Signed-off-by Brad Smith <[email protected]>migration/savevm.c +0
-0@@ -2849,8 +2849,7 @@ bool save_snapshot(const char *name, bool overwrite, const char *vmstate, if (name) { pstrcpy(sn->name, sizeof(sn->name), name); } else {Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
migration/savevm.c +0
-1- /* cast below needed for OpenBSD where tv_sec isstill 'long' */
-localtime_r((const time_t *)&tv.tv_sec, &tm);
+localtime_r(&tv.tv_sec, &tm);
strftime(sn->name, sizeof(sn->name), "vm-%Y%m%d%H%M%S", &tm); }but the
qemu_timevalfrom "include/sysemu/os-win32.h" still uses a long: is this file compiled for win32?Quoted 2 lines
Yep this fails for me when built with x86_64-w64-mingw32- (it's fine with i686-w64-mingw32- )
We could just switch the code to use GDateTime from GLib and thus avoid portability issues. I think this should be equivalent:
Quoted 7 lines
Quoted 3 lines
g_autoptr(GDateTime)now =g_date_time_new_now_local();g_autofreechar *nowstr =g_date_time_format(now, "vm-%Y%m%d%H%M%s");strncpy(sn->name, sizeof(sn->name), nowstr);Which way do you guys want to go? Something like above, remove the comment or some variation on the comment but not mentioning OpenBSD since it is no longer relevant?
Anyone?
Quoted 43 lines · Brad Smith
Quoted 42 lines · Brad Smith
Quoted 40 lines · Daniel P. Berrangé
Quoted 30 lines · Dr. David Alan Gilbert
Quoted 21 lines · * Laurent Vivier ([email protected]) wrote:
Le 08/03/2021 à 12:46, Thomas Huth a écrit :
Quoted 20 lines · Brad Smith
Quoted 19 lines
OpenBSD has supported 64-bit
time_tacross all archs since 5.5 released in 2014.Remove a
time_tcast that is no longer necessary.Signed-off-by Brad Smith <[email protected]>migration/savevm.c +0
-1@@ -2849,8 +2849,7 @@ bool save_snapshot(const char *name, bool overwrite, const char *vmstate, if (name) { pstrcpy(sn->name, sizeof(sn->name), name); } else { - /* cast below needed for OpenBSD where
tv_secis still 'long' */Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
-
localtime_r((const time_t *)&tv.tv_sec, &tm); +localtime_r(&tv.tv_sec, &tm);strftime(sn->name, sizeof(sn->name), "vm-%Y%m%d%H%M%S", &tm);
}but the
qemu_timevalfrom "include/sysemu/os-win32.h" still uses a long: is this file compiled for
win32?Quoted 2 lines
Yep this fails for me when built with x86_64-w64-mingw32- (it's fine with i686-w64-mingw32- )
We could just switch the code to use GDateTime from GLib and thus avoid portability issues. I think this should be equivalent:
g_autoptr(GDateTime)now =g_date_time_new_now_local();g_autofreechar *nowstr =g_date_time_format(now, "vm-%Y%m%d%H%M%s");
strncpy(sn->name, sizeof(sn->name), nowstr);
Quoted 7 lines
Quoted 5 lines
Which way do you guys want to go? Something like above, remove the comment
or some variation on the comment but not mentioning OpenBSD since it is no
longer relevant?Anyone?
Personally I always favour using GLib APIs if there's an applicable one, since it eliminates portability problems - or rather offloads them to the GLib maintainers, who have already solved them generally.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 48 lines · Daniel P. Berrangé
Quoted 47 lines · Brad Smith
Quoted 46 lines · Brad Smith
Quoted 33 lines · Daniel P. Berrangé
Quoted 30 lines · Dr. David Alan Gilbert
Quoted 21 lines · * Laurent Vivier ([email protected]) wrote:
Le 08/03/2021 à 12:46, Thomas Huth a écrit :
Quoted 20 lines · Brad Smith
Quoted 19 lines
OpenBSD has supported 64-bit
time_tacross all archs since 5.5 released in 2014.Remove a
time_tcast that is no longer necessary.Signed-off-by Brad Smith <[email protected]>migration/savevm.c +0
-1@@ -2849,8 +2849,7 @@ bool save_snapshot(const char *name, bool overwrite, const char *vmstate, if (name) { pstrcpy(sn->name, sizeof(sn->name), name); } else { - /* cast below needed for OpenBSD where
tv_secis still 'long' */Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
-
localtime_r((const time_t *)&tv.tv_sec, &tm); +localtime_r(&tv.tv_sec, &tm);strftime(sn->name, sizeof(sn->name), "vm-%Y%m%d%H%M%S", &tm);
}but the
qemu_timevalfrom "include/sysemu/os-win32.h" still uses a long: is this file compiled for
win32?Quoted 2 lines
Yep this fails for me when built with x86_64-w64-mingw32- (it's fine with i686-w64-mingw32- )
Quoted 7 lines
We could just switch the code to use GDateTime from GLib and thus avoid portability issues. I think this should be equivalent:
g_autoptr(GDateTime)now =g_date_time_new_now_local();g_autofreechar *nowstr =g_date_time_format(now, "vm-%Y%m%d%H%M%s");
strncpy(sn->name, sizeof(sn->name), nowstr);Which way do you guys want to go? Something like above, remove the comment
or some variation on the comment but not mentioning OpenBSD since it is no
longer relevant?
Quoted 4 lines
Quoted 1 line
Anyone?
Personally I always favour using GLib APIs if there's an applicable one, since it eliminates portability problems - or rather offloads them to the GLib maintainers, who have already solved them generally.
Can you please submit a proper diff and I'll drop this?
Quoted 26 lines · Thomas Huth
Quoted 17 lines · Brad Smith
OpenBSD has supported 64-bit
time_tacross all archs since 5.5 released in 2014.Remove a
time_tcast that is no longer necessary.Signed-off-by Brad Smith <[email protected]>migration/savevm.c +0
-1@@ -2849,8 +2849,7 @@ bool save_snapshot(const char *name, bool overwrite, const char *vmstate, if (name) { pstrcpy(sn->name, sizeof(sn->name), name); } else { - /* cast below needed for OpenBSD where tv_sec isQuoted 5 lines
still 'long' */
-localtime_r((const time_t *)&tv.tv_sec, &tm);
+localtime_r(&tv.tv_sec, &tm);
strftime(sn->name, sizeof(sn->name), "vm-%Y%m%d%H%M%S", &tm); }Please make sure to CC: the maintainers (see
MAINTAINERSfile). Done now.
Quoted 1 line
Reviewed-by Thomas Huth <[email protected]>
My bad. That was an oversight on my part. I was quick to send it to the list without thinking about something like that.