diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2022-10-27 15:19:39 +0200 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2022-10-28 15:14:44 +0200 |
commit | bd1f01fd2770c893592f94c5449a9c23b5871c63 (patch) | |
tree | d7c66e8142fd6570b54b52ff0f9fdb7b91ad98d2 /src/tbf_ul.h | |
parent | 29b9f94cacc86a808f6a7ef978bdc7071d5c5b54 (diff) |
Fix mess with struct tbf types passed to LOGPTBF macro
It is quite common in all osmo-pcu code to have to convert between
parent class "tbf" and children "dl_tbf"/"ul_tbf", or other way around.
This commit adds new helper static inline functions to cast between
those while doing type checks.
This is used by new LOGPTBFDL and LOGPTBFUL macros to now expect the
proper subclass and cast securely inside the macro itself, hence sparing
all code calling those macros to have to cast explicitly the pointer to
the parent "tbf" class.
Change-Id: I7e4489ad4b93c9c8442213947e53c10b61fdc5e9
Diffstat (limited to 'src/tbf_ul.h')
-rw-r--r-- | src/tbf_ul.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/tbf_ul.h b/src/tbf_ul.h index 62b94567..d69220d6 100644 --- a/src/tbf_ul.h +++ b/src/tbf_ul.h @@ -143,7 +143,17 @@ bool ul_tbf_contention_resolution_done(const struct gprs_rlcmac_ul_tbf *tbf); struct osmo_fsm_inst *tbf_ul_ack_fi(const struct gprs_rlcmac_ul_tbf *tbf); void ul_tbf_contention_resolution_success(struct gprs_rlcmac_ul_tbf *tbf); -#define LOGPTBFUL(tbf, level, fmt, args...) LOGP(DTBFUL, level, "%s " fmt, tbf_name(tbf), ## args) +static inline struct gprs_rlcmac_tbf *ul_tbf_as_tbf(struct gprs_rlcmac_ul_tbf *ul_tbf) +{ + return (struct gprs_rlcmac_tbf *)ul_tbf; +} + +static inline const struct gprs_rlcmac_tbf *ul_tbf_as_tbf_const(const struct gprs_rlcmac_ul_tbf *ul_tbf) +{ + return (const struct gprs_rlcmac_tbf *)ul_tbf; +} + +#define LOGPTBFUL(ul_tbf, level, fmt, args...) LOGP(DTBFUL, level, "%s " fmt, tbf_name(ul_tbf_as_tbf_const(ul_tbf)), ## args) #ifdef __cplusplus } #endif |