lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

December 2023

  • 1 participants
  • 1601 discussions
[S] Change in libosmocore[master]: utils: osmo_bcd2str(): fix applying non-zero offset to null pointer
by fixeria 31 Dec '23

31 Dec '23
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/35470?usp=email ) Change subject: utils: osmo_bcd2str(): fix applying non-zero offset to null pointer ...................................................................... utils: osmo_bcd2str(): fix applying non-zero offset to null pointer This can be seen when building with CC=clang: utils.c:150:22: runtime error: applying non-zero offset 100 to null pointer SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior utils.c:150:22 in utils.c:150:33: runtime error: addition of unsigned offset to 0x000000000064 overflowed to 0x000000000063 SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior utils.c:150:33 in The *dst pointer may be NULL (e.g. bcd2str_test() is passing it). This makes tests/utils/utils_test fail. Let's fix this. Change-Id: I542aef1ac220891b6bbdb0c60c39232f0df0a43c --- M src/core/utils.c 1 file changed, 22 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/70/35470/1 diff --git a/src/core/utils.c b/src/core/utils.c index 882eb6f..1ec940d 100644 --- a/src/core/utils.c +++ b/src/core/utils.c @@ -147,13 +147,15 @@ */ int osmo_bcd2str(char *dst, size_t dst_size, const uint8_t *bcd, int start_nibble, int end_nibble, bool allow_hex) { - char *dst_end = dst + dst_size - 1; + char *dst_end; int nibble_i; int rc = 0; if (!dst || dst_size < 1 || start_nibble < 0) return -ENOMEM; + dst_end = dst + dst_size - 1; + for (nibble_i = start_nibble; nibble_i < end_nibble && dst < dst_end; nibble_i++, dst++) { uint8_t nibble = bcd[nibble_i >> 1]; if ((nibble_i & 1)) -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35470?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I542aef1ac220891b6bbdb0c60c39232f0df0a43c Gerrit-Change-Number: 35470 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in libosmocore[master]: bitvec: bitvec_to_string_r(): drop unused variable
by fixeria 31 Dec '23

31 Dec '23
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/35472?usp=email ) Change subject: bitvec: bitvec_to_string_r(): drop unused variable ...................................................................... bitvec: bitvec_to_string_r(): drop unused variable bitvec.c:543:14: warning: variable 'pos' set but not used [-Wunused-but-set-variable] unsigned i, pos = 0; Change-Id: I17df6f9263bee06676309c00837f12220803c814 --- M src/core/bitvec.c 1 file changed, 13 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/72/35472/1 diff --git a/src/core/bitvec.c b/src/core/bitvec.c index 38ea1bb..ac702b9 100644 --- a/src/core/bitvec.c +++ b/src/core/bitvec.c @@ -540,13 +540,11 @@ */ void bitvec_to_string_r(const struct bitvec *bv, char *str) { - unsigned i, pos = 0; char *cur = str; - for (i = 0; i < bv->cur_bit; i++) { + for (unsigned int i = 0; i < bv->cur_bit; i++) { if (0 == i % 8) *cur++ = ' '; *cur++ = bit_value_to_char(bitvec_get_bit_pos(bv, i)); - pos++; } *cur = 0; } -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35472?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I17df6f9263bee06676309c00837f12220803c814 Gerrit-Change-Number: 35472 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in libosmocore[master]: {gsm,vty}: suppress warnings about [total_]len being set but not used
by fixeria 31 Dec '23

31 Dec '23
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/35473?usp=email ) Change subject: {gsm,vty}: suppress warnings about [total_]len being set but not used ...................................................................... {gsm,vty}: suppress warnings about [total_]len being set but not used This commit fixes the following warnings seen with CC=clang: utils.c:376:6: warning: variable 'len' set but not used [-Wunused-but-set-variable] int len = 0, offset = 0, ret, rem; gsm0808_utils.c:2094:6: warning: variable 'total_len' set but not used [-Wunused-but-set-variable] int total_len = 0; ... and finally allows to build libosmocore with --enable-werror. Change-Id: I0040ef20ba3fc53ee7ccefc4885170f333f80566 --- M src/gsm/gsm0808_utils.c M src/vty/utils.c 2 files changed, 21 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/73/35473/1 diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c index 778630d..0d6d5ad 100644 --- a/src/gsm/gsm0808_utils.c +++ b/src/gsm/gsm0808_utils.c @@ -2094,6 +2094,7 @@ int total_len = 0; APPEND_STR("%s:", gsm0808_cell_id_discr_name(cid->id_discr)); APPEND_CELL_ID_U(cid->id_discr, &cid->id); + (void)total_len; /* suppress warnings about total_len being set but not used */ return buf; } diff --git a/src/vty/utils.c b/src/vty/utils.c index a651515..0f5a34e 100644 --- a/src/vty/utils.c +++ b/src/vty/utils.c @@ -415,6 +415,7 @@ if (ret < 0) goto err; OSMO_SNPRINTF_RET(ret, rem, offset, len); + (void)len; /* suppress warnings about len being set but not used */ err: str[size-1] = '\0'; return str; -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35473?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I0040ef20ba3fc53ee7ccefc4885170f333f80566 Gerrit-Change-Number: 35473 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[M] Change in libosmocore[master]: core: osmo_tdef_fsm_inst_state_chg(): allow millisecond precision
by fixeria 30 Dec '23

30 Dec '23
Attention is currently required from: laforge, neels. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/35466?usp=email ) Change subject: core: osmo_tdef_fsm_inst_state_chg(): allow millisecond precision ...................................................................... Patch Set 3: This change is ready for review. -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35466?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I4c4ee89e7e32e86f74cd215f5cbfa44ace5426c1 Gerrit-Change-Number: 35466 Gerrit-PatchSet: 3 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de> Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Sat, 30 Dec 2023 17:22:33 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: No Gerrit-MessageType: comment
1 0
0 0
[S] Change in libosmocore[master]: tests/tdef: tune logging, also match stderr
by fixeria 30 Dec '23

30 Dec '23
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/35469?usp=email ) Change subject: tests/tdef: tune logging, also match stderr ...................................................................... tests/tdef: tune logging, also match stderr Change-Id: I7f346dfbec9e724e905d26990a978495d3a9b030 --- M tests/Makefile.am M tests/tdef/tdef_test.c A tests/tdef/tdef_test.err M tests/testsuite.at 4 files changed, 46 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/69/35469/1 diff --git a/tests/Makefile.am b/tests/Makefile.am index 478dd48..8d510d5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -466,6 +466,7 @@ oap/oap_client_test.ok oap/oap_client_test.err \ vty/vty_transcript_test.vty \ tdef/tdef_test.ok \ + tdef/tdef_test.err \ tdef/tdef_test_range_64bit.ok \ tdef/tdef_vty_config_root_test.vty \ tdef/tdef_vty_config_subnode_test.vty \ @@ -676,7 +677,8 @@ gsm23236/gsm23236_test \ >$(srcdir)/gsm23236/gsm23236_test.ok tdef/tdef_test \ - >$(srcdir)/tdef/tdef_test.ok + >$(srcdir)/tdef/tdef_test.ok \ + 2>$(srcdir)/tdef/tdef_test.err sockaddr_str/sockaddr_str_test \ >$(srcdir)/sockaddr_str/sockaddr_str_test.ok use_count/use_count_test \ diff --git a/tests/tdef/tdef_test.c b/tests/tdef/tdef_test.c index 13dcd01..1cc9c9c 100644 --- a/tests/tdef/tdef_test.c +++ b/tests/tdef/tdef_test.c @@ -469,9 +469,16 @@ osmo_init_logging2(ctx, NULL); log_set_print_filename2(osmo_stderr_target, LOG_FILENAME_NONE); + log_set_print_level(osmo_stderr_target, 1); log_set_print_category(osmo_stderr_target, 1); + log_set_print_category_hex(osmo_stderr_target, 0); log_set_use_color(osmo_stderr_target, 0); + osmo_fsm_log_addr(false); + osmo_fsm_log_timeouts(true); + + log_set_category_filter(osmo_stderr_target, DLGLOBAL, 1, LOGL_DEBUG); + OSMO_ASSERT(osmo_fsm_register(&test_tdef_fsm) == 0); test_tdef_get(argc > 1); diff --git a/tests/tdef/tdef_test.err b/tests/tdef/tdef_test.err new file mode 100644 index 0000000..1a39b89 --- /dev/null +++ b/tests/tdef/tdef_test.err @@ -0,0 +1,25 @@ +DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){A}: Allocated +DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){A}: State change to A (T1, 100s) +DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){A}: State change to B (T2, 1s) +DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){B}: State change to C (T3, 3000s) +DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){C}: State change to D (T4, 100s) +DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){D}: State change to E (X5, 1s) +DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){E}: State change to F (X6, 1s) +DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){F}: State change to G (T7, 50s) +DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){G}: State change to H (T8, 300s) +DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){H}: State change to I (T9, 300s) +DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){I}: State change to J (T10, 1200s) +DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){J}: State change to K (keeping T10, 1076.954s remaining) +DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){K}: State change to A (T1, 100s) +DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){A}: State change to K (keeping T1, 76.954s remaining) +DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){K}: State change to A (T1, 100s) +DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){A}: State change to L (keeping T1, 76.954s remaining) +DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){L}: State change to O (no timeout) +DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){O}: State change to L (T123, 1s) +DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){L}: State change to O (no timeout) +DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){O}: State change to X (no timeout) +DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){X}: State change to Y (T666, 999s) +DLGLOBAL DEBUG tdef_test(test_tdef_state_timeout){Y}: State change to Z (no timeout) +DLGLOBAL ERROR tdef_test(test_tdef_state_timeout){Z}: transition to state B not permitted! +DLGLOBAL ERROR tdef_test(test_tdef_state_timeout){Z}: transition to state C not permitted! +DLGLOBAL ERROR tdef_test(test_tdef_state_timeout){Z}: transition to state D not permitted! diff --git a/tests/testsuite.at b/tests/testsuite.at index e88e0a8..40424e1 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -414,7 +414,8 @@ AT_SETUP([tdef]) AT_KEYWORDS([tdef]) cat $abs_srcdir/tdef/tdef_test.ok > expout -AT_CHECK([$abs_top_builddir/tests/tdef/tdef_test], [0], [expout], [ignore]) +cat $abs_srcdir/tdef/tdef_test.err > experr +AT_CHECK([$abs_top_builddir/tests/tdef/tdef_test], [0], [expout], [experr]) AT_CLEANUP AT_SETUP([sockaddr_str]) -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35469?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I7f346dfbec9e724e905d26990a978495d3a9b030 Gerrit-Change-Number: 35469 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in osmo-bts[master]: l1sap: fix logic error in gsmtap_csd_rlp_process()
by fixeria 30 Dec '23

30 Dec '23
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/35468?usp=email ) Change subject: l1sap: fix logic error in gsmtap_csd_rlp_process() ...................................................................... l1sap: fix logic error in gsmtap_csd_rlp_process() Current code evaluates as follows: (trx->arfcn | is_uplink) ? GSMTAP_ARFCN_F_UPLINK : 0 while we want it to be evaluated as follows: trx->arfcn | (is_uplink ? GSMTAP_ARFCN_F_UPLINK : 0) Change-Id: Ida3d684968a3e4a45531d4b6d7b6af170e3e39f4 Fixes: CID#338165 --- M src/common/l1sap.c 1 file changed, 24 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/68/35468/1 diff --git a/src/common/l1sap.c b/src/common/l1sap.c index e9095de..11f5e3f 100644 --- a/src/common/l1sap.c +++ b/src/common/l1sap.c @@ -1858,6 +1858,7 @@ struct gsmtap_inst *inst = trx->bts->gsmtap.inst; struct osmo_rlp_frame_decoded rlpf; pbit_t *rlp_buf; + uint16_t arfcn; int byte_len; if (!inst || !trx->bts->gsmtap.rlp) @@ -1916,8 +1917,11 @@ return; } - gsmtap_send_ex(inst, GSMTAP_TYPE_GSM_RLP, trx->arfcn | is_uplink ? GSMTAP_ARFCN_F_UPLINK : 0, - lchan->ts->nr, + arfcn = trx->arfcn; + if (is_uplink) + arfcn |= GSMTAP_ARFCN_F_UPLINK; + + gsmtap_send_ex(inst, GSMTAP_TYPE_GSM_RLP, arfcn, lchan->ts->nr, lchan->type == GSM_LCHAN_TCH_H ? GSMTAP_CHANNEL_VOICE_H : GSMTAP_CHANNEL_VOICE_F, lchan->nr, tch_ind->fn, tch_ind->rssi, 0, rlp_buf, byte_len); -- To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/35468?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Change-Id: Ida3d684968a3e4a45531d4b6d7b6af170e3e39f4 Gerrit-Change-Number: 35468 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in libosmocore[master]: utils: improve readability of OSMO_STRBUF_CHAR_COUNT
by fixeria 30 Dec '23

30 Dec '23
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/35313?usp=email ) Change subject: utils: improve readability of OSMO_STRBUF_CHAR_COUNT ...................................................................... utils: improve readability of OSMO_STRBUF_CHAR_COUNT Similarly to OSMO_STRBUF_REMAIN, let's improve the code readability by adding a static inline function. We should generally prefer using static inline functions over macros, unless there is something that only the proprocessor can do. Change-Id: I71f24b87c13fd83952029171a6993f8da5e32e5b --- M include/osmocom/core/utils.h 1 file changed, 28 insertions(+), 4 deletions(-) Approvals: laforge: Looks good to me, but someone else must approve pespin: Looks good to me, but someone else must approve neels: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h index 973a9d0..9a6e6b2 100644 --- a/include/osmocom/core/utils.h +++ b/include/osmocom/core/utils.h @@ -297,11 +297,21 @@ #define OSMO_STRBUF_REMAIN(STRBUF) \ _osmo_strbuf_remain(&(STRBUF)) +/*! Get number of actual characters (without terminating nul) in the given struct osmo_strbuf. + * \param[in] sb the string buffer to get the number of characters for. + * \returns number of actual characters (without terminating nul). */ +static inline size_t _osmo_strbuf_char_count(const struct osmo_strbuf *sb) +{ + if (OSMO_UNLIKELY(sb == NULL || sb->buf == NULL)) + return 0; + if (sb->pos == NULL || sb->pos <= sb->buf) + return 0; + return OSMO_MIN(sb->pos - sb->buf, sb->len - 1); +} + /*! Return number of actual characters contained in struct osmo_strbuf (without terminating nul). */ -#define OSMO_STRBUF_CHAR_COUNT(STRBUF) ((STRBUF).buf && ((STRBUF).pos > (STRBUF).buf) ? \ - OSMO_MIN((STRBUF).pos - (STRBUF).buf, \ - (STRBUF).len - 1) \ - : 0) +#define OSMO_STRBUF_CHAR_COUNT(STRBUF) \ + _osmo_strbuf_char_count(&(STRBUF)) /*! Like OSMO_STRBUF_APPEND(), but for function signatures that return the char* buffer instead of a length. * When using this function, the final STRBUF.chars_needed may not reflect the actual number of characters needed, since -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35313?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I71f24b87c13fd83952029171a6993f8da5e32e5b Gerrit-Change-Number: 35313 Gerrit-PatchSet: 2 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[M] Change in libosmocore[master]: utils: fix OSMO_STRBUF_REMAIN to handle sb.pos == NULL correctly
by fixeria 30 Dec '23

30 Dec '23
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/35312?usp=email ) Change subject: utils: fix OSMO_STRBUF_REMAIN to handle sb.pos == NULL correctly ...................................................................... utils: fix OSMO_STRBUF_REMAIN to handle sb.pos == NULL correctly Currently, OSMO_STRBUF_REMAIN would return a huge number if the given strbuf has its .pos pointer set to NULL. This macro is safe against the .buf pointer being NULL, but not against .pos being NULL. Fix this by adding a static inline function (for the sake of code readability) and handle .pos being NULL properly by returning length of the buffer. Add a unit test. Change-Id: I294a74a99c40995cf7fb5520d61f697d967be5a4 --- M include/osmocom/core/utils.h M tests/utils/utils_test.c M tests/utils/utils_test.ok 3 files changed, 56 insertions(+), 1 deletion(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve laforge: Looks good to me, but someone else must approve neels: Looks good to me, approved diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h index b6e67e2..973a9d0 100644 --- a/include/osmocom/core/utils.h +++ b/include/osmocom/core/utils.h @@ -281,8 +281,21 @@ #define OSMO_STRBUF_PRINTF(STRBUF, fmt, args...) \ OSMO_STRBUF_APPEND(STRBUF, snprintf, fmt, ##args) +/*! Get remaining space for characters and terminating nul in the given struct osmo_strbuf. + * \param[in] sb the string buffer to get the remaining space for. + * \returns remaining space in the given struct osmo_strbuf. */ +static inline size_t _osmo_strbuf_remain(const struct osmo_strbuf *sb) +{ + if (OSMO_UNLIKELY(sb == NULL || sb->buf == NULL)) + return 0; + if (sb->pos == NULL) + return sb->len; + return sb->len - (sb->pos - sb->buf); +} + /*! Return remaining space for characters and terminating nul in the given struct osmo_strbuf. */ -#define OSMO_STRBUF_REMAIN(STRBUF) ((STRBUF).buf ? (STRBUF).len - ((STRBUF).pos - (STRBUF).buf) : 0) +#define OSMO_STRBUF_REMAIN(STRBUF) \ + _osmo_strbuf_remain(&(STRBUF)) /*! Return number of actual characters contained in struct osmo_strbuf (without terminating nul). */ #define OSMO_STRBUF_CHAR_COUNT(STRBUF) ((STRBUF).buf && ((STRBUF).pos > (STRBUF).buf) ? \ diff --git a/tests/utils/utils_test.c b/tests/utils/utils_test.c index bdeedb5..26c94dc 100644 --- a/tests/utils/utils_test.c +++ b/tests/utils/utils_test.c @@ -1351,6 +1351,23 @@ strbuf_test_tail_for_buflen(1); } +void strbuf_test_remain_char_count(void) +{ + char buf[20]; + struct osmo_strbuf sb = { .buf = buf, .len = sizeof(buf) }; + + printf("\n%s\n", __func__); + + printf("remaining space: %zu\n", OSMO_STRBUF_REMAIN(sb)); + printf("current char count: %zu\n", OSMO_STRBUF_CHAR_COUNT(sb)); + + printf("populating the buffer\n"); + OSMO_STRBUF_PRINTF(sb, "osmocom"); + + printf("remaining space: %zu\n", OSMO_STRBUF_REMAIN(sb)); + printf("current char count: %zu\n", OSMO_STRBUF_CHAR_COUNT(sb)); +} + static void startswith_test_str(const char *str, const char *startswith_str, bool expect_rc) { bool rc = osmo_str_startswith(str, startswith_str); @@ -2198,6 +2215,7 @@ strbuf_test(); strbuf_test_nolen(); strbuf_test_tail(); + strbuf_test_remain_char_count(); startswith_test(); name_c_impl_test(); osmo_print_n_test(); diff --git a/tests/utils/utils_test.ok b/tests/utils/utils_test.ok index 6f5d46b..c0c9560 100644 --- a/tests/utils/utils_test.ok +++ b/tests/utils/utils_test.ok @@ -524,6 +524,13 @@ 6: "" sb.chars_needed=6 sb.pos=&sb.buf[1] 7: "" sb.chars_needed=12 sb.pos=&sb.buf[1] +strbuf_test_remain_char_count +remaining space: 20 +current char count: 0 +populating the buffer +remaining space: 13 +current char count: 7 + startswith_test() osmo_str_startswith(NULL, NULL) == true osmo_str_startswith("", NULL) == true -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35312?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I294a74a99c40995cf7fb5520d61f697d967be5a4 Gerrit-Change-Number: 35312 Gerrit-PatchSet: 2 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[M] Change in pysim[master]: move SUCI sub-classes to EF_SUCI_CalcInfo
by laforge 30 Dec '23

30 Dec '23
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/35426?usp=email ) Change subject: move SUCI sub-classes to EF_SUCI_CalcInfo ...................................................................... move SUCI sub-classes to EF_SUCI_CalcInfo Change-Id: Iea6b176327881ff9414f4fe624e94811f9782927 --- M pySim/ts_31_102.py 1 file changed, 34 insertions(+), 27 deletions(-) Approvals: Jenkins Builder: Verified fixeria: Looks good to me, approved diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py index 1976ae0..fdd8acf 100644 --- a/pySim/ts_31_102.py +++ b/pySim/ts_31_102.py @@ -267,33 +267,6 @@ super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, **kwargs) self._tlv = EF_5GAUTHKEYS.FiveGAuthKeys -# 3GPP TS 31.102 Section 4.4.11.8 -class ProtSchemeIdList(BER_TLV_IE, tag=0xa0): - # FIXME: 3GPP TS 24.501 Protection Scheme Identifier - # repeated sequence of (id, index) tuples - _construct = GreedyRange( - Struct('id'/Enum(Byte, null=0, A=1, B=2), 'index'/Int8ub)) - - -class HomeNetPubKeyId(BER_TLV_IE, tag=0x80): - # 3GPP TS 24.501 / 3GPP TS 23.003 - _construct = Int8ub - - -class HomeNetPubKey(BER_TLV_IE, tag=0x81): - # FIXME: RFC 5480 - _construct = HexAdapter(GreedyBytes) - - -class HomeNetPubKeyList(BER_TLV_IE, tag=0xa1, - nested=[HomeNetPubKeyId, HomeNetPubKey]): - pass - -# 3GPP TS 31.102 Section 4.4.11.6 -class SUCI_CalcInfo(TLV_IE_Collection, nested=[ProtSchemeIdList, HomeNetPubKeyList]): - pass - - # TS 31.102 4.4.11.8 class EF_SUCI_Calc_Info(TransparentEF): _test_de_encode = [ @@ -306,6 +279,31 @@ {"hnet_pubkey_identifier": 11, "hnet_pubkey": "d1bc365f4997d17ce4374e72181431cbfeba9e1b98d7618f79d48561b144672a"}]} ), ] + # 3GPP TS 31.102 Section 4.4.11.8 + class ProtSchemeIdList(BER_TLV_IE, tag=0xa0): + # FIXME: 3GPP TS 24.501 Protection Scheme Identifier + # repeated sequence of (id, index) tuples + _construct = GreedyRange( + Struct('identifier'/Enum(Byte, null=0, A=1, B=2), 'key_index'/Int8ub)) + + + class HnetPubkeyIdentifier(BER_TLV_IE, tag=0x80): + # 3GPP TS 24.501 / 3GPP TS 23.003 + _construct = Int8ub + + + class HnetPubkey(BER_TLV_IE, tag=0x81): + # FIXME: RFC 5480 + _construct = HexAdapter(GreedyBytes) + + + class HnetPubkeyList(BER_TLV_IE, tag=0xa1, nested=[HnetPubkeyIdentifier, HnetPubkey]): + pass + + # 3GPP TS 31.102 Section 4.4.11.6 + class SUCI_CalcInfo(TLV_IE_Collection, nested=[ProtSchemeIdList, HnetPubkeyList]): + pass + def __init__(self, fid="4f07", sfid=0x07, name='EF.SUCI_Calc_Info', size=(2, None), desc='SUCI Calc Info', **kwargs): super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, **kwargs) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/35426?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Iea6b176327881ff9414f4fe624e94811f9782927 Gerrit-Change-Number: 35426 Gerrit-PatchSet: 5 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
1 0
0 0
[S] Change in pysim[master]: commands: Ignore exceptions during READ while UPDATE
by laforge 30 Dec '23

30 Dec '23
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/35459?usp=email ) Change subject: commands: Ignore exceptions during READ while UPDATE ...................................................................... commands: Ignore exceptions during READ while UPDATE If we are reading a file to check if we can skip the write to conserve writes, don't treat exceptions as fatal. The file may well have the access mode in a way that permits us to UPDATE but not to READ. Simply fall-back to unconditional UPDATE in this case. Change-Id: I7bffdaa7596e63c8f0ab04a3cb3ebe12f137d3a8 --- M pySim/commands.py 1 file changed, 35 insertions(+), 7 deletions(-) Approvals: Jenkins Builder: Verified fixeria: Looks good to me, approved diff --git a/pySim/commands.py b/pySim/commands.py index 336cf0c..d785251 100644 --- a/pySim/commands.py +++ b/pySim/commands.py @@ -279,9 +279,16 @@ # Save write cycles by reading+comparing before write if conserve: - data_current, sw = self.read_binary(ef, data_length, offset) - if data_current == data: - return None, sw + try: + data_current, sw = self.read_binary(ef, data_length, offset) + if data_current == data: + return None, sw + except Exception: + # cannot read data. This is not a fatal error, as reading is just done to + # conserve the amount of smart card writes. The access conditions of the file + # may well permit us to UPDATE but not permit us to READ. So let's ignore + # any such exception during READ. + pass self.select_path(ef) total_data = '' @@ -363,10 +370,17 @@ # Save write cycles by reading+comparing before write if conserve: - data_current, sw = self.read_record(ef, rec_no) - data_current = data_current[0:rec_length*2] - if data_current == data: - return None, sw + try: + data_current, sw = self.read_record(ef, rec_no) + data_current = data_current[0:rec_length*2] + if data_current == data: + return None, sw + except Exception: + # cannot read data. This is not a fatal error, as reading is just done to + # conserve the amount of smart card writes. The access conditions of the file + # may well permit us to UPDATE but not permit us to READ. So let's ignore + # any such exception during READ. + pass pdu = (self.cla_byte + 'dc%02x04%02x' % (rec_no, rec_length)) + data res = self._tp.send_apdu_checksw(pdu) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/35459?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I7bffdaa7596e63c8f0ab04a3cb3ebe12f137d3a8 Gerrit-Change-Number: 35459 Gerrit-PatchSet: 2 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
1 0
0 0
  • ← Newer
  • 1
  • 2
  • 3
  • 4
  • 5
  • ...
  • 161
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.