mirror of
https://github.com/nasa/trick.git
synced 2025-06-23 09:15:29 +00:00
various static analyser bug fixes
This commit is contained in:
@ -126,7 +126,7 @@ void CommentSaver::getICGField( std::string file_name ) {
|
|||||||
so much easier in perl! */
|
so much easier in perl! */
|
||||||
|
|
||||||
/* find the ICG field */
|
/* find the ICG field */
|
||||||
ret = regcomp( ®_expr , "(ICG:)" , REG_EXTENDED | REG_ICASE ) ;
|
regcomp( ®_expr , "(ICG:)" , REG_EXTENDED | REG_ICASE ) ;
|
||||||
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
||||||
regfree(®_expr) ;
|
regfree(®_expr) ;
|
||||||
if ( ret != 0 ) {
|
if ( ret != 0 ) {
|
||||||
@ -136,7 +136,7 @@ void CommentSaver::getICGField( std::string file_name ) {
|
|||||||
|
|
||||||
/* find the end of the ICG field */
|
/* find the end of the ICG field */
|
||||||
memset(pmatch , 0 , sizeof(pmatch)) ;
|
memset(pmatch , 0 , sizeof(pmatch)) ;
|
||||||
ret = regcomp( ®_expr , "(\\))" , REG_EXTENDED ) ;
|
regcomp( ®_expr , "(\\))" , REG_EXTENDED ) ;
|
||||||
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
||||||
regfree(®_expr) ;
|
regfree(®_expr) ;
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ void CommentSaver::getICGField( std::string file_name ) {
|
|||||||
|
|
||||||
/* test for NoComment */
|
/* test for NoComment */
|
||||||
memset(pmatch , 0 , sizeof(pmatch)) ;
|
memset(pmatch , 0 , sizeof(pmatch)) ;
|
||||||
ret = regcomp( ®_expr , "(NOCOMMENT)$" , REG_EXTENDED ) ;
|
regcomp( ®_expr , "(NOCOMMENT)$" , REG_EXTENDED ) ;
|
||||||
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
||||||
regfree(®_expr) ;
|
regfree(®_expr) ;
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ void CommentSaver::getICGField( std::string file_name ) {
|
|||||||
|
|
||||||
/* test for No */
|
/* test for No */
|
||||||
memset(pmatch , 0 , sizeof(pmatch)) ;
|
memset(pmatch , 0 , sizeof(pmatch)) ;
|
||||||
ret = regcomp( ®_expr , "(NO)$" , REG_EXTENDED ) ;
|
regcomp( ®_expr , "(NO)$" , REG_EXTENDED ) ;
|
||||||
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
||||||
regfree(®_expr) ;
|
regfree(®_expr) ;
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ std::set< std::string > CommentSaver::getIgnoreTypes( std::string file_name ) {
|
|||||||
start += strlen("trick_exclude_typename") ;
|
start += strlen("trick_exclude_typename") ;
|
||||||
std::string temp_str = th_str.substr(start) ;
|
std::string temp_str = th_str.substr(start) ;
|
||||||
memset(pmatch , 0 , sizeof(pmatch)) ;
|
memset(pmatch , 0 , sizeof(pmatch)) ;
|
||||||
ret = regcomp( ®_expr , "^\\s*\\{\\s*(\\S+)\\s*\\}" , REG_EXTENDED ) ;
|
regcomp( ®_expr , "^\\s*\\{\\s*(\\S+)\\s*\\}" , REG_EXTENDED ) ;
|
||||||
ret = regexec( ®_expr , temp_str.c_str() , 10 , pmatch , 0 ) ;
|
ret = regexec( ®_expr , temp_str.c_str() , 10 , pmatch , 0 ) ;
|
||||||
regfree(®_expr) ;
|
regfree(®_expr) ;
|
||||||
if ( ret == 0 ) {
|
if ( ret == 0 ) {
|
||||||
@ -230,7 +230,7 @@ std::set< std::string > CommentSaver::getIgnoreTypes( std::string file_name ) {
|
|||||||
so much easier in perl! */
|
so much easier in perl! */
|
||||||
|
|
||||||
/* find the start of the ICG_IGNORE_TYPES field */
|
/* find the start of the ICG_IGNORE_TYPES field */
|
||||||
ret = regcomp( ®_expr , "(ICG[ _]IGNORE[ _]TYPE(S)?:)" , REG_EXTENDED | REG_ICASE ) ;
|
regcomp( ®_expr , "(ICG[ _]IGNORE[ _]TYPE(S)?:)" , REG_EXTENDED | REG_ICASE ) ;
|
||||||
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
||||||
regfree(®_expr) ;
|
regfree(®_expr) ;
|
||||||
if ( ret != 0 ) {
|
if ( ret != 0 ) {
|
||||||
@ -240,7 +240,7 @@ std::set< std::string > CommentSaver::getIgnoreTypes( std::string file_name ) {
|
|||||||
|
|
||||||
/* find the end of the ICG_IGNORE_TYPES field */
|
/* find the end of the ICG_IGNORE_TYPES field */
|
||||||
memset(pmatch , 0 , sizeof(pmatch)) ;
|
memset(pmatch , 0 , sizeof(pmatch)) ;
|
||||||
ret = regcomp( ®_expr , "(\\)\\s*\\))" , REG_EXTENDED ) ;
|
regcomp( ®_expr , "(\\)\\s*\\))" , REG_EXTENDED ) ;
|
||||||
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
||||||
regfree(®_expr) ;
|
regfree(®_expr) ;
|
||||||
if ( ret != 0 ) {
|
if ( ret != 0 ) {
|
||||||
|
@ -85,7 +85,7 @@ std::string FieldDescription::get_regex_field(std::string input , const char * e
|
|||||||
regex_t reg_expr ;
|
regex_t reg_expr ;
|
||||||
regmatch_t pmatch[10] ;
|
regmatch_t pmatch[10] ;
|
||||||
memset(pmatch , 0 , sizeof(pmatch)) ;
|
memset(pmatch , 0 , sizeof(pmatch)) ;
|
||||||
ret = regcomp( ®_expr , expr , REG_EXTENDED ) ;
|
regcomp( ®_expr , expr , REG_EXTENDED ) ;
|
||||||
//std::cout << "regcomp ret = " << ret << std::endl ;
|
//std::cout << "regcomp ret = " << ret << std::endl ;
|
||||||
ret = regexec( ®_expr , input.c_str() , 10 , pmatch , 0 ) ;
|
ret = regexec( ®_expr , input.c_str() , 10 , pmatch , 0 ) ;
|
||||||
//std::cout << "regexec ret = " << ret << std::endl ;
|
//std::cout << "regexec ret = " << ret << std::endl ;
|
||||||
|
@ -20,7 +20,7 @@ MatLab4::MatLab4(char * file_name , char * param_name , char * time_name ) {
|
|||||||
int temp ;
|
int temp ;
|
||||||
int endian ;
|
int endian ;
|
||||||
int mat_size ;
|
int mat_size ;
|
||||||
int type , size ;
|
int type, size = 0;
|
||||||
int mat_type ;
|
int mat_type ;
|
||||||
int my_byte_order ;
|
int my_byte_order ;
|
||||||
div_t div_result ;
|
div_t div_result ;
|
||||||
|
@ -329,7 +329,6 @@ int LogData::countNumBinaryFiles(char *pathToBinaryData)
|
|||||||
fprintf(stderr, "Couldn't open \"%s\" for reading. \n",
|
fprintf(stderr, "Couldn't open \"%s\" for reading. \n",
|
||||||
pathToBinaryData);
|
pathToBinaryData);
|
||||||
fprintf(stderr, "Maybe LogGroup Constructor not called.\n");
|
fprintf(stderr, "Maybe LogGroup Constructor not called.\n");
|
||||||
closedir(dirp);
|
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1471,7 +1470,6 @@ int LogGroup::getHeaders()
|
|||||||
fprintf(stderr, "ERROR: Couldn't open \"%s\" for reading. \n",
|
fprintf(stderr, "ERROR: Couldn't open \"%s\" for reading. \n",
|
||||||
pathToBinaryData_);
|
pathToBinaryData_);
|
||||||
fprintf(stderr, "Maybe LogGroup constructer wasn't done. \n");
|
fprintf(stderr, "Maybe LogGroup constructer wasn't done. \n");
|
||||||
closedir(dirp);
|
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
// Count num headers, and max file name length in RUN dir
|
// Count num headers, and max file name length in RUN dir
|
||||||
|
@ -86,9 +86,10 @@ int Trick::VariableServerThread::copy_sim_data() {
|
|||||||
curr_var->size = wcslen((wchar_t *)curr_var->address) * sizeof(wchar_t);
|
curr_var->size = wcslen((wchar_t *)curr_var->address) * sizeof(wchar_t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(curr_var->address != NULL) {
|
||||||
memcpy( curr_var->buffer_in , curr_var->address , curr_var->size ) ;
|
memcpy( curr_var->buffer_in , curr_var->address , curr_var->size ) ;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Indicate that sim data has been written and is now ready in the buffer_in's of the vars variable list.
|
// Indicate that sim data has been written and is now ready in the buffer_in's of the vars variable list.
|
||||||
var_data_staged = true;
|
var_data_staged = true;
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
int tc_init_mcast_client(TCDevice * mcast_client_device)
|
int tc_init_mcast_client(TCDevice * mcast_client_device)
|
||||||
{
|
{
|
||||||
if (!mcast_client_device) {
|
if (!mcast_client_device) {
|
||||||
trick_error_report(mcast_client_device->error_handler,
|
trick_error_report(NULL,
|
||||||
TRICK_ERROR_ALERT, __FILE__, __LINE__, "mcast device is null.");
|
TRICK_ERROR_ALERT, __FILE__, __LINE__, "mcast device is null.");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ int tc_init_mcast_server(TCDevice * mcast_server_device)
|
|||||||
const unsigned int yes = 1;
|
const unsigned int yes = 1;
|
||||||
|
|
||||||
if (!mcast_server_device) {
|
if (!mcast_server_device) {
|
||||||
trick_error_report(mcast_server_device->error_handler,
|
trick_error_report(NULL,
|
||||||
TRICK_ERROR_ALERT, __FILE__, __LINE__, "mcast device is null.");
|
TRICK_ERROR_ALERT, __FILE__, __LINE__, "mcast device is null.");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ int tc_init_udp_client(TCDevice * udp_client_device)
|
|||||||
memset(&sockin, 0 , sizeof(struct sockaddr_in)) ;
|
memset(&sockin, 0 , sizeof(struct sockaddr_in)) ;
|
||||||
|
|
||||||
if (!udp_client_device) {
|
if (!udp_client_device) {
|
||||||
trick_error_report(udp_client_device->error_handler,
|
trick_error_report(NULL,
|
||||||
TRICK_ERROR_ALERT, __FILE__, __LINE__, "UDP device is null.");
|
TRICK_ERROR_ALERT, __FILE__, __LINE__, "UDP device is null.");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ int tc_init_udp_server( /* RETURN: -- 0 for success */
|
|||||||
unsigned int yes = 1;
|
unsigned int yes = 1;
|
||||||
|
|
||||||
if (!udp_server_device) {
|
if (!udp_server_device) {
|
||||||
trick_error_report(udp_server_device->error_handler,
|
trick_error_report(NULL,
|
||||||
TRICK_ERROR_ALERT, __FILE__, __LINE__, "UDP device is null.");
|
TRICK_ERROR_ALERT, __FILE__, __LINE__, "UDP device is null.");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,6 @@ int tsm_disconnect(TSMDevice * shm_device)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = TSM_SUCCESS;
|
|
||||||
|
|
||||||
// if we had a read/write lock, destroy it first
|
// if we had a read/write lock, destroy it first
|
||||||
if (shm_device->rwlock_addr != NULL) {
|
if (shm_device->rwlock_addr != NULL) {
|
||||||
ret = pthread_rwlockattr_destroy(&shm_device->rwlattr);
|
ret = pthread_rwlockattr_destroy(&shm_device->rwlattr);
|
||||||
|
@ -11,8 +11,12 @@ bstNode *bstFind(void *info, BST * bst)
|
|||||||
{
|
{
|
||||||
bstNode *current;
|
bstNode *current;
|
||||||
|
|
||||||
if (bst == NULL && info == NULL) {
|
if (bst == NULL) {
|
||||||
fprintf(stderr, "Queue is empty");
|
fprintf(stderr, "bst is not allocated");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (info == NULL) {
|
||||||
|
fprintf(stderr, "info is invalid pointer");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,8 +101,12 @@ void *bstDelete(bstNode * node, BST * bst)
|
|||||||
bstNode **parentspointer;
|
bstNode **parentspointer;
|
||||||
|
|
||||||
|
|
||||||
if (node == NULL && bst == NULL) {
|
if (bst == NULL) {
|
||||||
fprintf(stderr, "Queue is empty");
|
fprintf(stderr, "bst is not allocated");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (node == NULL) {
|
||||||
|
fprintf(stderr, "node is invalid pointer");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +115,7 @@ void *bstDelete(bstNode * node, BST * bst)
|
|||||||
return (node);
|
return (node);
|
||||||
}
|
}
|
||||||
bst->nodes--; /* decrement the node counter */
|
bst->nodes--; /* decrement the node counter */
|
||||||
if (node->parent != NULL) { /* if node is not the root, *//* then get the address of the parent's pointer to node */
|
if (node && node->parent != NULL) { /* if node is not the root, *//* then get the address of the parent's pointer to node */
|
||||||
if (node->parent->left == node)
|
if (node->parent->left == node)
|
||||||
parentspointer = &(node->parent->left);
|
parentspointer = &(node->parent->left);
|
||||||
else
|
else
|
||||||
@ -201,12 +209,16 @@ bstNode *bstInsert(void *info, BST * bst)
|
|||||||
int done = 0;
|
int done = 0;
|
||||||
|
|
||||||
|
|
||||||
if (bst == NULL && info == NULL) {
|
if (bst == NULL) {
|
||||||
fprintf(stderr, "Queue is empty");
|
fprintf(stderr, "bst is not allocated");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (info == NULL) {
|
||||||
|
fprintf(stderr, "info is invalid pointer");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bst->init) {
|
if (bst && !bst->init) {
|
||||||
bstInit(bst);
|
bstInit(bst);
|
||||||
}
|
}
|
||||||
newNode = (bstNode *) malloc(sizeof(bstNode)); /* allocate memory for the node */
|
newNode = (bstNode *) malloc(sizeof(bstNode)); /* allocate memory for the node */
|
||||||
|
Reference in New Issue
Block a user