]> xenbits.xensource.com Git - libvirt.git/commitdiff
virNetServerClientNewPostExecRestart: Avoid align problems
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 5 May 2016 07:07:50 +0000 (09:07 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 5 May 2016 11:48:56 +0000 (13:48 +0200)
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>
src/rpc/virnetserverclient.c

index d3a3a18f932b0956f778f37630649c75190f7416..ef835072c15d26a9097a07468b6a370ee0471d04 100644 (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"));