ruby-changes:37631
From: nobu <ko1@a...>
Date: Tue, 24 Feb 2015 12:34:25 +0900 (JST)
Subject: [ruby-changes:37631] nobu:r49712 (trunk): dir.c: use packed structs
nobu 2015-02-24 12:34:10 +0900 (Tue, 24 Feb 2015) New Revision: 49712 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49712 Log: dir.c: use packed structs * dir.c (is_case_sensitive, replace_real_basename): [OSX] use packed structs instead of arrays to suppress warning by older versions of gcc. Modified files: trunk/dir.c Index: dir.c =================================================================== --- dir.c (revision 49711) +++ dir.c (revision 49712) @@ -1401,9 +1401,12 @@ join_path(const char *path, long len, in https://github.com/ruby/ruby/blob/trunk/dir.c#L1401 static int is_case_sensitive(DIR *dirp) { - u_int32_t attrbuf[SIZEUP32(vol_capabilities_attr_t) + 1]; + struct { + u_int32_t length; + vol_capabilities_attr_t cap[1]; + } __attribute__((aligned(4), packed)) attrbuf[1]; struct attrlist al = {ATTR_BIT_MAP_COUNT, 0, 0, ATTR_VOL_INFO|ATTR_VOL_CAPABILITIES}; - const vol_capabilities_attr_t *cap = (void *)(attrbuf+1); + const vol_capabilities_attr_t *const cap = attrbuf[0].cap; const int idx = VOL_CAPABILITIES_FORMAT; const uint32_t mask = VOL_CAP_FMT_CASE_SENSITIVE; struct statfs sf; @@ -1419,9 +1422,13 @@ is_case_sensitive(DIR *dirp) https://github.com/ruby/ruby/blob/trunk/dir.c#L1422 static char * replace_real_basename(char *path, long base, rb_encoding *enc, int norm_p) { - u_int32_t attrbuf[SIZEUP32(attrreference_t) + RUP32(MAXPATHLEN * 3) + 1]; + struct { + u_int32_t length; + attrreference_t ref[1]; + char path[MAXPATHLEN * 3]; + } __attribute__((aligned(4), packed)) attrbuf[1]; struct attrlist al = {ATTR_BIT_MAP_COUNT, 0, ATTR_CMN_NAME}; - const attrreference_t *ar = (void *)(attrbuf+1); + const attrreference_t *const ar = attrbuf[0].ref; const char *name; long len; char *tmp; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/