summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2016-05-08 23:33:46 -0400
committerGravatar Lioncash2016-05-08 23:33:52 -0400
commitd5b983a8c000533ca17b727595e813113cd9d54c (patch)
tree4fa60b58f6336bbf15eb8621e082cbd8b7126f19 /src
parentswap: Get rid of undefined behavior in swapf and swapd (diff)
downloadyuzu-d5b983a8c000533ca17b727595e813113cd9d54c.tar.gz
yuzu-d5b983a8c000533ca17b727595e813113cd9d54c.tar.xz
yuzu-d5b983a8c000533ca17b727595e813113cd9d54c.zip
swap: Get rid of pointer casting for swapping structs
These shouldn't haphazardly convert types
Diffstat (limited to 'src')
-rw-r--r--src/common/swap.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/common/swap.h b/src/common/swap.h
index beedd6c7e..1749bd7a4 100644
--- a/src/common/swap.h
+++ b/src/common/swap.h
@@ -510,35 +510,35 @@ bool operator==(const S &p, const swap_struct_t<T, F> v) {
510template <typename T> 510template <typename T>
511struct swap_64_t { 511struct swap_64_t {
512 static T swap(T x) { 512 static T swap(T x) {
513 return (T)Common::swap64(*(u64 *)&x); 513 return static_cast<T>(Common::swap64(x));
514 } 514 }
515}; 515};
516 516
517template <typename T> 517template <typename T>
518struct swap_32_t { 518struct swap_32_t {
519 static T swap(T x) { 519 static T swap(T x) {
520 return (T)Common::swap32(*(u32 *)&x); 520 return static_cast<T>(Common::swap32(x));
521 } 521 }
522}; 522};
523 523
524template <typename T> 524template <typename T>
525struct swap_16_t { 525struct swap_16_t {
526 static T swap(T x) { 526 static T swap(T x) {
527 return (T)Common::swap16(*(u16 *)&x); 527 return static_cast<T>(Common::swap16(x));
528 } 528 }
529}; 529};
530 530
531template <typename T> 531template <typename T>
532struct swap_float_t { 532struct swap_float_t {
533 static T swap(T x) { 533 static T swap(T x) {
534 return (T)Common::swapf(*(float *)&x); 534 return static_cast<T>(Common::swapf(x));
535 } 535 }
536}; 536};
537 537
538template <typename T> 538template <typename T>
539struct swap_double_t { 539struct swap_double_t {
540 static T swap(T x) { 540 static T swap(T x) {
541 return (T)Common::swapd(*(double *)&x); 541 return static_cast<T>(Common::swapd(x));
542 } 542 }
543}; 543};
544 544