mirror of
https://github.com/nasa/trick.git
synced 2025-03-22 20:15:26 +00:00
various static analyser bug fixes
This commit is contained in:
parent
fcbd99aaf4
commit
77e0e73b3f
@ -126,7 +126,7 @@ void CommentSaver::getICGField( std::string file_name ) {
|
||||
so much easier in perl! */
|
||||
|
||||
/* 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 ) ;
|
||||
regfree(®_expr) ;
|
||||
if ( ret != 0 ) {
|
||||
@ -136,7 +136,7 @@ void CommentSaver::getICGField( std::string file_name ) {
|
||||
|
||||
/* find the end of the ICG field */
|
||||
memset(pmatch , 0 , sizeof(pmatch)) ;
|
||||
ret = regcomp( ®_expr , "(\\))" , REG_EXTENDED ) ;
|
||||
regcomp( ®_expr , "(\\))" , REG_EXTENDED ) ;
|
||||
ret = regexec( ®_expr , th_str.c_str() , 10 , pmatch , 0 ) ;
|
||||
regfree(®_expr) ;
|
||||
|
||||
@ -147,7 +147,7 @@ void CommentSaver::getICGField( std::string file_name ) {
|
||||
|
||||
/* test for NoComment */
|
||||
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 ) ;
|
||||
regfree(®_expr) ;
|
||||
|
||||
@ -157,7 +157,7 @@ void CommentSaver::getICGField( std::string file_name ) {
|
||||
|
||||
/* test for No */
|
||||
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 ) ;
|
||||
regfree(®_expr) ;
|
||||
|
||||
@ -208,7 +208,7 @@ std::set< std::string > CommentSaver::getIgnoreTypes( std::string file_name ) {
|
||||
start += strlen("trick_exclude_typename") ;
|
||||
std::string temp_str = th_str.substr(start) ;
|
||||
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 ) ;
|
||||
regfree(®_expr) ;
|
||||
if ( ret == 0 ) {
|
||||
@ -230,7 +230,7 @@ std::set< std::string > CommentSaver::getIgnoreTypes( std::string file_name ) {
|
||||
so much easier in perl! */
|
||||
|
||||
/* 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 ) ;
|
||||
regfree(®_expr) ;
|
||||
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 */
|
||||
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 ) ;
|
||||
regfree(®_expr) ;
|
||||
if ( ret != 0 ) {
|
||||
|
@ -85,7 +85,7 @@ std::string FieldDescription::get_regex_field(std::string input , const char * e
|
||||
regex_t reg_expr ;
|
||||
regmatch_t pmatch[10] ;
|
||||
memset(pmatch , 0 , sizeof(pmatch)) ;
|
||||
ret = regcomp( ®_expr , expr , REG_EXTENDED ) ;
|
||||
regcomp( ®_expr , expr , REG_EXTENDED ) ;
|
||||
//std::cout << "regcomp ret = " << ret << std::endl ;
|
||||
ret = regexec( ®_expr , input.c_str() , 10 , pmatch , 0 ) ;
|
||||
//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 endian ;
|
||||
int mat_size ;
|
||||
int type , size ;
|
||||
int type, size = 0;
|
||||
int mat_type ;
|
||||
int my_byte_order ;
|
||||
div_t div_result ;
|
||||
|
@ -329,7 +329,6 @@ int LogData::countNumBinaryFiles(char *pathToBinaryData)
|
||||
fprintf(stderr, "Couldn't open \"%s\" for reading. \n",
|
||||
pathToBinaryData);
|
||||
fprintf(stderr, "Maybe LogGroup Constructor not called.\n");
|
||||
closedir(dirp);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
@ -1471,7 +1470,6 @@ int LogGroup::getHeaders()
|
||||
fprintf(stderr, "ERROR: Couldn't open \"%s\" for reading. \n",
|
||||
pathToBinaryData_);
|
||||
fprintf(stderr, "Maybe LogGroup constructer wasn't done. \n");
|
||||
closedir(dirp);
|
||||
exit(-1);
|
||||
}
|
||||
// Count num headers, and max file name length in RUN dir
|
||||
|
@ -86,8 +86,9 @@ int Trick::VariableServerThread::copy_sim_data() {
|
||||
curr_var->size = wcslen((wchar_t *)curr_var->address) * sizeof(wchar_t);
|
||||
}
|
||||
}
|
||||
|
||||
memcpy( curr_var->buffer_in , curr_var->address , curr_var->size ) ;
|
||||
if(curr_var->address != NULL) {
|
||||
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.
|
||||
|
@ -23,7 +23,7 @@
|
||||
int tc_init_mcast_client(TCDevice * 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.");
|
||||
return (-1);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ int tc_init_mcast_server(TCDevice * mcast_server_device)
|
||||
const unsigned int yes = 1;
|
||||
|
||||
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.");
|
||||
return (-1);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ int tc_init_udp_client(TCDevice * udp_client_device)
|
||||
memset(&sockin, 0 , sizeof(struct sockaddr_in)) ;
|
||||
|
||||
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.");
|
||||
return (-1);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ int tc_init_udp_server( /* RETURN: -- 0 for success */
|
||||
unsigned int yes = 1;
|
||||
|
||||
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.");
|
||||
return (-1);
|
||||
}
|
||||
|
@ -10,8 +10,6 @@ int tsm_disconnect(TSMDevice * shm_device)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = TSM_SUCCESS;
|
||||
|
||||
// if we had a read/write lock, destroy it first
|
||||
if (shm_device->rwlock_addr != NULL) {
|
||||
ret = pthread_rwlockattr_destroy(&shm_device->rwlattr);
|
||||
|
@ -11,8 +11,12 @@ bstNode *bstFind(void *info, BST * bst)
|
||||
{
|
||||
bstNode *current;
|
||||
|
||||
if (bst == NULL && info == NULL) {
|
||||
fprintf(stderr, "Queue is empty");
|
||||
if (bst == NULL) {
|
||||
fprintf(stderr, "bst is not allocated");
|
||||
return NULL;
|
||||
}
|
||||
if (info == NULL) {
|
||||
fprintf(stderr, "info is invalid pointer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -97,8 +101,12 @@ void *bstDelete(bstNode * node, BST * bst)
|
||||
bstNode **parentspointer;
|
||||
|
||||
|
||||
if (node == NULL && bst == NULL) {
|
||||
fprintf(stderr, "Queue is empty");
|
||||
if (bst == NULL) {
|
||||
fprintf(stderr, "bst is not allocated");
|
||||
return NULL;
|
||||
}
|
||||
if (node == NULL) {
|
||||
fprintf(stderr, "node is invalid pointer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -107,7 +115,7 @@ void *bstDelete(bstNode * node, BST * bst)
|
||||
return (node);
|
||||
}
|
||||
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)
|
||||
parentspointer = &(node->parent->left);
|
||||
else
|
||||
@ -201,12 +209,16 @@ bstNode *bstInsert(void *info, BST * bst)
|
||||
int done = 0;
|
||||
|
||||
|
||||
if (bst == NULL && info == NULL) {
|
||||
fprintf(stderr, "Queue is empty");
|
||||
if (bst == NULL) {
|
||||
fprintf(stderr, "bst is not allocated");
|
||||
return NULL;
|
||||
}
|
||||
if (info == NULL) {
|
||||
fprintf(stderr, "info is invalid pointer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!bst->init) {
|
||||
if (bst && !bst->init) {
|
||||
bstInit(bst);
|
||||
}
|
||||
newNode = (bstNode *) malloc(sizeof(bstNode)); /* allocate memory for the node */
|
||||
|
Loading…
x
Reference in New Issue
Block a user