Commit 501ae74c authored by frtabu's avatar frtabu

first set of cppcheck fixes

parent 52754797
...@@ -166,6 +166,7 @@ int config_check_unknown_cmdlineopt(char *prefix) { ...@@ -166,6 +166,7 @@ int config_check_unknown_cmdlineopt(char *prefix) {
int unknowndetected=0; int unknowndetected=0;
char testprefix[CONFIG_MAXOPTLENGTH]; char testprefix[CONFIG_MAXOPTLENGTH];
int finalcheck = 0; int finalcheck = 0;
memset(testprefix,0,sizeof(testprefix));
memset(testprefix,0,sizeof(testprefix)); memset(testprefix,0,sizeof(testprefix));
if (prefix != NULL) { if (prefix != NULL) {
......
This diff is collapsed.
...@@ -52,20 +52,20 @@ typedef struct hash_table_s { ...@@ -52,20 +52,20 @@ typedef struct hash_table_s {
hash_size_t num_elements; hash_size_t num_elements;
struct hash_node_s **nodes; struct hash_node_s **nodes;
hash_size_t (*hashfunc)(const hash_key_t); hash_size_t (*hashfunc)(const hash_key_t);
void (*freefunc)(void*); void (*freefunc)(void *);
} hash_table_t; } hash_table_t;
char* hashtable_rc_code2string(hashtable_rc_t rcP); char *hashtable_rc_code2string(hashtable_rc_t rcP);
void hash_free_int_func(void* memoryP); void hash_free_int_func(void *memoryP);
hash_table_t *hashtable_create (const hash_size_t size, hash_size_t (*hashfunc)(const hash_key_t ), void (*freefunc)(void*)); hash_table_t *hashtable_create (const hash_size_t size, hash_size_t (*hashfunc)(const hash_key_t ), void (*freefunc)(void *));
hashtable_rc_t hashtable_destroy(hash_table_t * const hashtbl); hashtable_rc_t hashtable_destroy(hash_table_t **hashtbl);
hashtable_rc_t hashtable_is_key_exists (const hash_table_t * const hashtbl, const uint64_t key); hashtable_rc_t hashtable_is_key_exists (const hash_table_t *const hashtbl, const uint64_t key);
hashtable_rc_t hashtable_apply_funct_on_elements (hash_table_t * const hashtblP, void funct(hash_key_t keyP, void* dataP, void* parameterP), void* parameterP); hashtable_rc_t hashtable_apply_funct_on_elements (hash_table_t *const hashtblP, void funct(hash_key_t keyP, void *dataP, void *parameterP), void *parameterP);
hashtable_rc_t hashtable_dump_content (const hash_table_t * const hashtblP, char * const buffer_pP, int * const remaining_bytes_in_buffer_pP ); hashtable_rc_t hashtable_dump_content (const hash_table_t *const hashtblP, char *const buffer_pP, int *const remaining_bytes_in_buffer_pP );
hashtable_rc_t hashtable_insert (hash_table_t * const hashtbl, const hash_key_t key, void *data); hashtable_rc_t hashtable_insert (hash_table_t *const hashtbl, const hash_key_t key, void *data);
hashtable_rc_t hashtable_remove (hash_table_t * const hashtbl, const hash_key_t key); hashtable_rc_t hashtable_remove (hash_table_t *const hashtbl, const hash_key_t key);
hashtable_rc_t hashtable_get (const hash_table_t * const hashtbl, const hash_key_t key, void **dataP); hashtable_rc_t hashtable_get (const hash_table_t *const hashtbl, const hash_key_t key, void **dataP);
hashtable_rc_t hashtable_resize (hash_table_t * const hashtbl, const hash_size_t size); hashtable_rc_t hashtable_resize (hash_table_t *const hashtbl, const hash_size_t size);
......
This diff is collapsed.
...@@ -77,17 +77,17 @@ paramdef_t telnetoptions[] = { ...@@ -77,17 +77,17 @@ paramdef_t telnetoptions[] = {
/* configuration parameters for telnet utility */ /* configuration parameters for telnet utility */
/* optname helpstr paramflags XXXptr defXXXval type numelt */ /* optname helpstr paramflags XXXptr defXXXval type numelt */
/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
{"listenaddr", "<listen ip address>\n", 0, uptr:&telnetparams.listenaddr, defstrval:"0.0.0.0", TYPE_IPV4ADDR, 0 }, {"listenaddr", "<listen ip address>", 0, uptr:&telnetparams.listenaddr, defstrval:"0.0.0.0", TYPE_IPV4ADDR, 0 },
{"listenport", "<local port>\n", 0, uptr:&(telnetparams.listenport), defuintval:9090, TYPE_UINT, 0 }, {"listenport", "<local port>", 0, uptr:&(telnetparams.listenport), defuintval:9090, TYPE_UINT, 0 },
{"priority", "<scheduling policy (0-99)\n", 0, iptr:&telnetparams.priority, defuintval:0, TYPE_INT, 0 }, {"priority", "<scheduling policy (0-99)", 0, iptr:&telnetparams.priority, defuintval:0, TYPE_INT, 0 },
{"debug", "<debug level>\n", 0, uptr:NULL, defuintval:0, TYPE_UINT, 0 }, {"debug", "<debug level>", 0, uptr:NULL, defuintval:0, TYPE_UINT, 0 },
{"loopcount", "<loop command iterations>\n", 0, uptr:&(telnetparams.loopcount), defuintval:10, TYPE_UINT, 0 }, {"loopcount", "<loop command iterations>", 0, uptr:&(telnetparams.loopcount), defuintval:10, TYPE_UINT, 0 },
{"loopdelay", "<loop command delay (ms)>\n", 0, uptr:&(telnetparams.loopdelay), defuintval:5000, TYPE_UINT, 0 }, {"loopdelay", "<loop command delay (ms)>", 0, uptr:&(telnetparams.loopdelay), defuintval:5000, TYPE_UINT, 0 },
{"histfile", "<history file name>\n", PARAMFLAG_NOFREE, strptr:&(telnetparams.histfile), defstrval:"oaitelnet.history", TYPE_STRING, 0 }, {"histfile", "<history file name>", PARAMFLAG_NOFREE, strptr:&(telnetparams.histfile), defstrval:"oaitelnet.history", TYPE_STRING, 0 },
{"histsize", "<history sizes>\n", 0, iptr:&(telnetparams.histsize), defuintval:50, TYPE_INT, 0 }, {"histsize", "<history sizes>", 0, iptr:&(telnetparams.histsize), defuintval:50, TYPE_INT, 0 },
{"phypbsize", "<phy dump buff size (bytes)>\n",0, uptr:&(telnetparams.phyprntbuff_size),defuintval:65000, TYPE_UINT, 0 }, {"phypbsize", "<phy dump buff size (bytes)>",0, uptr:&(telnetparams.phyprntbuff_size),defuintval:65000, TYPE_UINT, 0 },
{"staticmod", "<static modules selection>\n", 0, strlistptr:NULL, defstrlistval:telnet_defstatmod,TYPE_STRINGLIST,(sizeof(telnet_defstatmod)/sizeof(char *))}, {"staticmod", "<static modules selection>", 0, strlistptr:NULL, defstrlistval:telnet_defstatmod,TYPE_STRINGLIST,(sizeof(telnet_defstatmod)/sizeof(char *))},
{"shrmod", "<dynamic modules selection>\n", 0, strlistptr:NULL, defstrlistval:NULL,TYPE_STRINGLIST,0 } {"shrmod", "<dynamic modules selection>", 0, strlistptr:NULL, defstrlistval:NULL,TYPE_STRINGLIST,0 }
}; };
int get_phybsize(void) { int get_phybsize(void) {
...@@ -355,7 +355,8 @@ int setgetvar(int moduleindex,char getorset,char *params) { ...@@ -355,7 +355,8 @@ int setgetvar(int moduleindex,char getorset,char *params) {
char varname[TELNET_CMD_MAXSIZE]; char varname[TELNET_CMD_MAXSIZE];
char *varval=NULL; char *varval=NULL;
memset(varname,0,sizeof(varname)); memset(varname,0,sizeof(varname));
n = sscanf(params,"%s %ms",varname,&varval); n = sscanf(params,"%19s %ms",varname,&varval);
for ( i=0 ; telnetparams.CmdParsers[moduleindex].var[i].varvalptr != NULL ; i++) { for ( i=0 ; telnetparams.CmdParsers[moduleindex].var[i].varvalptr != NULL ; i++) {
if ( strncasecmp(telnetparams.CmdParsers[moduleindex].var[i].varname,varname,strlen(telnetparams.CmdParsers[moduleindex].var[i].varname)) == 0) { if ( strncasecmp(telnetparams.CmdParsers[moduleindex].var[i].varname,varname,strlen(telnetparams.CmdParsers[moduleindex].var[i].varname)) == 0) {
...@@ -475,7 +476,8 @@ int process_command(char *buf) { ...@@ -475,7 +476,8 @@ int process_command(char *buf) {
memset(cmdb,0,sizeof(cmdb)); memset(cmdb,0,sizeof(cmdb));
bufbck=strdup(buf); bufbck=strdup(buf);
rt=CMDSTATUS_NOTFOUND; rt=CMDSTATUS_NOTFOUND;
j = sscanf(buf,"%9s %9s %[^\t\n]",modulename,cmd,cmdb); j = sscanf(buf,"%9s %9s %2000[^\t\n]",modulename,cmd,cmdb);
if (telnetparams.telnetdbg > 0) if (telnetparams.telnetdbg > 0)
printf("process_command: %i words, module=%s cmd=%s, parameters= %s\n",j,modulename,cmd,cmdb); printf("process_command: %i words, module=%s cmd=%s, parameters= %s\n",j,modulename,cmd,cmdb);
......
...@@ -39,88 +39,74 @@ ...@@ -39,88 +39,74 @@
#define TELNETSRV_PHYCMD_MAIN #define TELNETSRV_PHYCMD_MAIN
#include "telnetsrv_phycmd.h" #include "telnetsrv_phycmd.h"
char *prnbuff; char *prnbuff;
extern int dump_eNB_stats(PHY_VARS_eNB *eNB, char* buffer, int length); extern int dump_eNB_l2_stats(char *buffer, int length);
void init_phytelnet(void) void init_phytelnet(void) {
{ prnbuff=malloc(get_phybsize() );
prnbuff=malloc(get_phybsize() );
if (prnbuff == NULL) if (prnbuff == NULL) {
{
fprintf(stderr,"Error %s on malloc in init_phytelnet()\n",strerror(errno)); fprintf(stderr,"Error %s on malloc in init_phytelnet()\n",strerror(errno));
} }
} }
void display_uestatshead( telnet_printfunc_t prnt) void display_uestatshead( telnet_printfunc_t prnt) {
{ prnt("cc ue rnti Dmcs Umcs tao tau Dbr Dtb \n");
prnt("cc ue rnti Dmcs Umcs tao tau Dbr Dtb \n");
} }
void dump_uestats(int debug, telnet_printfunc_t prnt, uint8_t prntflag) void dump_uestats(int debug, telnet_printfunc_t prnt, uint8_t prntflag) {
{ int p;
prnbuff=malloc(20480);
int p; p=dump_eNB_l2_stats( prnbuff, 20480);
p=dump_eNB_l2_stats( prnbuff, 0);
if(prntflag>=1) if(prntflag>=1)
prnt("%s\n",prnbuff); prnt("%s\n",prnbuff);
if(debug>=1) if(debug>=1)
prnt("%i bytes printed\n",p); prnt("%i bytes printed\n",p);
free(prnbuff);
} }
void display_uestats(int debug, telnet_printfunc_t prnt, int ue) void display_uestats(int debug, telnet_printfunc_t prnt, int ue) {
{ for (int cc=0; cc<1 ; cc++) {
for (int cc=0; cc<1 ; cc++)
{
} }
} }
void display_phycounters(char *buf, int debug, telnet_printfunc_t prnt) void display_phycounters(char *buf, int debug, telnet_printfunc_t prnt) {
{
prnt(" DLSCH kb DLSCH kb/s\n"); prnt(" DLSCH kb DLSCH kb/s\n");
dump_uestats(debug, prnt,0); dump_uestats(debug, prnt,0);
} }
int dump_phyvars(char *buf, int debug, telnet_printfunc_t prnt) int dump_phyvars(char *buf, int debug, telnet_printfunc_t prnt) {
{
if (debug > 0) if (debug > 0)
prnt("phy interface module received %s\n",buf); prnt("phy interface module received %s\n",buf);
if (strcasestr(buf,"phycnt") != NULL)
{ if (strcasestr(buf,"phycnt") != NULL) {
display_phycounters(buf, debug, prnt); display_phycounters(buf, debug, prnt);
} }
if (strcasestr(buf,"uestat") != NULL)
{ if (strcasestr(buf,"uestat") != NULL) {
char *cptr=strcasestr(buf+sizeof("uestat"),"UE"); char *cptr=strcasestr(buf+sizeof("uestat"),"UE");
display_uestatshead(prnt); display_uestatshead(prnt);
if (cptr != NULL)
{ if (cptr != NULL) {
int ueidx = strtol( cptr+sizeof("UE"), NULL, 10); int ueidx = strtol( cptr+sizeof("UE"), NULL, 10);
if (ueidx < NUMBER_OF_UE_MAX && ueidx >= 0)
{ if (ueidx < NUMBER_OF_UE_MAX && ueidx >= 0) {
display_uestats(debug, prnt,ueidx); display_uestats(debug, prnt,ueidx);
} }
} /* if cptr != NULL */ } /* if cptr != NULL */
else else {
{ for (int ue=0; ue<NUMBER_OF_UE_MAX ; ue++) {
for (int ue=0; ue<NUMBER_OF_UE_MAX ; ue++)
{
display_uestats(debug, prnt,ue); display_uestats(debug, prnt,ue);
} }
} /* else cptr != NULL */ } /* else cptr != NULL */
} /* uestat */ } /* uestat */
if (strcasestr(buf,"uedump") != NULL)
{ if (strcasestr(buf,"uedump") != NULL) {
dump_uestats(debug, prnt,1); dump_uestats(debug, prnt,1);
} }
return 0; return 0;
} }
...@@ -134,9 +120,7 @@ telnetshell_cmddef_t phy_cmdarray[] = { ...@@ -134,9 +120,7 @@ telnetshell_cmddef_t phy_cmdarray[] = {
/*-------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------*/
void add_phy_cmds(void) void add_phy_cmds(void) {
{
init_phytelnet(); init_phytelnet();
add_telnetcmd("phy", phy_vardef, phy_cmdarray); add_telnetcmd("phy", phy_vardef, phy_cmdarray);
} }
This diff is collapsed.
This diff is collapsed.
...@@ -134,16 +134,16 @@ static const eutra_bandentry_t eutra_bandtable[] = { ...@@ -134,16 +134,16 @@ static const eutra_bandentry_t eutra_bandtable[] = {
{68, 6980, 7280, 7530, 7830, 67536} {68, 6980, 7280, 7530, 7830, 67536}
}; };
uint32_t to_earfcn(int eutra_bandP, uint32_t dl_CarrierFreq, uint32_t bw)
{
#define BANDTABLE_SIZE (sizeof(eutra_bandtable)/sizeof(eutra_bandentry_t))
uint32_t to_earfcn(int eutra_bandP, uint32_t dl_CarrierFreq, uint32_t bw) {
uint32_t dl_CarrierFreq_by_100k = dl_CarrierFreq / 100000; uint32_t dl_CarrierFreq_by_100k = dl_CarrierFreq / 100000;
int bw_by_100 = bw / 100; int bw_by_100 = bw / 100;
int i; int i;
AssertFatal(eutra_bandP < 69, "eutra_band %d > 68\n", eutra_bandP); AssertFatal(eutra_bandP < 69, "eutra_band %d > 68\n", eutra_bandP);
for (i = 0; i < 69 && eutra_bandtable[i].band != eutra_bandP; i++);
for (i = 0; i < BANDTABLE_SIZE && eutra_bandtable[i].band != eutra_bandP; i++);
AssertFatal(dl_CarrierFreq_by_100k >= eutra_bandtable[i].dl_min, AssertFatal(dl_CarrierFreq_by_100k >= eutra_bandtable[i].dl_min,
"Band %d, bw %u : DL carrier frequency %u Hz < %u\n", "Band %d, bw %u : DL carrier frequency %u Hz < %u\n",
...@@ -154,22 +154,17 @@ uint32_t to_earfcn(int eutra_bandP, uint32_t dl_CarrierFreq, uint32_t bw) ...@@ -154,22 +154,17 @@ uint32_t to_earfcn(int eutra_bandP, uint32_t dl_CarrierFreq, uint32_t bw)
"Band %d, bw %u: DL carrier frequency %u Hz > %d\n", "Band %d, bw %u: DL carrier frequency %u Hz > %d\n",
eutra_bandP, bw, dl_CarrierFreq, eutra_bandP, bw, dl_CarrierFreq,
eutra_bandtable[i].dl_max - bw_by_100); eutra_bandtable[i].dl_max - bw_by_100);
return (dl_CarrierFreq_by_100k - eutra_bandtable[i].dl_min + return (dl_CarrierFreq_by_100k - eutra_bandtable[i].dl_min +
(eutra_bandtable[i].N_OFFs_DL / 10)); (eutra_bandtable[i].N_OFFs_DL / 10));
} }
uint32_t to_earfcn_DL(int eutra_bandP, long long int dl_CarrierFreq, uint32_t bw) uint32_t to_earfcn_DL(int eutra_bandP, long long int dl_CarrierFreq, uint32_t bw) {
{
uint32_t dl_CarrierFreq_by_100k = dl_CarrierFreq / 100000; uint32_t dl_CarrierFreq_by_100k = dl_CarrierFreq / 100000;
int bw_by_100 = bw / 100; int bw_by_100 = bw / 100;
int i; int i;
AssertFatal(eutra_bandP < 69, "eutra_band %d > 68\n", eutra_bandP); AssertFatal(eutra_bandP < 69, "eutra_band %d > 68\n", eutra_bandP);
for (i = 0; i < 69 && eutra_bandtable[i].band != eutra_bandP; i++);
for (i = 0; i < BANDTABLE_SIZE && eutra_bandtable[i].band != eutra_bandP; i++);
AssertFatal(dl_CarrierFreq_by_100k >= eutra_bandtable[i].dl_min, AssertFatal(dl_CarrierFreq_by_100k >= eutra_bandtable[i].dl_min,
"Band %d, bw %u : DL carrier frequency %lld Hz < %u\n", "Band %d, bw %u : DL carrier frequency %lld Hz < %u\n",
...@@ -180,22 +175,17 @@ uint32_t to_earfcn_DL(int eutra_bandP, long long int dl_CarrierFreq, uint32_t bw ...@@ -180,22 +175,17 @@ uint32_t to_earfcn_DL(int eutra_bandP, long long int dl_CarrierFreq, uint32_t bw
"Band %d, bw %u : DL carrier frequency %lld Hz > %d\n", "Band %d, bw %u : DL carrier frequency %lld Hz > %d\n",
eutra_bandP, bw, dl_CarrierFreq, eutra_bandP, bw, dl_CarrierFreq,
eutra_bandtable[i].dl_max - bw_by_100); eutra_bandtable[i].dl_max - bw_by_100);
return (dl_CarrierFreq_by_100k - eutra_bandtable[i].dl_min + return (dl_CarrierFreq_by_100k - eutra_bandtable[i].dl_min +
(eutra_bandtable[i].N_OFFs_DL / 10)); (eutra_bandtable[i].N_OFFs_DL / 10));
} }
uint32_t to_earfcn_UL(int eutra_bandP, long long int ul_CarrierFreq, uint32_t bw) uint32_t to_earfcn_UL(int eutra_bandP, long long int ul_CarrierFreq, uint32_t bw) {
{
uint32_t ul_CarrierFreq_by_100k = ul_CarrierFreq / 100000; uint32_t ul_CarrierFreq_by_100k = ul_CarrierFreq / 100000;
int bw_by_100 = bw / 100; int bw_by_100 = bw / 100;
int i; int i;
AssertFatal(eutra_bandP < 69, "eutra_band %d > 68\n", eutra_bandP); AssertFatal(eutra_bandP < 69, "eutra_band %d > 68\n", eutra_bandP);
for (i = 0; i < 69 && eutra_bandtable[i].band != eutra_bandP; i++);
for (i = 0; i < BANDTABLE_SIZE && eutra_bandtable[i].band != eutra_bandP; i++);
AssertFatal(ul_CarrierFreq_by_100k >= eutra_bandtable[i].ul_min, AssertFatal(ul_CarrierFreq_by_100k >= eutra_bandtable[i].ul_min,
"Band %d, bw %u : UL carrier frequency %lld Hz < %u\n", "Band %d, bw %u : UL carrier frequency %lld Hz < %u\n",
...@@ -206,30 +196,26 @@ uint32_t to_earfcn_UL(int eutra_bandP, long long int ul_CarrierFreq, uint32_t bw ...@@ -206,30 +196,26 @@ uint32_t to_earfcn_UL(int eutra_bandP, long long int ul_CarrierFreq, uint32_t bw
"Band %d, bw %u : UL carrier frequency %lld Hz > %d\n", "Band %d, bw %u : UL carrier frequency %lld Hz > %d\n",
eutra_bandP, bw, ul_CarrierFreq, eutra_bandP, bw, ul_CarrierFreq,
eutra_bandtable[i].ul_max - bw_by_100); eutra_bandtable[i].ul_max - bw_by_100);
return (ul_CarrierFreq_by_100k - eutra_bandtable[i].ul_min + return (ul_CarrierFreq_by_100k - eutra_bandtable[i].ul_min +
((eutra_bandtable[i].N_OFFs_DL + 180000) / 10)); ((eutra_bandtable[i].N_OFFs_DL + 180000) / 10));
} }
uint32_t from_earfcn(int eutra_bandP, uint32_t dl_earfcn) uint32_t from_earfcn(int eutra_bandP, uint32_t dl_earfcn) {
{
int i; int i;
AssertFatal(eutra_bandP < 69, "eutra_band %d > 68\n", eutra_bandP); AssertFatal(eutra_bandP < 69, "eutra_band %d > 68\n", eutra_bandP);
for (i = 0; i < 69 && eutra_bandtable[i].band != eutra_bandP; i++);
for (i = 0; i < BANDTABLE_SIZE && eutra_bandtable[i].band != eutra_bandP; i++);
return (eutra_bandtable[i].dl_min + return (eutra_bandtable[i].dl_min +
(dl_earfcn - (eutra_bandtable[i].N_OFFs_DL / 10))) * 100000; (dl_earfcn - (eutra_bandtable[i].N_OFFs_DL / 10))) * 100000;
} }
int32_t get_uldl_offset(int eutra_bandP) int32_t get_uldl_offset(int eutra_bandP) {
{
int i; int i;
for (i = 0; i < 69 && eutra_bandtable[i].band != eutra_bandP; i++); for (i = 0; i < BANDTABLE_SIZE && eutra_bandtable[i].band != eutra_bandP; i++);
return (eutra_bandtable[i].dl_min - eutra_bandtable[i].ul_min); return (eutra_bandtable[i].dl_min - eutra_bandtable[i].ul_min);
} }
......
This diff is collapsed.
...@@ -677,7 +677,7 @@ void ...@@ -677,7 +677,7 @@ void
rlc_module_cleanup (void) rlc_module_cleanup (void)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
{ {
hashtable_destroy(rlc_coll_p); hashtable_destroy(&rlc_coll_p);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment