ia64/xen-unstable

changeset 15789:8e9ec8711efa

ioemu: Avoid struct members clashing with POSIX apis

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>
author kfraser@localhost.localdomain
date Tue Aug 28 16:13:35 2007 +0100 (2007-08-28)
parents 8e3abd893835
children 86a02b7148fa
files tools/ioemu/hw/tpm_tis.c
line diff
     1.1 --- a/tools/ioemu/hw/tpm_tis.c	Tue Aug 28 16:11:05 2007 +0100
     1.2 +++ b/tools/ioemu/hw/tpm_tis.c	Tue Aug 28 16:13:35 2007 +0100
     1.3 @@ -154,16 +154,16 @@ static int has_channel_local_socket(tpmS
     1.4  #define NUM_TRANSPORTS 1
     1.5  
     1.6  struct vTPM_transmit {
     1.7 -    int (*open) (tpmState *s, uint32_t vtpm_instance);
     1.8 -    int (*write) (tpmState *s, const tpmBuffer *);
     1.9 -    int (*read) (tpmState *s, tpmBuffer *);
    1.10 -    int (*close) (tpmState *s, int);
    1.11 +    int (*open_fn) (tpmState *s, uint32_t vtpm_instance);
    1.12 +    int (*write_fn) (tpmState *s, const tpmBuffer *);
    1.13 +    int (*read_fn) (tpmState *s, tpmBuffer *);
    1.14 +    int (*close_fn) (tpmState *s, int);
    1.15      int (*has_channel) (tpmState *s);
    1.16  } vTPMTransmit[NUM_TRANSPORTS] = {
    1.17 -    { .open = create_local_socket,
    1.18 -      .write = write_local_socket,
    1.19 -      .read = read_local_socket,
    1.20 -      .close = close_local_socket,
    1.21 +    { .open_fn = create_local_socket,
    1.22 +      .write_fn = write_local_socket,
    1.23 +      .read_fn = read_local_socket,
    1.24 +      .close_fn = close_local_socket,
    1.25        .has_channel = has_channel_local_socket,
    1.26      }
    1.27  };
    1.28 @@ -200,7 +200,7 @@ static void open_vtpm_channel(tpmState *
    1.29      int idx;
    1.30      /* search a usable transmit layer */
    1.31      for (idx = 0; idx < NUM_TRANSPORTS; idx++) {
    1.32 -        if (1 == vTPMTransmit[idx].open(s, s->vtpm_instance)) {
    1.33 +        if (1 == vTPMTransmit[idx].open_fn(s, s->vtpm_instance)) {
    1.34              /* found one */
    1.35              s->Transmitlayer = idx;
    1.36              break;
    1.37 @@ -213,7 +213,7 @@ static void open_vtpm_channel(tpmState *
    1.38   */
    1.39  static inline void close_vtpm_channel(tpmState *s, int force)
    1.40  {
    1.41 -    if (1 == vTPMTransmit[s->Transmitlayer].close(s, force)) {
    1.42 +    if (1 == vTPMTransmit[s->Transmitlayer].close_fn(s, force)) {
    1.43          s->Transmitlayer = -1;
    1.44      }
    1.45  }
    1.46 @@ -974,7 +974,7 @@ static int TPM_Send(tpmState *s, tpmBuff
    1.47      buffer->instance[0] &= 0x1f;
    1.48      buffer->instance[0] |= (locty << 5);
    1.49  
    1.50 -    len = vTPMTransmit[s->Transmitlayer].write(s, buffer);
    1.51 +    len = vTPMTransmit[s->Transmitlayer].write_fn(s, buffer);
    1.52      if (len < 0) {
    1.53          s->Transmitlayer = -1;
    1.54      }
    1.55 @@ -990,7 +990,7 @@ static int TPM_Receive(tpmState *s, tpmB
    1.56  {
    1.57      int off;
    1.58  
    1.59 -    off = vTPMTransmit[s->Transmitlayer].read(s, buffer);
    1.60 +    off = vTPMTransmit[s->Transmitlayer].read_fn(s, buffer);
    1.61  
    1.62      if (off < 0) {
    1.63          /* EAGAIN is set in errno due to non-blocking mode */