virNetServerClientNewPostExecRestart: Avoid align problems

I've noticed this while trying to compile libvirt on my arm box.

  CC       rpc/libvirt_net_rpc_server_la-virnetserverclient.lo
rpc/virnetserverclient.c: In function 'virNetServerClientNewPostExecRestart':
rpc/virnetserverclient.c:516:45: error: cast increases required alignment of target type [-Werror=cast-align]
                                             (long long *) &timestamp) < 0) {
                                             ^
cc1: all warnings being treated as errors

Problem is, @timestap is defined as time_t which is 32 bits long,
and we are typecasting it to long long which is 64bits long.
Solution is to make @timestamp type of long long. At the same
time, we can make @conn_time in _virNetServerClient struct long
long too. There is no need for it to be type of time_t.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik 2016-05-05 09:07:50 +02:00
parent 2a3a2c2f5b
commit b17e610e1f

View File

@ -90,7 +90,7 @@ struct _virNetServerClient
* attribute, value of 0 (epoch time) is used to indicate we have no
* information about their connection time.
*/
time_t conn_time;
long long conn_time;
/* Count of messages in the 'tx' queue,
* and the server worker pool queue
@ -363,7 +363,7 @@ virNetServerClientNewInternal(unsigned long long id,
#endif
bool readonly,
size_t nrequests_max,
time_t timestamp)
long long timestamp)
{
virNetServerClientPtr client;
@ -472,7 +472,7 @@ virNetServerClientPtr virNetServerClientNewPostExecRestart(virJSONValuePtr objec
bool readonly;
unsigned int nrequests_max;
unsigned long long id;
time_t timestamp;
long long timestamp;
if (virJSONValueObjectGetNumberInt(object, "auth", &auth) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@ -511,8 +511,7 @@ virNetServerClientPtr virNetServerClientNewPostExecRestart(virJSONValuePtr objec
if (!virJSONValueObjectHasKey(object, "conn_time")) {
timestamp = 0;
} else {
if (virJSONValueObjectGetNumberLong(object, "conn_time",
(long long *) &timestamp) < 0) {
if (virJSONValueObjectGetNumberLong(object, "conn_time", &timestamp) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Malformed conn_time field in JSON "
"state document"));