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) {
int unknowndetected=0;
char testprefix[CONFIG_MAXOPTLENGTH];
int finalcheck = 0;
memset(testprefix,0,sizeof(testprefix));
memset(testprefix,0,sizeof(testprefix));
if (prefix != NULL) {
......
This diff is collapsed.
......@@ -2,9 +2,9 @@
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
......@@ -31,41 +31,41 @@ typedef uint64_t hash_key_t;
#define HASHTABLE_NOT_A_KEY_VALUE ((uint64_t)-1)
typedef enum hashtable_return_code_e {
HASH_TABLE_OK = 0,
HASH_TABLE_INSERT_OVERWRITTEN_DATA = 1,
HASH_TABLE_KEY_NOT_EXISTS = 2,
HASH_TABLE_KEY_ALREADY_EXISTS = 3,
HASH_TABLE_BAD_PARAMETER_HASHTABLE = 4,
HASH_TABLE_SYSTEM_ERROR = 5,
HASH_TABLE_CODE_MAX
HASH_TABLE_OK = 0,
HASH_TABLE_INSERT_OVERWRITTEN_DATA = 1,
HASH_TABLE_KEY_NOT_EXISTS = 2,
HASH_TABLE_KEY_ALREADY_EXISTS = 3,
HASH_TABLE_BAD_PARAMETER_HASHTABLE = 4,
HASH_TABLE_SYSTEM_ERROR = 5,
HASH_TABLE_CODE_MAX
} hashtable_rc_t;
typedef struct hash_node_s {
hash_key_t key;
void *data;
struct hash_node_s *next;
hash_key_t key;
void *data;
struct hash_node_s *next;
} hash_node_t;
typedef struct hash_table_s {
hash_size_t size;
hash_size_t num_elements;
struct hash_node_s **nodes;
hash_size_t (*hashfunc)(const hash_key_t);
void (*freefunc)(void*);
hash_size_t size;
hash_size_t num_elements;
struct hash_node_s **nodes;
hash_size_t (*hashfunc)(const hash_key_t);
void (*freefunc)(void *);
} hash_table_t;
char* hashtable_rc_code2string(hashtable_rc_t rcP);
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*));
hashtable_rc_t hashtable_destroy(hash_table_t * const hashtbl);
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_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_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_resize (hash_table_t * const hashtbl, const hash_size_t size);
char *hashtable_rc_code2string(hashtable_rc_t rcP);
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 *));
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_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_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_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);
......
This diff is collapsed.
......@@ -77,17 +77,17 @@ paramdef_t telnetoptions[] = {
/* configuration parameters for telnet utility */
/* optname helpstr paramflags XXXptr defXXXval type numelt */
/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
{"listenaddr", "<listen ip address>\n", 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 },
{"priority", "<scheduling policy (0-99)\n", 0, iptr:&telnetparams.priority, defuintval:0, TYPE_INT, 0 },
{"debug", "<debug level>\n", 0, uptr:NULL, defuintval:0, TYPE_UINT, 0 },
{"loopcount", "<loop command iterations>\n", 0, uptr:&(telnetparams.loopcount), defuintval:10, TYPE_UINT, 0 },
{"loopdelay", "<loop command delay (ms)>\n", 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 },
{"histsize", "<history sizes>\n", 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 },
{"staticmod", "<static modules selection>\n", 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 }
{"listenaddr", "<listen ip address>", 0, uptr:&telnetparams.listenaddr, defstrval:"0.0.0.0", TYPE_IPV4ADDR, 0 },
{"listenport", "<local port>", 0, uptr:&(telnetparams.listenport), defuintval:9090, TYPE_UINT, 0 },
{"priority", "<scheduling policy (0-99)", 0, iptr:&telnetparams.priority, defuintval:0, TYPE_INT, 0 },
{"debug", "<debug level>", 0, uptr:NULL, defuintval:0, TYPE_UINT, 0 },
{"loopcount", "<loop command iterations>", 0, uptr:&(telnetparams.loopcount), defuintval:10, TYPE_UINT, 0 },
{"loopdelay", "<loop command delay (ms)>", 0, uptr:&(telnetparams.loopdelay), defuintval:5000, TYPE_UINT, 0 },
{"histfile", "<history file name>", PARAMFLAG_NOFREE, strptr:&(telnetparams.histfile), defstrval:"oaitelnet.history", TYPE_STRING, 0 },
{"histsize", "<history sizes>", 0, iptr:&(telnetparams.histsize), defuintval:50, TYPE_INT, 0 },
{"phypbsize", "<phy dump buff size (bytes)>",0, uptr:&(telnetparams.phyprntbuff_size),defuintval:65000, TYPE_UINT, 0 },
{"staticmod", "<static modules selection>", 0, strlistptr:NULL, defstrlistval:telnet_defstatmod,TYPE_STRINGLIST,(sizeof(telnet_defstatmod)/sizeof(char *))},
{"shrmod", "<dynamic modules selection>", 0, strlistptr:NULL, defstrlistval:NULL,TYPE_STRINGLIST,0 }
};
int get_phybsize(void) {
......@@ -355,7 +355,8 @@ int setgetvar(int moduleindex,char getorset,char *params) {
char varname[TELNET_CMD_MAXSIZE];
char *varval=NULL;
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++) {
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) {
memset(cmdb,0,sizeof(cmdb));
bufbck=strdup(buf);
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)
printf("process_command: %i words, module=%s cmd=%s, parameters= %s\n",j,modulename,cmd,cmdb);
......
......@@ -29,7 +29,7 @@
* \note
* \warning
*/
#define _GNU_SOURCE
#define _GNU_SOURCE
#include <string.h>
#include <pthread.h>
......@@ -39,104 +39,88 @@
#define TELNETSRV_PHYCMD_MAIN
#include "telnetsrv_phycmd.h"
char *prnbuff;
extern int dump_eNB_stats(PHY_VARS_eNB *eNB, char* buffer, int length);
void init_phytelnet(void)
{
prnbuff=malloc(get_phybsize() );
if (prnbuff == NULL)
{
fprintf(stderr,"Error %s on malloc in init_phytelnet()\n",strerror(errno));
}
}
extern int dump_eNB_l2_stats(char *buffer, int length);
void init_phytelnet(void) {
prnbuff=malloc(get_phybsize() );
void display_uestatshead( telnet_printfunc_t prnt)
{
prnt("cc ue rnti Dmcs Umcs tao tau Dbr Dtb \n");
if (prnbuff == NULL) {
fprintf(stderr,"Error %s on malloc in init_phytelnet()\n",strerror(errno));
}
}
void dump_uestats(int debug, telnet_printfunc_t prnt, uint8_t prntflag)
{
void display_uestatshead( telnet_printfunc_t prnt) {
prnt("cc ue rnti Dmcs Umcs tao tau Dbr Dtb \n");
}
int p;
void dump_uestats(int debug, telnet_printfunc_t prnt, uint8_t prntflag) {
int p;
prnbuff=malloc(20480);
p=dump_eNB_l2_stats( prnbuff, 20480);
p=dump_eNB_l2_stats( prnbuff, 0);
if(prntflag>=1)
prnt("%s\n",prnbuff);
if(debug>=1)
prnt("%i bytes printed\n",p);
if(prntflag>=1)
prnt("%s\n",prnbuff);
if(debug>=1)
prnt("%i bytes printed\n",p);
free(prnbuff);
}
void display_uestats(int debug, telnet_printfunc_t prnt, int ue)
{
for (int cc=0; cc<1 ; cc++)
{
}
void display_uestats(int debug, telnet_printfunc_t prnt, int ue) {
for (int cc=0; cc<1 ; cc++) {
}
}
void display_phycounters(char *buf, int debug, telnet_printfunc_t prnt)
{
prnt(" DLSCH kb DLSCH kb/s\n");
dump_uestats(debug, prnt,0);
void display_phycounters(char *buf, int debug, telnet_printfunc_t prnt) {
prnt(" DLSCH kb DLSCH kb/s\n");
dump_uestats(debug, prnt,0);
}
int dump_phyvars(char *buf, int debug, telnet_printfunc_t prnt)
{
if (debug > 0)
prnt("phy interface module received %s\n",buf);
if (strcasestr(buf,"phycnt") != NULL)
{
display_phycounters(buf, debug, prnt);
}
if (strcasestr(buf,"uestat") != NULL)
{
char *cptr=strcasestr(buf+sizeof("uestat"),"UE");
display_uestatshead(prnt);
if (cptr != NULL)
{
int ueidx = strtol( cptr+sizeof("UE"), NULL, 10);
if (ueidx < NUMBER_OF_UE_MAX && ueidx >= 0)
{
display_uestats(debug, prnt,ueidx);
}
} /* if cptr != NULL */
else
{
for (int ue=0; ue<NUMBER_OF_UE_MAX ; ue++)
{
display_uestats(debug, prnt,ue);
}
} /* else cptr != NULL */
} /* uestat */
if (strcasestr(buf,"uedump") != NULL)
{
dump_uestats(debug, prnt,1);
}
return 0;
int dump_phyvars(char *buf, int debug, telnet_printfunc_t prnt) {
if (debug > 0)
prnt("phy interface module received %s\n",buf);
if (strcasestr(buf,"phycnt") != NULL) {
display_phycounters(buf, debug, prnt);
}
if (strcasestr(buf,"uestat") != NULL) {
char *cptr=strcasestr(buf+sizeof("uestat"),"UE");
display_uestatshead(prnt);
if (cptr != NULL) {
int ueidx = strtol( cptr+sizeof("UE"), NULL, 10);
if (ueidx < NUMBER_OF_UE_MAX && ueidx >= 0) {
display_uestats(debug, prnt,ueidx);
}
} /* if cptr != NULL */
else {
for (int ue=0; ue<NUMBER_OF_UE_MAX ; ue++) {
display_uestats(debug, prnt,ue);
}
} /* else cptr != NULL */
} /* uestat */
if (strcasestr(buf,"uedump") != NULL) {
dump_uestats(debug, prnt,1);
}
return 0;
}
telnetshell_cmddef_t phy_cmdarray[] = {
{"disp","[phycnt,uedump,uestat UE<x>]", dump_phyvars},
{"disp","[phycnt,uedump,uestat UE<x>]", dump_phyvars},
{"","",NULL},
{"","",NULL},
};
/*-------------------------------------------------------------------------------------*/
void add_phy_cmds(void)
{
init_phytelnet();
add_telnetcmd("phy", phy_vardef, phy_cmdarray);
void add_phy_cmds(void) {
init_phytelnet();
add_telnetcmd("phy", phy_vardef, phy_cmdarray);
}
This diff is collapsed.
This diff is collapsed.
......@@ -134,42 +134,37 @@ static const eutra_bandentry_t eutra_bandtable[] = {
{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;
int bw_by_100 = bw / 100;
int i;
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,
"Band %d, bw %u : DL carrier frequency %u Hz < %u\n",
eutra_bandP, bw, dl_CarrierFreq,
eutra_bandtable[i].dl_min);
"Band %d, bw %u : DL carrier frequency %u Hz < %u\n",
eutra_bandP, bw, dl_CarrierFreq,
eutra_bandtable[i].dl_min);
AssertFatal(dl_CarrierFreq_by_100k <=
(eutra_bandtable[i].dl_max - bw_by_100),
"Band %d, bw %u: DL carrier frequency %u Hz > %d\n",
eutra_bandP, bw, dl_CarrierFreq,
eutra_bandtable[i].dl_max - bw_by_100);
(eutra_bandtable[i].dl_max - bw_by_100),
"Band %d, bw %u: DL carrier frequency %u Hz > %d\n",
eutra_bandP, bw, dl_CarrierFreq,
eutra_bandtable[i].dl_max - bw_by_100);
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;
int bw_by_100 = bw / 100;
int i;
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,
"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
"Band %d, bw %u : DL carrier frequency %lld Hz > %d\n",
eutra_bandP, bw, dl_CarrierFreq,
eutra_bandtable[i].dl_max - bw_by_100);
return (dl_CarrierFreq_by_100k - eutra_bandtable[i].dl_min +
(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;
int bw_by_100 = bw / 100;
int i;
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,
"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
"Band %d, bw %u : UL carrier frequency %lld Hz > %d\n",
eutra_bandP, bw, ul_CarrierFreq,
eutra_bandtable[i].ul_max - bw_by_100);
return (ul_CarrierFreq_by_100k - eutra_bandtable[i].ul_min +
((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;
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 +
(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;
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);
}
......
This diff is collapsed.
......@@ -677,7 +677,7 @@ void
rlc_module_cleanup (void)
//-----------------------------------------------------------------------------
{
hashtable_destroy(rlc_coll_p);
hashtable_destroy(&rlc_coll_p);
}
//-----------------------------------------------------------------------------
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