From b57ea2c975d52aa19201642d3c008abf2f0556ff Mon Sep 17 00:00:00 2001 From: proski Date: Mon, 8 Jun 2009 13:25:54 +0000 Subject: [PATCH] 2009-06-08 Pavel Roskin * fs/hfs.c (grub_hfs_find_dir): Use union to avoid a warning about aliasing. --- ChangeLog | 5 +++++ fs/hfs.c | 17 ++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 92dd90c90..b9ef1ba40 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-06-08 Pavel Roskin + + * fs/hfs.c (grub_hfs_find_dir): Use union to avoid a warning + about aliasing. + 2009-06-08 Felix Zielcke * Makefile.in (uninstall): Remove all $lib_DATA files. diff --git a/fs/hfs.c b/fs/hfs.c index fe5d2694f..e8821e092 100644 --- a/fs/hfs.c +++ b/fs/hfs.c @@ -872,9 +872,12 @@ grub_hfs_find_dir (struct grub_hfs_data *data, const char *path, int inode = data->rootdir; char *next; char *origpath; - struct grub_hfs_filerec frec; - struct grub_hfs_dirrec *dir = (struct grub_hfs_dirrec *) &frec; - frec.type = GRUB_HFS_FILETYPE_DIR; + union { + struct grub_hfs_filerec frec; + struct grub_hfs_dirrec dir; + } fdrec; + + fdrec.frec.type = GRUB_HFS_FILETYPE_DIR; if (path[0] != '/') { @@ -892,7 +895,7 @@ grub_hfs_find_dir (struct grub_hfs_data *data, const char *path, while (path && grub_strlen (path)) { - if (frec.type != GRUB_HFS_FILETYPE_DIR) + if (fdrec.frec.type != GRUB_HFS_FILETYPE_DIR) { grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); goto fail; @@ -914,7 +917,7 @@ grub_hfs_find_dir (struct grub_hfs_data *data, const char *path, /* Lookup this node. */ if (! grub_hfs_find_node (data, (char *) &key, data->cat_root, - 0, (char *) &frec, sizeof (frec))) + 0, (char *) &fdrec.frec, sizeof (fdrec.frec))) { grub_error (GRUB_ERR_FILE_NOT_FOUND, "file not found"); goto fail; @@ -923,12 +926,12 @@ grub_hfs_find_dir (struct grub_hfs_data *data, const char *path, if (grub_errno) goto fail; - inode = grub_be_to_cpu32 (dir->dirid); + inode = grub_be_to_cpu32 (fdrec.dir.dirid); path = next; } if (retdata) - grub_memcpy (retdata, &frec, sizeof (frec)); + grub_memcpy (retdata, &fdrec.frec, sizeof (fdrec.frec)); if (retinode) *retinode = inode;