Olaf Hering
2013-Aug-20 14:33 UTC
[Libguestfs] [PATCH] lib: avoid pragma usage in journal.c
journal.c: In function 'guestfs__journal_get': journal.c:120:9: error: #pragma GCC diagnostic not allowed inside functions journal.c:121:9: error: #pragma GCC diagnostic not allowed inside functions journal.c:123:9: error: #pragma GCC diagnostic not allowed inside functions make[3]: *** [libguestfs_la-journal.lo] Error 1 Signed-off-by: Olaf Hering <olaf@aepfle.de> --- Not compiled. src/journal.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/journal.c b/src/journal.c index cac8040..61ab352 100644 --- a/src/journal.c +++ b/src/journal.c @@ -117,10 +117,8 @@ guestfs__journal_get (guestfs_h *g) "size=%zu, i=%zu", size, i); goto err; } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wcast-align" - len = be64toh (* (uint64_t *) &buf[i]); -#pragma GCC diagnostic pop + memcpy(&len, &buf[i], sizeof(len)); + len = be64toh (len); i += 8; eofield = &buf[i+len]; if (eofield > eobuf) {
Richard W.M. Jones
2013-Aug-20 17:30 UTC
Re: [Libguestfs] [PATCH] lib: avoid pragma usage in journal.c
On Tue, Aug 20, 2013 at 04:33:01PM +0200, Olaf Hering wrote:> journal.c: In function 'guestfs__journal_get': > journal.c:120:9: error: #pragma GCC diagnostic not allowed inside functions > journal.c:121:9: error: #pragma GCC diagnostic not allowed inside functions > journal.c:123:9: error: #pragma GCC diagnostic not allowed inside functions > make[3]: *** [libguestfs_la-journal.lo] Error 1 > > Signed-off-by: Olaf Hering <olaf@aepfle.de> > --- > > Not compiled. > > src/journal.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/src/journal.c b/src/journal.c > index cac8040..61ab352 100644 > --- a/src/journal.c > +++ b/src/journal.c > @@ -117,10 +117,8 @@ guestfs__journal_get (guestfs_h *g) > "size=%zu, i=%zu", size, i); > goto err; > } > -#pragma GCC diagnostic push > -#pragma GCC diagnostic ignored "-Wcast-align" > - len = be64toh (* (uint64_t *) &buf[i]); > -#pragma GCC diagnostic pop > + memcpy(&len, &buf[i], sizeof(len)); > + len = be64toh (len);Yes, this is a much better way of doing it. There are probably a few others like this. Thanks - I have pushed this patch and the other one you posted. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
Maybe Matching Threads
- Re: [nbdkit PATCH 7/7] nbd: Implement structured replies
- [PATCH 0/2] Two build fixes for libldm
- [libnbd PATCH 2/8] states: Consolidate search for current reply's command
- [libnbd PATCH v4 4/4] internal: Refactor layout of replies in sbuf
- [PATCH libnbd 1/3] states: Factor out common code for setting export size and eflags.