mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-bts.git
synced 2025-11-05 06:33:26 +00:00
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
This commit is contained in:
committed by
Harald Welte
parent
a8041edb5b
commit
19795c5ab2
@@ -151,25 +151,8 @@ void bts_model_print_help()
|
|||||||
|
|
||||||
static void print_hwversion()
|
static void print_hwversion()
|
||||||
{
|
{
|
||||||
int rev;
|
printf(get_hwversion_desc());
|
||||||
int model;
|
printf("\n");
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int bts_model_handle_options(int argc, char **argv)
|
int bts_model_handle_options(int argc, char **argv)
|
||||||
|
|||||||
@@ -138,3 +138,25 @@ int lc15bts_option_get(enum lc15bts_option_type type)
|
|||||||
|
|
||||||
return option;
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -47,5 +47,6 @@ enum lc15bts_gsm_band {
|
|||||||
int lc15bts_rev_get(void);
|
int lc15bts_rev_get(void);
|
||||||
int lc15bts_model_get(void);
|
int lc15bts_model_get(void);
|
||||||
int lc15bts_option_get(enum lc15bts_option_type type);
|
int lc15bts_option_get(enum lc15bts_option_type type);
|
||||||
|
const char* get_hwversion_desc();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -104,8 +104,6 @@ static void respond_to(struct sockaddr_in *src, struct osmo_fd *fd,
|
|||||||
if (!fetched_info) {
|
if (!fetched_info) {
|
||||||
int fd_eth;
|
int fd_eth;
|
||||||
int serno;
|
int serno;
|
||||||
int model;
|
|
||||||
int rev;
|
|
||||||
|
|
||||||
/* fetch the MAC */
|
/* fetch the MAC */
|
||||||
fd_eth = open(ETH0_ADDR_SYSFS, O_RDONLY);
|
fd_eth = open(ETH0_ADDR_SYSFS, O_RDONLY);
|
||||||
@@ -119,20 +117,7 @@ static void respond_to(struct sockaddr_in *src, struct osmo_fd *fd,
|
|||||||
lc15bts_par_get_int(tall_mgr_ctx, LC15BTS_PAR_SERNR, &serno);
|
lc15bts_par_get_int(tall_mgr_ctx, LC15BTS_PAR_SERNR, &serno);
|
||||||
snprintf(ser_str, sizeof(ser_str), "%d", serno);
|
snprintf(ser_str, sizeof(ser_str), "%d", serno);
|
||||||
|
|
||||||
/* fetch the model and trx number */
|
strncpy(model_name, get_hwversion_desc(), sizeof(model_name)-1);
|
||||||
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);
|
|
||||||
}
|
|
||||||
fetched_info = 1;
|
fetched_info = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user