diff options
| author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2025-07-23 19:15:24 +0200 | 
|---|---|---|
| committer | Sander Vrijders <sander@ouroboros.rocks> | 2025-07-25 16:24:46 +0200 | 
| commit | 408c977f7be09db3b8aa98224989aec731eb0b5a (patch) | |
| tree | ec8781aae11e7b2ec459f541d36252020c2eff3a | |
| parent | 1856a585ae4290e666314ee7907dc8cbbb08fe2d (diff) | |
| download | ouroboros-408c977f7be09db3b8aa98224989aec731eb0b5a.tar.gz ouroboros-408c977f7be09db3b8aa98224989aec731eb0b5a.zip  | |
lib: Swap len and data in the buffer_t
This is how the ProtoBufCBinary data type is defined, so it will allow
easier conversion until we get rid of it. But it makes sense, as the
size_t will always be aligned.
Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
| -rw-r--r-- | include/ouroboros/utils.h | 4 | ||||
| -rw-r--r-- | src/ipcpd/broadcast/main.c | 2 | ||||
| -rw-r--r-- | src/irmd/main.c | 2 | ||||
| -rw-r--r-- | src/irmd/reg/tests/flow_test.c | 2 | ||||
| -rw-r--r-- | src/irmd/reg/tests/reg_test.c | 12 | ||||
| -rw-r--r-- | src/lib/dev.c | 20 | 
6 files changed, 21 insertions, 21 deletions
diff --git a/include/ouroboros/utils.h b/include/ouroboros/utils.h index 9c48b039..e1f0ca0e 100644 --- a/include/ouroboros/utils.h +++ b/include/ouroboros/utils.h @@ -33,11 +33,11 @@  #define ABS(a)   ((a) > 0 ? (a) : -(a))  #define clrbuf(buf) do { memset(&(buf), 0, sizeof(buf)); } while (0);  #define freebuf(buf) do { free((buf).data); clrbuf(buf); } while (0); -#define BUF_INIT { NULL, 0 } +#define BUF_INIT { 0, NULL }  typedef struct { -        uint8_t * data;          size_t    len; +        uint8_t * data;  } buffer_t;  /* diff --git a/src/ipcpd/broadcast/main.c b/src/ipcpd/broadcast/main.c index 02355570..0f2bf26c 100644 --- a/src/ipcpd/broadcast/main.c +++ b/src/ipcpd/broadcast/main.c @@ -207,7 +207,7 @@ static int broadcast_ipcp_join(int             fd,  {          struct conn conn;          time_t      mpl = IPCP_BROADCAST_MPL; -        buffer_t    data = {NULL, 0}; +        buffer_t    data = {0, NULL};          (void) qs; diff --git a/src/irmd/main.c b/src/irmd/main.c index 3a1a7225..e0be8a01 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -920,7 +920,7 @@ static int flow_join(struct flow_info * flow,          struct ipcp_info  ipcp;          struct layer_info layer;          buffer_t          hash; -        buffer_t          pbuf = {NULL, 0}; /* nothing to piggyback */ +        buffer_t          pbuf = {0, NULL}; /* nothing to piggyback */          int               err;          log_info("Allocating flow for %d to %s.", flow->n_pid, dst); diff --git a/src/irmd/reg/tests/flow_test.c b/src/irmd/reg/tests/flow_test.c index 3e586341..27fd61b0 100644 --- a/src/irmd/reg/tests/flow_test.c +++ b/src/irmd/reg/tests/flow_test.c @@ -232,7 +232,7 @@ static int test_flow_data(void)          char * data;          buffer_t buf; -        buffer_t rcv = {NULL, 0}; +        buffer_t rcv = {0, NULL};          TEST_START(); diff --git a/src/irmd/reg/tests/reg_test.c b/src/irmd/reg/tests/reg_test.c index b69cf476..7f3ba32d 100644 --- a/src/irmd/reg/tests/reg_test.c +++ b/src/irmd/reg/tests/reg_test.c @@ -115,7 +115,7 @@ static int test_reg_allocate_flow_timeout(void)  {          struct timespec abstime;          struct timespec timeo = TIMESPEC_INIT_MS(1); -        buffer_t        rbuf = {NULL, 0}; +        buffer_t        rbuf = {0, NULL};          struct flow_info info = {                  .n_pid = TEST_PID, @@ -173,7 +173,7 @@ static int test_reg_allocate_flow_timeout(void)  static void * test_flow_respond_alloc(void * o)  {          struct flow_info * info = (struct flow_info *) o; -        buffer_t           pbuf = {NULL, 0}; +        buffer_t           pbuf = {0, NULL};          if (info->state == FLOW_ALLOCATED) {                  pbuf.data = (uint8_t *) strdup(TEST_DATA2); @@ -215,7 +215,7 @@ static int test_reg_accept_flow_success(void)          pthread_t       thr;          struct timespec abstime;          struct timespec timeo = TIMESPEC_INIT_S(1); -        buffer_t        rbuf  = {NULL, 0}; +        buffer_t        rbuf  = {0, NULL};          struct flow_info info = {                  .n_pid = TEST_PID, @@ -309,7 +309,7 @@ static int test_reg_accept_flow_success_no_crypt(void)          pthread_t       thr;          struct timespec abstime;          struct timespec timeo = TIMESPEC_INIT_S(1); -        buffer_t        rbuf  = {NULL, 0}; +        buffer_t        rbuf  = {0, NULL};          struct flow_info info = {                  .n_pid = TEST_PID, @@ -398,7 +398,7 @@ static int test_reg_accept_flow_success_no_crypt(void)  static int test_reg_allocate_flow_fail(void)  { -        buffer_t        buf   = {NULL, 0}; +        buffer_t        buf   = {0, NULL};          pthread_t       thr;          struct timespec abstime;          struct timespec timeo = TIMESPEC_INIT_S(1); @@ -1118,7 +1118,7 @@ static void * test_call_flow_accept(void * o)  {          struct timespec abstime;          struct timespec timeo = TIMESPEC_INIT_MS(1); -        buffer_t        pbuf = {NULL, 0}; +        buffer_t        pbuf = {0, NULL};          struct proc_info pinfo = {                  .pid =  TEST_PID, diff --git a/src/lib/dev.c b/src/lib/dev.c index c22b4f06..9df5fd46 100644 --- a/src/lib/dev.c +++ b/src/lib/dev.c @@ -227,7 +227,7 @@ static enum flow_state flow_wait_assign(int flow_id)  static int proc_announce(const char * prog)  {          uint8_t          buf[SOCK_BUF_SIZE]; -        buffer_t         msg = {buf, SOCK_BUF_SIZE}; +        buffer_t         msg = {SOCK_BUF_SIZE, buf};          int              err;          if (proc_announce__irm_req_ser(&msg, prog) < 0) @@ -244,7 +244,7 @@ static int proc_announce(const char * prog)  static void proc_exit(void)  {          uint8_t          buf[SOCK_BUF_SIZE]; -        buffer_t         msg = {buf, SOCK_BUF_SIZE}; +        buffer_t         msg = {SOCK_BUF_SIZE, buf};          if (proc_exit__irm_req_ser(&msg) < 0)                  return; @@ -826,7 +826,7 @@ int flow_accept(qosspec_t *             qs,  {          struct flow_info flow;          uint8_t          buf[SOCK_BUF_SIZE]; -        buffer_t         msg = {buf, SOCK_BUF_SIZE}; +        buffer_t         msg = {SOCK_BUF_SIZE, buf};          buffer_t         sk;          int              fd;          int              err; @@ -867,7 +867,7 @@ int flow_alloc(const char *            dst,  {          struct flow_info flow;          uint8_t          buf[SOCK_BUF_SIZE]; -        buffer_t         msg = {buf, SOCK_BUF_SIZE}; +        buffer_t         msg = {SOCK_BUF_SIZE, buf};          buffer_t         sk; /* symmetric key */          int              fd;          int              err; @@ -909,7 +909,7 @@ int flow_join(const char *            dst,  {          struct flow_info flow;          uint8_t          buf[SOCK_BUF_SIZE]; -        buffer_t         msg = {buf, SOCK_BUF_SIZE}; +        buffer_t         msg = {SOCK_BUF_SIZE, buf};          int              fd;          int              err; @@ -950,7 +950,7 @@ int flow_dealloc(int fd)          struct flow_info info;          uint8_t          pkt[PKT_BUF_LEN];          uint8_t          buf[SOCK_BUF_SIZE]; -        buffer_t         msg = {buf, SOCK_BUF_SIZE}; +        buffer_t         msg = {SOCK_BUF_SIZE, buf};          struct timespec  tic   = TIMESPEC_INIT_NS(TICTIME);          struct timespec  timeo = TIMESPEC_INIT_S(0);          struct flow *    flow; @@ -1024,7 +1024,7 @@ int ipcp_flow_dealloc(int fd)  {          struct flow_info info;          uint8_t          buf[SOCK_BUF_SIZE]; -        buffer_t         msg = {buf, SOCK_BUF_SIZE}; +        buffer_t         msg = {SOCK_BUF_SIZE, buf};          struct flow *    flow;          int              err; @@ -1849,7 +1849,7 @@ int np1_flow_resp(int flow_id)  int ipcp_create_r(const struct ipcp_info * info)  {          uint8_t          buf[SOCK_BUF_SIZE]; -        buffer_t         msg = {buf, SOCK_BUF_SIZE}; +        buffer_t         msg = {SOCK_BUF_SIZE, buf};          int              err;          if (ipcp_create_r__irm_req_ser(&msg,info) < 0) @@ -1869,7 +1869,7 @@ int ipcp_flow_req_arr(const buffer_t * dst,  {          struct flow_info flow;          uint8_t          buf[SOCK_BUF_SIZE]; -        buffer_t         msg = {buf, SOCK_BUF_SIZE}; +        buffer_t         msg = {SOCK_BUF_SIZE, buf};          int              err;          memset(&flow, 0, sizeof(flow)); @@ -1906,7 +1906,7 @@ int ipcp_flow_alloc_reply(int              fd,  {          struct flow_info flow;          uint8_t          buf[SOCK_BUF_SIZE]; -        buffer_t         msg = {buf, SOCK_BUF_SIZE}; +        buffer_t         msg = {SOCK_BUF_SIZE, buf};          int              err;          assert(fd >= 0 && fd < SYS_MAX_FLOWS);  | 
