arm: Prevent -Wcast-align warnings.

See link below for a general description of the problem:

f8b62e4cd2
This commit is contained in:
Richard W.M. Jones
2012-12-27 18:05:40 +00:00
parent 5af94b5692
commit 364ee94b8d
5 changed files with 64 additions and 50 deletions

View File

@@ -43,6 +43,9 @@ static int inotify_fd = -1;
static char inotify_buf[64*1024*1024]; /* Event buffer, [0..posn-1] is valid */
static size_t inotify_posn = 0;
/* Because of use of arbitrary offsets within inotify_buf. */
#pragma GCC diagnostic ignored "-Wcast-align"
/* Clean up the inotify handle on daemon exit. */
static void inotify_finalize (void) __attribute__((destructor));
static void

View File

@@ -103,7 +103,7 @@ receive_stdout (int s)
else {
/* Extract the transferred file descriptor from the control data */
unsigned char *data = CMSG_DATA (h);
void *data = CMSG_DATA (h);
int fd = *(int *)data;
/* Duplicate the received file descriptor to stdout */
@@ -153,7 +153,7 @@ send_stdout (int s)
msg.msg_controllen = controllen;
/* Add STDOUT to the control data */
unsigned char *data = CMSG_DATA (cmptr);
void *data = CMSG_DATA (cmptr);
*(int *)data = STDOUT_FILENO;
if (sendmsg (s, &msg, 0) != 1) {

View File

@@ -1156,38 +1156,38 @@ guestfs__umount_local (guestfs_h *g,
* if you like.
*/
struct lsc_entry { /* lstat cache entry */
struct entry_common {
char *pathname; /* full path to the file */
time_t timeout; /* when this entry expires */
};
struct lsc_entry { /* lstat cache entry */
struct entry_common c;
struct stat statbuf; /* statbuf */
};
struct xac_entry { /* xattr cache entry */
/* NB first two fields must be same as lsc_entry */
char *pathname; /* full path to the file */
time_t timeout; /* when this entry expires */
struct entry_common c;
struct guestfs_xattr_list *xattrs;
};
struct rlc_entry { /* readlink cache entry */
/* NB first two fields must be same as lsc_entry */
char *pathname; /* full path to the file */
time_t timeout; /* when this entry expires */
struct entry_common c;
char *link;
};
static size_t
gen_hash (void const *x, size_t table_size)
{
struct lsc_entry const *p = x;
struct entry_common const *p = x;
return hash_pjw (p->pathname, table_size);
}
static bool
gen_compare (void const *x, void const *y)
{
struct lsc_entry const *a = x;
struct lsc_entry const *b = y;
struct entry_common const *a = x;
struct entry_common const *b = y;
return STREQ (a->pathname, b->pathname);
}
@@ -1195,7 +1195,7 @@ static void
lsc_free (void *x)
{
if (x) {
struct lsc_entry *p = x;
struct entry_common *p = x;
free (p->pathname);
free (p);
@@ -1264,7 +1264,7 @@ gen_remove_if_expired (void *x, void *data)
* with x == NULL.
*/
if (x) {
struct lsc_entry *p = x;
struct entry_common *p = x;
struct gen_remove_data *d = data;
if (p->timeout < d->now)
@@ -1298,9 +1298,9 @@ dir_cache_remove_all_expired (guestfs_h *g, time_t now)
}
static int
gen_replace (Hash_table *ht, struct lsc_entry *new_entry, Hash_data_freer freer)
gen_replace (Hash_table *ht, struct entry_common *new_entry, Hash_data_freer freer)
{
struct lsc_entry *old_entry;
struct entry_common *old_entry;
old_entry = hash_delete (ht, new_entry);
freer (old_entry);
@@ -1330,22 +1330,22 @@ lsc_insert (guestfs_h *g,
}
size_t len = strlen (path) + strlen (name) + 2;
entry->pathname = malloc (len);
if (entry->pathname == NULL) {
entry->c.pathname = malloc (len);
if (entry->c.pathname == NULL) {
perror ("malloc");
free (entry);
return -1;
}
if (STREQ (path, "/"))
snprintf (entry->pathname, len, "/%s", name);
snprintf (entry->c.pathname, len, "/%s", name);
else
snprintf (entry->pathname, len, "%s/%s", path, name);
snprintf (entry->c.pathname, len, "%s/%s", path, name);
memcpy (&entry->statbuf, statbuf, sizeof entry->statbuf);
entry->timeout = now + g->ml_dir_cache_timeout;
entry->c.timeout = now + g->ml_dir_cache_timeout;
return gen_replace (g->lsc_ht, entry, lsc_free);
return gen_replace (g->lsc_ht, (struct entry_common *) entry, lsc_free);
}
static int
@@ -1362,22 +1362,22 @@ xac_insert (guestfs_h *g,
}
size_t len = strlen (path) + strlen (name) + 2;
entry->pathname = malloc (len);
if (entry->pathname == NULL) {
entry->c.pathname = malloc (len);
if (entry->c.pathname == NULL) {
perror ("malloc");
free (entry);
return -1;
}
if (STREQ (path, "/"))
snprintf (entry->pathname, len, "/%s", name);
snprintf (entry->c.pathname, len, "/%s", name);
else
snprintf (entry->pathname, len, "%s/%s", path, name);
snprintf (entry->c.pathname, len, "%s/%s", path, name);
entry->xattrs = xattrs;
entry->timeout = now + g->ml_dir_cache_timeout;
entry->c.timeout = now + g->ml_dir_cache_timeout;
return gen_replace (g->xac_ht, (struct lsc_entry *) entry, xac_free);
return gen_replace (g->xac_ht, (struct entry_common *) entry, xac_free);
}
static int
@@ -1394,35 +1394,35 @@ rlc_insert (guestfs_h *g,
}
size_t len = strlen (path) + strlen (name) + 2;
entry->pathname = malloc (len);
if (entry->pathname == NULL) {
entry->c.pathname = malloc (len);
if (entry->c.pathname == NULL) {
perror ("malloc");
free (entry);
return -1;
}
if (STREQ (path, "/"))
snprintf (entry->pathname, len, "/%s", name);
snprintf (entry->c.pathname, len, "/%s", name);
else
snprintf (entry->pathname, len, "%s/%s", path, name);
snprintf (entry->c.pathname, len, "%s/%s", path, name);
entry->link = link;
entry->timeout = now + g->ml_dir_cache_timeout;
entry->c.timeout = now + g->ml_dir_cache_timeout;
return gen_replace (g->rlc_ht, (struct lsc_entry *) entry, rlc_free);
return gen_replace (g->rlc_ht, (struct entry_common *) entry, rlc_free);
}
static const struct stat *
lsc_lookup (guestfs_h *g, const char *pathname)
{
const struct lsc_entry key = { .pathname = (char *) pathname };
const struct entry_common key = { .pathname = (char *) pathname };
struct lsc_entry *entry;
time_t now;
time (&now);
entry = hash_lookup (g->lsc_ht, &key);
if (entry && entry->timeout >= now)
if (entry && entry->c.timeout >= now)
return &entry->statbuf;
else
return NULL;
@@ -1431,14 +1431,14 @@ lsc_lookup (guestfs_h *g, const char *pathname)
static const struct guestfs_xattr_list *
xac_lookup (guestfs_h *g, const char *pathname)
{
const struct xac_entry key = { .pathname = (char *) pathname };
const struct entry_common key = { .pathname = (char *) pathname };
struct xac_entry *entry;
time_t now;
time (&now);
entry = hash_lookup (g->xac_ht, &key);
if (entry && entry->timeout >= now)
if (entry && entry->c.timeout >= now)
return entry->xattrs;
else
return NULL;
@@ -1447,24 +1447,24 @@ xac_lookup (guestfs_h *g, const char *pathname)
static const char *
rlc_lookup (guestfs_h *g, const char *pathname)
{
const struct rlc_entry key = { .pathname = (char *) pathname };
const struct entry_common key = { .pathname = (char *) pathname };
struct rlc_entry *entry;
time_t now;
time (&now);
entry = hash_lookup (g->rlc_ht, &key);
if (entry && entry->timeout >= now)
if (entry && entry->c.timeout >= now)
return entry->link;
else
return NULL;
}
static void
lsc_remove (Hash_table *ht, const char *pathname, Hash_data_freer freer)
gen_remove (Hash_table *ht, const char *pathname, Hash_data_freer freer)
{
const struct lsc_entry key = { .pathname = (char *) pathname };
struct lsc_entry *entry;
const struct entry_common key = { .pathname = (char *) pathname };
struct entry_common *entry;
entry = hash_delete (ht, &key);
@@ -1474,9 +1474,9 @@ lsc_remove (Hash_table *ht, const char *pathname, Hash_data_freer freer)
static void
dir_cache_invalidate (guestfs_h *g, const char *path)
{
lsc_remove (g->lsc_ht, path, lsc_free);
lsc_remove (g->xac_ht, path, xac_free);
lsc_remove (g->rlc_ht, path, rlc_free);
gen_remove (g->lsc_ht, path, lsc_free);
gen_remove (g->xac_ht, path, xac_free);
gen_remove (g->rlc_ht, path, rlc_free);
}
#else /* !HAVE_FUSE */

View File

@@ -233,6 +233,9 @@ read_rpm_name (guestfs_h *g,
return 0;
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-align"
/* tag constants, see rpmtag.h in RPM for complete list */
#define RPMTAG_VERSION 1001
#define RPMTAG_RELEASE 1002
@@ -279,6 +282,8 @@ get_rpm_header_tag (guestfs_h *g, const unsigned char *header_start,
return NULL;
}
#pragma GCC diagnostic pop
struct read_package_data {
struct rpm_names_list *list;
struct guestfs_application2_list *apps;

View File

@@ -81,7 +81,7 @@ free_regexps (void)
static int check_windows_arch (guestfs_h *g, struct inspect_fs *fs);
static int check_windows_software_registry (guestfs_h *g, struct inspect_fs *fs);
static int check_windows_system_registry (guestfs_h *g, struct inspect_fs *fs);
static char *map_registry_disk_blob (guestfs_h *g, const char *blob);
static char *map_registry_disk_blob (guestfs_h *g, const void *blob);
/* XXX Handling of boot.ini in the Perl version was pretty broken. It
* essentially didn't do anything for modern Windows guests.
@@ -343,7 +343,7 @@ check_windows_system_registry (guestfs_h *g, struct inspect_fs *fs)
struct guestfs_hivex_value_list *values = NULL;
int32_t dword;
size_t i, count;
char *buf = NULL;
void *buf = NULL;
size_t buflen;
const char *hivepath[] =
{ NULL /* current control set */, "Services", "Tcpip", "Parameters" };
@@ -501,7 +501,7 @@ check_windows_system_registry (guestfs_h *g, struct inspect_fs *fs)
* name, if possible.
*/
static char *
map_registry_disk_blob (guestfs_h *g, const char *blob)
map_registry_disk_blob (guestfs_h *g, const void *blob)
{
char **devices = NULL;
struct guestfs_partition_list *partitions = NULL;
@@ -538,8 +538,14 @@ map_registry_disk_blob (guestfs_h *g, const char *blob)
/* Next 8 bytes are the offset of the partition in bytes(!) given as
* a 64 bit little endian number. Luckily it's easy to get the
* partition byte offset from guestfs_part_list.
*
* Note deliberate cast-align violation here since the data is in a
* very odd place within the blob. Thanks Microsoft!
*/
part_offset = le64toh (* (uint64_t *) &blob[4]);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-align"
part_offset = le64toh (* (uint64_t *) ((char *) blob + 4));
#pragma GCC diagnostic pop
partitions = guestfs_part_list (g, devices[i]);
if (partitions == NULL)