[前][次][番号順一覧][スレッド一覧]

ruby-changes:33588

From: nobu <ko1@a...>
Date: Tue, 22 Apr 2014 23:01:58 +0900 (JST)
Subject: [ruby-changes:33588] nobu:r45669 (trunk): file.c: suppress a warning

nobu	2014-04-22 23:01:51 +0900 (Tue, 22 Apr 2014)

  New Revision: 45669

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45669

  Log:
    file.c: suppress a warning
    
    * file.c (statfs_fsid): use union to suppress strict-aliasing
      warning.

  Modified files:
    trunk/file.c
Index: file.c
===================================================================
--- file.c	(revision 45668)
+++ file.c	(revision 45669)
@@ -5529,8 +5529,12 @@ statfs_ffree(VALUE self) https://github.com/ruby/ruby/blob/trunk/file.c#L5529
 static VALUE
 statfs_fsid(VALUE self)
 {
-    fsid_t n = get_statfs(self)->f_fsid;
-    return LL2NUM(*(LONG_LONG*)&n);
+    union {
+	uint64_t v;
+	fsid_t f;
+    } n = {0};
+    n.f = get_statfs(self)->f_fsid;
+    return LL2NUM(n.v);
 }
 
 #ifdef HAVE_STRUCT_STATFS_F_FSTYPENAME

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]