Fix #312: Use correct type for message_write_float

message_write_float was declared to have arguments message_t,float,int. Change it to message_t,void*,int and update the implementation accordingly. This also means message_write_float needs to be updated to cast the void* to a float* so we can access the float.

Edited by Raymond Toy

Merge request reports

Loading
+4 −4
Changes for src/motif/server/datatrans.c: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -265,10 +265,10 @@ void message_write_color(message_t m,XColor *color,int tag)
  message_put_word(m,color->blue);
}

void message_write_float(message_t m,float f,int tag)
void message_write_float(message_t m,void *f,int tag)
{
  message_put_dblword(m,combine_type_and_data(tag,0));
  message_put_dblword(m,f);
  message_put_dblword(m,*(long *) f);
}


@@ -524,8 +524,8 @@ void message_read_color(message_t m,XColor *color,int tag, int red)

void message_read_float(message_t m,float *f,int tag,int data)
{
  fprintf(stderr,">>>>> Warning:message_read_float: Not implemented.\n");
  fflush(stderr);
  long d = message_get_dblword(m);
  memcpy(f, &d, sizeof(*f));
}


+1 −1
Changes for src/motif/server/datatrans.h: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ extern void message_write_int_list();
extern void message_write_event();
extern void message_write_color();
/* GCC complains without the full prototype */
extern void message_write_float(message_t,float,int);
extern void message_write_float(message_t,void *,int);



+2 −2
Changes for src/motif/server/tables.h: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -10,8 +10,8 @@
#ifndef TABLES_H
#define TABLES_H

typedef void (*type_writer)(message_t out,caddr_t src,int type_tag);
typedef void (*type_reader)(message_t in,caddr_t dest,int type_tag,int data);
typedef void (*type_writer)(message_t out,void *src,int type_tag);
typedef void (*type_reader)(message_t in,void *dest,int type_tag,int data);

typedef struct {
  String type;
Loading