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
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
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
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
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