Skip to content

Commit

Permalink
Merge pull request #42 from artfwo/waddress-of-packed-member
Browse files Browse the repository at this point in the history
fix address-of-packed-member compiler warnings (fixes #28)
  • Loading branch information
artfwo authored Jan 15, 2018
2 parents 344fa73 + 3832ac0 commit 7d7cb82
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
14 changes: 6 additions & 8 deletions include/serialosc/ipc.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@

#include <stdint.h>

#ifndef PACKED
#define PACKED __attribute__((__packed__))
#endif

#ifdef WIN32
#define SOSC_PIPE_PREFIX "\\\\.\\pipe\\org.monome.serialosc-"
#define SOSC_DETECTOR_PIPE (SOSC_PIPE_PREFIX "detector")
#endif

#define SOSC_IPC_MSG_BUFFER_SIZE 256

typedef enum {
/* device -> supervisor */
SOSC_DEVICE_CONNECTION,
Expand All @@ -45,20 +43,20 @@ typedef struct sosc_ipc_msg {
__extension__ union {
struct {
char *devnode;
} PACKED connection;
} connection;

struct {
char *serial;
char *friendly;
} PACKED device_info;
} device_info;

struct {
uint16_t port;
} PACKED port_change;
} port_change;
};

uint16_t magic;
} PACKED sosc_ipc_msg_t;
} sosc_ipc_msg_t;

int sosc_ipc_msg_write(int fd, sosc_ipc_msg_t *msg);
int sosc_ipc_msg_read(int fd, sosc_ipc_msg_t *buf);
Expand Down
2 changes: 1 addition & 1 deletion src/common/ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ read_strdata(int fd, size_t n, ...)
int
sosc_ipc_msg_write(int fd, sosc_ipc_msg_t *msg)
{
uint8_t buf[64];
uint8_t buf[SOSC_IPC_MSG_BUFFER_SIZE];
ssize_t written;
ssize_t bufsiz;

Expand Down
2 changes: 1 addition & 1 deletion src/serialosc-detector/windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct detector_state {
static void
send_connect(const struct detector_state *state, char *port)
{
uint8_t buf[64];
uint8_t buf[SOSC_IPC_MSG_BUFFER_SIZE];
DWORD written;
size_t bufsiz;

Expand Down
2 changes: 1 addition & 1 deletion src/serialosc-device/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ static void
send_ipc_msg(sosc_ipc_msg_t *msg)
{
HANDLE p = (HANDLE) _get_osfhandle(STDOUT_FILENO);
uint8_t buf[64];
uint8_t buf[SOSC_IPC_MSG_BUFFER_SIZE];
DWORD written;
ssize_t bufsiz;

Expand Down
2 changes: 1 addition & 1 deletion src/serialoscd/uv.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ write_ipc_msg_to_stream(uv_stream_t *stream, struct sosc_ipc_msg *msg)
{
uv_buf_t uv_buf;
uv_write_t *req;
uint8_t buf[64];
uint8_t buf[SOSC_IPC_MSG_BUFFER_SIZE];
ssize_t nbytes;

nbytes = sosc_ipc_msg_to_buf(buf, sizeof(buf), msg);
Expand Down

0 comments on commit 7d7cb82

Please sign in to comment.