All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: xen-devel@lists.xensource.com
Subject: PATCH: Avoid struct members clashing with POSIX apis
Date: Wed, 22 Aug 2007 22:46:53 +0100	[thread overview]
Message-ID: <20070822214653.GP18061@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 995 bytes --]

The TPM code in tools/ioemu/hw/tpm_tis.c has a struct containing a number
of function pointers with names open, close, read, write which are the
same as various POSIX apis already #included in the file. POSIX allows
these functions to be defined as macros and latest GCC/glibc does indeed
define them as macros depending on compiler flags. This causes compile
errors when deferencing the struct members. The solution is either to
change calls like   ctx->open () to be (* ctx->open) (), or simply to
rename the struct members. Since this struct was only used inside that
one file i simply renamed them.

   Signed-off-by: Daniel P. Berrange <berrange@redhat.com>

Regards,
Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 

[-- Attachment #2: xen-tpm-functions.patch --]
[-- Type: text/plain, Size: 2407 bytes --]

diff -r 7953164cebb6 tools/ioemu/hw/tpm_tis.c
--- a/tools/ioemu/hw/tpm_tis.c	Tue Aug 07 09:07:29 2007 +0100
+++ b/tools/ioemu/hw/tpm_tis.c	Wed Aug 22 17:30:18 2007 -0400
@@ -154,16 +154,16 @@ static int has_channel_local_socket(tpmS
 #define NUM_TRANSPORTS 1
 
 struct vTPM_transmit {
-    int (*open) (tpmState *s, uint32_t vtpm_instance);
-    int (*write) (tpmState *s, const tpmBuffer *);
-    int (*read) (tpmState *s, tpmBuffer *);
-    int (*close) (tpmState *s, int);
+    int (*open_fn) (tpmState *s, uint32_t vtpm_instance);
+    int (*write_fn) (tpmState *s, const tpmBuffer *);
+    int (*read_fn) (tpmState *s, tpmBuffer *);
+    int (*close_fn) (tpmState *s, int);
     int (*has_channel) (tpmState *s);
 } vTPMTransmit[NUM_TRANSPORTS] = {
-    { .open = create_local_socket,
-      .write = write_local_socket,
-      .read = read_local_socket,
-      .close = close_local_socket,
+    { .open_fn = create_local_socket,
+      .write_fn = write_local_socket,
+      .read_fn = read_local_socket,
+      .close_fn = close_local_socket,
       .has_channel = has_channel_local_socket,
     }
 };
@@ -200,7 +200,7 @@ static void open_vtpm_channel(tpmState *
     int idx;
     /* search a usable transmit layer */
     for (idx = 0; idx < NUM_TRANSPORTS; idx++) {
-        if (1 == vTPMTransmit[idx].open(s, s->vtpm_instance)) {
+        if (1 == vTPMTransmit[idx].open_fn(s, s->vtpm_instance)) {
             /* found one */
             s->Transmitlayer = idx;
             break;
@@ -213,7 +213,7 @@ static void open_vtpm_channel(tpmState *
  */
 static inline void close_vtpm_channel(tpmState *s, int force)
 {
-    if (1 == vTPMTransmit[s->Transmitlayer].close(s, force)) {
+    if (1 == vTPMTransmit[s->Transmitlayer].close_fn(s, force)) {
         s->Transmitlayer = -1;
     }
 }
@@ -974,7 +974,7 @@ static int TPM_Send(tpmState *s, tpmBuff
     buffer->instance[0] &= 0x1f;
     buffer->instance[0] |= (locty << 5);
 
-    len = vTPMTransmit[s->Transmitlayer].write(s, buffer);
+    len = vTPMTransmit[s->Transmitlayer].write_fn(s, buffer);
     if (len < 0) {
         s->Transmitlayer = -1;
     }
@@ -990,7 +990,7 @@ static int TPM_Receive(tpmState *s, tpmB
 {
     int off;
 
-    off = vTPMTransmit[s->Transmitlayer].read(s, buffer);
+    off = vTPMTransmit[s->Transmitlayer].read_fn(s, buffer);
 
     if (off < 0) {
         /* EAGAIN is set in errno due to non-blocking mode */

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

                 reply	other threads:[~2007-08-22 21:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070822214653.GP18061@redhat.com \
    --to=berrange@redhat.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.