From 56b8b90727e653a430cfff15febf4d0be4ad3fa4 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Thu, 20 Aug 2020 22:50:10 -0500 Subject: [PATCH] Minor code deduplication in src/sock.c Minor code deduplication in src/sock.c for handling SABM vs SABME sequence numbers --- src/sock.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/sock.c b/src/sock.c index 47ba896..d60db09 100644 --- a/src/sock.c +++ b/src/sock.c @@ -56,18 +56,20 @@ static inline size_t rx_bufsz(patty_ax25_sock *sock) { return PATTY_AX25_FRAME_OVERHEAD + sock->n_maxlen_rx; } +static inline size_t tx_slots(patty_ax25_sock *sock) { + return sock->mode == PATTY_AX25_SOCK_SABME? 128: 8; +} + static inline size_t tx_slot_size(patty_ax25_sock *sock) { return sizeof(struct slot) + PATTY_AX25_FRAME_OVERHEAD + sock->n_maxlen_tx; } static inline size_t tx_slots_size(patty_ax25_sock *sock) { - size_t slots = sock->mode == PATTY_AX25_SOCK_SABME? 128: 8; - - return slots * tx_slot_size(sock); + return tx_slots(sock) * tx_slot_size(sock); } static inline int tx_seq(patty_ax25_sock *sock, int seq) { - return sock->mode == PATTY_AX25_SOCK_SABME? seq % 128: seq % 8; + return seq % tx_slots(sock); } static inline struct slot *tx_slot(patty_ax25_sock *sock, int seq) {