diff options
author | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2021-01-04 17:40:05 +0100 |
---|---|---|
committer | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2021-01-04 17:49:18 +0100 |
commit | 833e8fac82480f9d19edc233a4fc3aca287efa81 (patch) | |
tree | 8e7661b31847e766e9b844832d45fe146e0fc693 | |
parent | 8f5844ed01f0bc85c595d853921c41924d60a65d (diff) |
gsmtap_util: SNR can be negative, use a signed integer
In 'struct gsmtap_hdr' field 'snr_db' is defined as a signed integer,
however all functions that fill this structure accept an unsigned
integer. This is wrong, because SNR can be negative.
Let's use 'int8_t' instead of 'uint8_t'. Changing from unsigned
to signed should be relatively safe compared to the opposite.
Most of the callers I am aware of always do pass 0 anyway.
Change-Id: I9f432be5c346d563bf518111c14ff04d4a63f592
Related: SYS#5073
-rw-r--r-- | include/osmocom/core/gsmtap_util.h | 8 | ||||
-rw-r--r-- | src/gsmtap_util.c | 8 |
2 files changed, 8 insertions, 8 deletions
diff --git a/include/osmocom/core/gsmtap_util.h b/include/osmocom/core/gsmtap_util.h index 9b215be3..e5643260 100644 --- a/include/osmocom/core/gsmtap_util.h +++ b/include/osmocom/core/gsmtap_util.h @@ -17,11 +17,11 @@ void chantype_gsmtap2rsl(uint8_t gsmtap_chantype, uint8_t *rsl_chantype, uint8_t struct msgb *gsmtap_makemsg_ex(uint8_t type, uint16_t arfcn, uint8_t ts, uint8_t chan_type, uint8_t ss, uint32_t fn, int8_t signal_dbm, - uint8_t snr, const uint8_t *data, unsigned int len); + int8_t snr, const uint8_t *data, unsigned int len); struct msgb *gsmtap_makemsg(uint16_t arfcn, uint8_t ts, uint8_t chan_type, uint8_t ss, uint32_t fn, int8_t signal_dbm, - uint8_t snr, const uint8_t *data, unsigned int len); + int8_t snr, const uint8_t *data, unsigned int len); /*! one gsmtap instance */ struct gsmtap_inst { @@ -51,12 +51,12 @@ int gsmtap_sendmsg(struct gsmtap_inst *gti, struct msgb *msg); int gsmtap_send_ex(struct gsmtap_inst *gti, uint8_t type, uint16_t arfcn, uint8_t ts, uint8_t chan_type, uint8_t ss, uint32_t fn, - int8_t signal_dbm, uint8_t snr, const uint8_t *data, + int8_t signal_dbm, int8_t snr, const uint8_t *data, unsigned int len); int gsmtap_send(struct gsmtap_inst *gti, uint16_t arfcn, uint8_t ts, uint8_t chan_type, uint8_t ss, uint32_t fn, - int8_t signal_dbm, uint8_t snr, const uint8_t *data, + int8_t signal_dbm, int8_t snr, const uint8_t *data, unsigned int len); extern const struct value_string gsmtap_gsm_channel_names[]; diff --git a/src/gsmtap_util.c b/src/gsmtap_util.c index 9a0ac027..336e1d03 100644 --- a/src/gsmtap_util.c +++ b/src/gsmtap_util.c @@ -176,7 +176,7 @@ void chantype_gsmtap2rsl(uint8_t gsmtap_chantype, uint8_t *rsl_chantype, */ struct msgb *gsmtap_makemsg_ex(uint8_t type, uint16_t arfcn, uint8_t ts, uint8_t chan_type, uint8_t ss, uint32_t fn, int8_t signal_dbm, - uint8_t snr, const uint8_t *data, unsigned int len) + int8_t snr, const uint8_t *data, unsigned int len) { struct msgb *msg; struct gsmtap_hdr *gh; @@ -223,7 +223,7 @@ struct msgb *gsmtap_makemsg_ex(uint8_t type, uint16_t arfcn, uint8_t ts, uint8_t */ struct msgb *gsmtap_makemsg(uint16_t arfcn, uint8_t ts, uint8_t chan_type, uint8_t ss, uint32_t fn, int8_t signal_dbm, - uint8_t snr, const uint8_t *data, unsigned int len) + int8_t snr, const uint8_t *data, unsigned int len) { return gsmtap_makemsg_ex(GSMTAP_TYPE_UM, arfcn, ts, chan_type, ss, fn, signal_dbm, snr, data, len); @@ -326,7 +326,7 @@ int gsmtap_sendmsg(struct gsmtap_inst *gti, struct msgb *msg) */ int gsmtap_send_ex(struct gsmtap_inst *gti, uint8_t type, uint16_t arfcn, uint8_t ts, uint8_t chan_type, uint8_t ss, uint32_t fn, - int8_t signal_dbm, uint8_t snr, const uint8_t *data, + int8_t signal_dbm, int8_t snr, const uint8_t *data, unsigned int len) { struct msgb *msg; @@ -351,7 +351,7 @@ int gsmtap_send_ex(struct gsmtap_inst *gti, uint8_t type, uint16_t arfcn, uint8_ */ int gsmtap_send(struct gsmtap_inst *gti, uint16_t arfcn, uint8_t ts, uint8_t chan_type, uint8_t ss, uint32_t fn, - int8_t signal_dbm, uint8_t snr, const uint8_t *data, + int8_t signal_dbm, int8_t snr, const uint8_t *data, unsigned int len) { return gsmtap_send_ex(gti, GSMTAP_TYPE_UM, arfcn, ts, chan_type, ss, fn, |