summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-24 03:34:10 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-24 03:34:10 +0000
commit7294d08d489d075e54927fde3b71010683c7c93b (patch)
treea9ed8bcdd96caed2bf7e334c07380816ed45068d
parente97b684c02ebdf9a238ce863a14700d92c61c2e0 (diff)
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--dir.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/dir.c b/dir.c
index 0b6c0aa31e..b394bda3d0 100644
--- a/dir.c
+++ b/dir.c
@@ -1401,9 +1401,12 @@ join_path(const char *path, long len, int dirsep, const char *name, size_t namle
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)
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;