This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Pau Espin Pedrol gerrit-no-reply at lists.osmocom.orgPau Espin Pedrol has uploaded this change for review. ( https://gerrit.osmocom.org/9533
Change subject: lc15: rewrite and refactor code to print hwversion description
......................................................................
lc15: rewrite and refactor code to print hwversion description
Also print a newline at the end of print_hwversion().
In the process of rewrite, fix several warnings in the few lines of this functions:
osmo-bts/src/osmo-bts-litecell15/main.c: In function ‘print_hwversion’:
osmo-bts/src/osmo-bts-litecell15/main.c:162:12: warning: passing argument 1 to restrict-qualified parameter aliases with argument 4 [-Wrestrict]
snprintf(model_name, sizeof(model_name), "%s Rev %c",
^~~~~~~~~~
model_name, (char)rev);
~~~~~~~~~~
osmo-bts/src/osmo-bts-litecell15/main.c:168:12: warning: passing argument 1 to restrict-qualified parameter aliases with argument 4 [-Wrestrict]
snprintf(model_name, sizeof(model_name), "%s (%05X)",
^~~~~~~~~~
model_name, model);
~~~~~~~~~~
osmo-bts/src/osmo-bts-litecell15/main.c:162:47: warning: ‘ Rev ’ directive output may be truncated writing 5 bytes into a region of size between 1 and 64 [-Wformat-truncation=]
snprintf(model_name, sizeof(model_name), "%s Rev %c",
^~~~~
osmo-bts/src/osmo-bts-litecell15/main.c:162:3: note: ‘snprintf’ output between 7 and 70 bytes into a destination of size 64
snprintf(model_name, sizeof(model_name), "%s Rev %c",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
model_name, (char)rev);
~~~~~~~~~~~~~~~~~~~~~~
osmo-bts/src/osmo-bts-litecell15/main.c:168:47: warning: ‘ (’ directive output may be truncated writing 2 bytes into a region of size between 1 and 64 [-Wformat-truncation=]
snprintf(model_name, sizeof(model_name), "%s (%05X)",
^~
osmo-bts/src/osmo-bts-litecell15/main.c:168:44: note: using the range [0, 4294967295] for directive argument
snprintf(model_name, sizeof(model_name), "%s (%05X)",
^~~~~~~~~~~
osmo-bts/src/osmo-bts-litecell15/main.c:168:3: note: ‘snprintf’ output between 9 and 75 bytes into a destination of size 64
snprintf(model_name, sizeof(model_name), "%s (%05X)",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
model_name, model);
~~~~~~~~~~~~~~~~~~
Change-Id: I079b056a04fe77d2f7f361ff5899232cb70b5a93
---
M src/osmo-bts-litecell15/main.c
M src/osmo-bts-litecell15/misc/lc15bts_bid.c
M src/osmo-bts-litecell15/misc/lc15bts_bid.h
M src/osmo-bts-litecell15/misc/lc15bts_mgr_nl.c
4 files changed, 26 insertions(+), 35 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/33/9533/1
diff --git a/src/osmo-bts-litecell15/main.c b/src/osmo-bts-litecell15/main.c
index 030c3ef..de175e3 100644
--- a/src/osmo-bts-litecell15/main.c
+++ b/src/osmo-bts-litecell15/main.c
@@ -151,25 +151,8 @@
static void print_hwversion()
{
- int rev;
- int model;
- static char model_name[64] = {0, };
-
- snprintf(model_name, sizeof(model_name), "NuRAN Litecell 1.5 BTS");
-
- rev = lc15bts_rev_get();
- if (rev >= 0) {
- snprintf(model_name, sizeof(model_name), "%s Rev %c",
- model_name, (char)rev);
- }
-
- model = lc15bts_model_get();
- if (model >= 0) {
- snprintf(model_name, sizeof(model_name), "%s (%05X)",
- model_name, model);
- }
-
- printf(model_name);
+ printf(get_hwversion_desc());
+ printf("\n");
}
int bts_model_handle_options(int argc, char **argv)
diff --git a/src/osmo-bts-litecell15/misc/lc15bts_bid.c b/src/osmo-bts-litecell15/misc/lc15bts_bid.c
index 7f278bf..9284b62 100644
--- a/src/osmo-bts-litecell15/misc/lc15bts_bid.c
+++ b/src/osmo-bts-litecell15/misc/lc15bts_bid.c
@@ -138,3 +138,25 @@
return option;
}
+
+const char* get_hwversion_desc()
+{
+ int rev;
+ int model;
+ size_t len;
+ static char model_name[64] = {0, };
+ len = snprintf(model_name, sizeof(model_name), "NuRAN Litecell 1.5 BTS");
+
+ rev = lc15bts_rev_get();
+ if (rev >= 0) {
+ len += snprintf(model_name + len, sizeof(model_name) - len,
+ " Rev %c", (char)rev);
+ }
+
+ model = lc15bts_model_get();
+ if (model >= 0) {
+ snprintf(model_name + len, sizeof(model_name) - len,
+ "%s (%05X)", model_name, model);
+ }
+ return model_name;
+}
diff --git a/src/osmo-bts-litecell15/misc/lc15bts_bid.h b/src/osmo-bts-litecell15/misc/lc15bts_bid.h
index b320e11..a71fdd7 100644
--- a/src/osmo-bts-litecell15/misc/lc15bts_bid.h
+++ b/src/osmo-bts-litecell15/misc/lc15bts_bid.h
@@ -47,5 +47,6 @@
int lc15bts_rev_get(void);
int lc15bts_model_get(void);
int lc15bts_option_get(enum lc15bts_option_type type);
+const char* get_hwversion_desc();
#endif
diff --git a/src/osmo-bts-litecell15/misc/lc15bts_mgr_nl.c b/src/osmo-bts-litecell15/misc/lc15bts_mgr_nl.c
index 549c179..3a617dd 100644
--- a/src/osmo-bts-litecell15/misc/lc15bts_mgr_nl.c
+++ b/src/osmo-bts-litecell15/misc/lc15bts_mgr_nl.c
@@ -104,8 +104,6 @@
if (!fetched_info) {
int fd_eth;
int serno;
- int model;
- int rev;
/* fetch the MAC */
fd_eth = open(ETH0_ADDR_SYSFS, O_RDONLY);
@@ -119,20 +117,7 @@
lc15bts_par_get_int(tall_mgr_ctx, LC15BTS_PAR_SERNR, &serno);
snprintf(ser_str, sizeof(ser_str), "%d", serno);
- /* fetch the model and trx number */
- snprintf(model_name, sizeof(model_name), "Litecell 1.5 BTS");
-
- rev = lc15bts_rev_get();
- if (rev >= 0) {
- snprintf(model_name, sizeof(model_name), "%s Rev %c",
- model_name, rev);
- }
-
- model = lc15bts_model_get();
- if (model >= 0) {
- snprintf(model_name, sizeof(model_name), "%s (%05X)",
- model_name, model);
- }
+ strncpy(model_name, get_hwversion_desc(), sizeof(model_name)-1);
fetched_info = 1;
}
--
To view, visit https://gerrit.osmocom.org/9533
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I079b056a04fe77d2f7f361ff5899232cb70b5a93
Gerrit-Change-Number: 9533
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180611/1f304d41/attachment.htm>