diff options
author | Daniel Friesel <derf@finalrewind.org> | 2018-12-05 14:41:08 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2018-12-05 14:41:08 +0100 |
commit | 9df610bbcde89aed4fb71f1fa73d9246ee1fe370 (patch) | |
tree | 9f1c9762d4fc398cc502d89a5081c0d55f44e0ff /src/os/object/xdrinput.cc | |
parent | bb1c35235b71079b20f469421a895b038bcfa0db (diff) |
XDR: Use unions instead of casts for float/double<->int conversion
Diffstat (limited to 'src/os/object/xdrinput.cc')
-rw-r--r-- | src/os/object/xdrinput.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/os/object/xdrinput.cc b/src/os/object/xdrinput.cc index 5fb17bf..612244e 100644 --- a/src/os/object/xdrinput.cc +++ b/src/os/object/xdrinput.cc @@ -37,14 +37,22 @@ int64_t XDRInput::get_int64() float XDRInput::get_float() { - uint32_t val = get_uint32(); - return *(float*)&val; + union { + uint32_t i; + float f; + } v; + v.i = get_uint32(); + return v.f; } double XDRInput::get_double() { - uint64_t val = get_uint64(); - return *(double*)&val; + union { + uint64_t i; + double d; + } v; + v.i = get_uint64(); + return v.d; } uint32_t XDRInput::get_opaque_length() |