]> xenbits.xensource.com Git - libvirt.git/commitdiff
build: fix type-punning bug
authorEric Blake <eblake@redhat.com>
Fri, 26 Oct 2012 18:53:45 +0000 (12:53 -0600)
committerEric Blake <eblake@redhat.com>
Fri, 26 Oct 2012 19:00:27 +0000 (13:00 -0600)
With older gcc and 64-bit size_t, the compiler issues a real warning:
rpc/virnetserverservice.c:277: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

Introduced in commit 0cc79255.  Depending on machine endianness,
this warning represents a real bug that could mis-interpret the
value by a factor of 2^32.  I don't know why I couldn't get newer
gcc to report the same warning message.

* src/rpc/virnetserverservice.c
(virNetServerServiceNewPostExecRestart): Use temporary instead.

src/rpc/virnetserverservice.c

index 8ac523cde22fe8375e535ae1bbb7d99d13d3d863..31a9424d81313aaa9b6afdc6eadce15d8fb47c43 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * virnetserverservice.c: generic network RPC server service
  *
- * Copyright (C) 2006-2011 Red Hat, Inc.
+ * Copyright (C) 2006-2012 Red Hat, Inc.
  * Copyright (C) 2006 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -274,11 +274,12 @@ virNetServerServicePtr virNetServerServiceNewPostExecRestart(virJSONValuePtr obj
         goto error;
     }
     if (virJSONValueObjectGetNumberUint(object, "nrequests_client_max",
-                                        (unsigned int *)&svc->nrequests_client_max) < 0) {
+                                        &n) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Missing nrequests_client_max field in JSON state document"));
         goto error;
     }
+    svc->nrequests_client_max = n;
 
     if (!(socks = virJSONValueObjectGet(object, "socks"))) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",