Changeset 476


Ignore:
Timestamp:
Apr 15, 2011, 7:34:53 AM (6 years ago)
Author:
sam
Message:

Fix a few compiler warnings caused by bad type punning.

Location:
abuse/trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/cache.cpp

    r162 r476  
    524524    for (i=0;i<tsaved;i++)
    525525    {
    526       uint8_t type=fp->read_uint8();
     526      fp->read_uint8(); // read type
    527527      short file_num=fp->read_uint16();
    528528      if (file_num>=tnames)  // bad data?
  • abuse/trunk/src/imlib/palette.cpp

    r162 r476  
    100100
    101101uint32_t palette::getquad(int x)
    102 { char entry[4];
     102{ union { char entry[4]; uint32_t ret; };
    103103  entry[3]=0;
    104104  entry[2]=pal[x].red;
    105105  entry[1]=pal[x].green;
    106106  entry[0]=pal[x].blue;
    107   return *((uint32_t *)entry);
     107  return ret;
    108108}
    109109
     
    261261  else if (ncolors==16)
    262262    for (i=0;i<ncolors;i++)
    263       set(i,255-(i&3),255-(i&4)>>2,255-(i&8)>>3);
     263      set(i,255-(i&3),255-((i&4)>>2),255-((i&8)>>3));
    264264  else
    265265    for (i=0;i<ncolors;i++)
  • abuse/trunk/src/net/fileman.cpp

    r125 r476  
    141141
    142142    actual=read(file_fd,buf+2,read_total);
    143     *((ushort *)buf)=lstl(actual);
     143    ushort tmp = lstl(actual);
     144    memcpy(buf, &tmp, sizeof(tmp));
    144145
    145146    int write_amount=sock->write(buf,actual+2);
  • abuse/trunk/src/netface.hpp

    r124 r476  
    107107  uint8_t data[PACKET_MAX_SIZE];
    108108  int packet_prefix_size()                 { return 5; }    // 2 byte size, 2 byte check sum, 1 byte packet order
    109   uint16_t packet_size()             { uint16_t size=(*(uint16_t *)data); return lstl(size); }
     109  uint16_t packet_size()             { uint16_t size; memcpy(&size, data, sizeof(size)); return lstl(size); }
    110110  uint8_t tick_received()            { return data[4]; }
    111111  void set_tick_received(uint8_t x)  { data[4]=x; }
     
    142142  void write_uint32(uint32_t x) { x=lltl(x); add_to_packet(&x,4); }
    143143
    144   void set_packet_size(uint16_t x) { *((uint16_t *)data)=lstl(x); }
     144  void set_packet_size(uint16_t x) { uint16_t tmp = lstl(x); memcpy(data, &tmp, sizeof(tmp)); }
    145145
    146146
Note: See TracChangeset for help on using the changeset viewer.