From af2575da5b0cb59c68083474b20da91ca42b1b37 Mon Sep 17 00:00:00 2001 From: Pappy Van Winkle Date: Thu, 11 Oct 2018 22:05:50 -0500 Subject: [PATCH 1/2] Remove all unused variables (style warning). --- .../SIM_satellite/models/Satellite/graphics/SatelliteModel.c | 2 -- trick_sims/SIM_satellite/models/Satellite/src/Satellite.cpp | 2 -- trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp | 3 --- trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp | 1 - .../data_products/DPX/APPS/GXPLOT/gp_view_curve_node.cpp | 1 - .../data_products/DPX/APPS/GXPLOT/gp_view_plot_node.cpp | 1 - trick_source/sim_services/DebugPause/DebugPause.cpp | 1 - .../sim_services/Executive/Executive_loop_multi_thread.cpp | 1 - trick_source/sim_services/InputProcessor/IPPython.cpp | 2 -- .../sim_services/MemoryManager/MemoryManager_add_attr_info.cpp | 2 -- .../sim_services/UdUnits/map_trick_units_to_udunits.cpp | 1 - trick_source/trick_utils/comm/test_programs/dr_client.c | 2 -- 12 files changed, 19 deletions(-) diff --git a/trick_sims/SIM_satellite/models/Satellite/graphics/SatelliteModel.c b/trick_sims/SIM_satellite/models/Satellite/graphics/SatelliteModel.c index 6be46e4c..1ad7eda0 100644 --- a/trick_sims/SIM_satellite/models/Satellite/graphics/SatelliteModel.c +++ b/trick_sims/SIM_satellite/models/Satellite/graphics/SatelliteModel.c @@ -35,8 +35,6 @@ GLuint MakeTexture(GLubyte* data , int width, int height) { void Satellite_initialize(void) { - FILE fp; - capsuleTextureID = MakeTexture(Capsule_texture, CAPSULE_TEXTURE_WIDTH, CAPSULE_TEXTURE_HEIGHT); nozzleTextureID = MakeTexture(Nozzle_texture, NOZZLE_TEXTURE_WIDTH, NOZZLE_TEXTURE_HEIGHT); diff --git a/trick_sims/SIM_satellite/models/Satellite/src/Satellite.cpp b/trick_sims/SIM_satellite/models/Satellite/src/Satellite.cpp index 527293ca..751c2d5d 100644 --- a/trick_sims/SIM_satellite/models/Satellite/src/Satellite.cpp +++ b/trick_sims/SIM_satellite/models/Satellite/src/Satellite.cpp @@ -28,8 +28,6 @@ void Satellite::get_force_of_gravity ( double* gForceV) { void Satellite::get_Force_and_Torque() { double gforcev[3]; - double thruster_force[3]; - double thruster_torque[3]; // Zero force. for (int ii=0; ii<3; ii++) { force[ii] = 0.0; } diff --git a/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp b/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp index a3600ab7..553aa895 100644 --- a/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp +++ b/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp @@ -237,7 +237,6 @@ bool FieldVisitor::VisitFieldDecl( clang::FieldDecl *field ) { if ( !qt.isCanonical() ) { fdes->setNonCanonicalTypeName(qt.getAsString()) ; clang::QualType ct = qt.getCanonicalType() ; - std::string tst_string = ct.getAsString() ; if ( debug_level >= 3 ) { std::cout << "\033[33mFieldVisitor VisitFieldDecl: Processing canonical type\033[00m" << std::endl ; ct.dump() ; @@ -271,8 +270,6 @@ bool FieldVisitor::ProcessTemplate(std::string in_name , clang::CXXRecordDecl * return false ; } - size_t pos ; - // Check to see if we've processed this template before // If not we need to create attributes for this template if ( processed_templates.find(in_name) == processed_templates.end() ) { diff --git a/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp b/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp index 2249d175..8583c5be 100644 --- a/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp +++ b/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp @@ -383,7 +383,6 @@ void PrintAttributes::printIOMakefile() { std::ofstream io_link_list ; std::ofstream ICG_processed ; std::ofstream ext_lib ; - unsigned int ii ; // Don't create a makefile if we didn't process any files. if ( out_of_date_io_files.empty() ) { diff --git a/trick_source/data_products/DPX/APPS/GXPLOT/gp_view_curve_node.cpp b/trick_source/data_products/DPX/APPS/GXPLOT/gp_view_curve_node.cpp index 91521f85..f15cc6d2 100644 --- a/trick_source/data_products/DPX/APPS/GXPLOT/gp_view_curve_node.cpp +++ b/trick_source/data_products/DPX/APPS/GXPLOT/gp_view_curve_node.cpp @@ -42,7 +42,6 @@ GPViewCurveNode::GPViewCurveNode( Widget Toplevel, std::string curve_symbol_style; std::string curve_symbol_size; std::string tmp_string; - std::stringstream tmp_stream; toplevel = Toplevel; dpc_curve = Curve; diff --git a/trick_source/data_products/DPX/APPS/GXPLOT/gp_view_plot_node.cpp b/trick_source/data_products/DPX/APPS/GXPLOT/gp_view_plot_node.cpp index 2ab89e8b..5a84d332 100644 --- a/trick_source/data_products/DPX/APPS/GXPLOT/gp_view_plot_node.cpp +++ b/trick_source/data_products/DPX/APPS/GXPLOT/gp_view_plot_node.cpp @@ -95,7 +95,6 @@ void GPViewPlotNode::finalize() { std::string plot_data_src_label; std::string plot_title; std::string plot_x_label; - std::string plot_x_units; std::string plot_x_scale; std::string plot_x_min_rng; std::string plot_x_max_rng; diff --git a/trick_source/sim_services/DebugPause/DebugPause.cpp b/trick_source/sim_services/DebugPause/DebugPause.cpp index 21b00757..b95bcbd2 100644 --- a/trick_source/sim_services/DebugPause/DebugPause.cpp +++ b/trick_source/sim_services/DebugPause/DebugPause.cpp @@ -60,7 +60,6 @@ int Trick::DebugPause::debug_signal() { int Trick::DebugPause::debug_pause_on() { - std::map::iterator it ; std::stringstream sem_name_stream ; if ( debug_pause_flag == true ) { diff --git a/trick_source/sim_services/Executive/Executive_loop_multi_thread.cpp b/trick_source/sim_services/Executive/Executive_loop_multi_thread.cpp index 26cdc674..34e348c1 100644 --- a/trick_source/sim_services/Executive/Executive_loop_multi_thread.cpp +++ b/trick_source/sim_services/Executive/Executive_loop_multi_thread.cpp @@ -38,7 +38,6 @@ int Trick::Executive::loop_multi_thread() { JobData * depend_job ; unsigned int ii ; - std::stringstream error_message ; Trick::ScheduledJobQueue * main_sched_queue ; int ret = 0 ; diff --git a/trick_source/sim_services/InputProcessor/IPPython.cpp b/trick_source/sim_services/InputProcessor/IPPython.cpp index 96c3c9df..f940361f 100644 --- a/trick_source/sim_services/InputProcessor/IPPython.cpp +++ b/trick_source/sim_services/InputProcessor/IPPython.cpp @@ -79,8 +79,6 @@ int Trick::IPPython::init() { /** @par Detailed Design: */ FILE *input_fp ; - std::string shortcut ; - std::string verify_command ; int ret ; std::string error_message ; pthread_mutexattr_t m_attr ; diff --git a/trick_source/sim_services/MemoryManager/MemoryManager_add_attr_info.cpp b/trick_source/sim_services/MemoryManager/MemoryManager_add_attr_info.cpp index bd7e91f7..14692ca7 100644 --- a/trick_source/sim_services/MemoryManager/MemoryManager_add_attr_info.cpp +++ b/trick_source/sim_services/MemoryManager/MemoryManager_add_attr_info.cpp @@ -21,14 +21,12 @@ int Trick::MemoryManager::add_attr_info( const std::string & user_type_string , std::string sub_attr_init_name ; std::string size_func_name ; size_t spos ; - std::string::iterator pos ; ATTRIBUTES* sub_attr = NULL ; ENUM_ATTR* enum_attr = NULL ; void (*init_sub_attr)(void) = NULL ; size_t (*size_func)(void) = NULL ; unsigned int ii ; std::set::iterator it ; - std::map::iterator mit; /** @par Design Details: */ diff --git a/trick_source/sim_services/UdUnits/map_trick_units_to_udunits.cpp b/trick_source/sim_services/UdUnits/map_trick_units_to_udunits.cpp index 11869fc2..cddfd8c5 100644 --- a/trick_source/sim_services/UdUnits/map_trick_units_to_udunits.cpp +++ b/trick_source/sim_services/UdUnits/map_trick_units_to_udunits.cpp @@ -74,7 +74,6 @@ std::string map_trick_units_to_udunits( std::string orig_units ) { std::vector::iterator it ; tokenize_units(orig_units, tokens, "*/^()") ; for( it = tokens.begin() ; it != tokens.end() ; it++ ) { - std::string power ; char last_char = *((*it).rbegin()) ; // tokens can end in powers of 2 or 3 in the old system. // save the power if it is the last character diff --git a/trick_source/trick_utils/comm/test_programs/dr_client.c b/trick_source/trick_utils/comm/test_programs/dr_client.c index ff686b29..8ed307d2 100644 --- a/trick_source/trick_utils/comm/test_programs/dr_client.c +++ b/trick_source/trick_utils/comm/test_programs/dr_client.c @@ -34,9 +34,7 @@ void dump_data ( DataFiles* df, int main( int narg, char** args ) { DataFiles df ; - DataFiles headers ; TCDevice connection ; - int isAsciiData ; int ret ; char* file_name ; char* msg ; From 121fa8408118b8d56d8053453c3a3e92603e96bd Mon Sep 17 00:00:00 2001 From: Pappy Van Winkle Date: Thu, 11 Oct 2018 22:52:04 -0500 Subject: [PATCH 2/2] Use correct format specifiers. Used http://www.cplusplus.com/reference/cstdio/printf/ as a reference. --- trick_sims/SIM_sun/RUN_test/input.py | 2 +- .../models/Sun/src/sun_pred_fast_display.c | 6 +++--- .../Apps/trkConvert/CSV_Formatter.cpp | 4 ++-- .../DPX/APPS/GXPLOT/gp_utilities.cpp | 2 +- .../Executive_write_s_job_execution.cpp | 6 +++--- .../sim_services/FrameLog/FrameLog.cpp | 2 +- .../sim_services/InputProcessor/MTV.cpp | 18 +++++++++--------- .../sim_services/MonteCarlo/MonteVarFile.cpp | 2 +- .../VariableServerThread_commands.cpp | 2 +- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/trick_sims/SIM_sun/RUN_test/input.py b/trick_sims/SIM_sun/RUN_test/input.py index 49357d86..fe1e64ed 100644 --- a/trick_sims/SIM_sun/RUN_test/input.py +++ b/trick_sims/SIM_sun/RUN_test/input.py @@ -101,7 +101,7 @@ if (os.path.isfile(SunDisplay_path)) : os.system( SunDisplay_cmd); else : print('==================================================================================') - print('SunDisplay needs to be built. Please \"cd\" into models/Graphics and type \"make\".') + print('SunDisplay needs to be built. Please \"cd\" into models/graphics and type \"make\".') print('==================================================================================') trick.stop(86400.0) diff --git a/trick_sims/SIM_sun/models/Sun/src/sun_pred_fast_display.c b/trick_sims/SIM_sun/models/Sun/src/sun_pred_fast_display.c index f8cee704..66722386 100644 --- a/trick_sims/SIM_sun/models/Sun/src/sun_pred_fast_display.c +++ b/trick_sims/SIM_sun/models/Sun/src/sun_pred_fast_display.c @@ -60,12 +60,12 @@ int sun_pred_fast_display( // sprintf(tmp_s," %ls %.6f",S->label_JD, S->JD); // strcat(message,tmp_s); if ( S->label_Azimuth != NULL ) { - sprintf(tmp_s," %ls %.3f%lc",S->label_Azimuth, S->solar_azimuth, DEGREE_SIGN); + sprintf(tmp_s," %ls %.3f%d",S->label_Azimuth, S->solar_azimuth, DEGREE_SIGN); } else { - sprintf(tmp_s," AZIMUTH %.3f%lc", S->solar_azimuth, DEGREE_SIGN); + sprintf(tmp_s," AZIMUTH %.3f%d", S->solar_azimuth, DEGREE_SIGN); } strcat(message,tmp_s); - sprintf(tmp_s," %ls %.3f%lc",S->label_Elevation, S->solar_elevation, DEGREE_SIGN); + sprintf(tmp_s," %ls %.3f%d",S->label_Elevation, S->solar_elevation, DEGREE_SIGN); strcat(message,tmp_s); send_hs(stdout,"%s\n",message); diff --git a/trick_source/data_products/Apps/trkConvert/CSV_Formatter.cpp b/trick_source/data_products/Apps/trkConvert/CSV_Formatter.cpp index 62d2b237..573dc855 100644 --- a/trick_source/data_products/Apps/trkConvert/CSV_Formatter.cpp +++ b/trick_source/data_products/Apps/trkConvert/CSV_Formatter.cpp @@ -17,8 +17,8 @@ void CSV_Formatter::writeDatum(FILE* out_fp, int16_t datum) { fprintf(out_fp,"% void CSV_Formatter::writeDatum(FILE* out_fp, uint16_t datum) { fprintf(out_fp,"%u", datum); } void CSV_Formatter::writeDatum(FILE* out_fp, int32_t datum) { fprintf(out_fp,"%d", datum); } void CSV_Formatter::writeDatum(FILE* out_fp, uint32_t datum) { fprintf(out_fp,"%u", datum); } -void CSV_Formatter::writeDatum(FILE* out_fp, int64_t datum) { fprintf(out_fp,"%lld", datum); } -void CSV_Formatter::writeDatum(FILE* out_fp, uint64_t datum) { fprintf(out_fp,"%lld", datum); } +void CSV_Formatter::writeDatum(FILE* out_fp, int64_t datum) { fprintf(out_fp,"%ld", datum); } +void CSV_Formatter::writeDatum(FILE* out_fp, uint64_t datum) { fprintf(out_fp,"%lu", datum); } void CSV_Formatter::writeDatum(FILE* out_fp, float datum) { fprintf(out_fp,"%.7f", datum); } void CSV_Formatter::writeDatum(FILE* out_fp, double datum) { fprintf(out_fp,"%.15g", datum); } const char* CSV_Formatter::extension() { return ".csv"; }; diff --git a/trick_source/data_products/DPX/APPS/GXPLOT/gp_utilities.cpp b/trick_source/data_products/DPX/APPS/GXPLOT/gp_utilities.cpp index b6a7a065..2672115d 100644 --- a/trick_source/data_products/DPX/APPS/GXPLOT/gp_utilities.cpp +++ b/trick_source/data_products/DPX/APPS/GXPLOT/gp_utilities.cpp @@ -57,7 +57,7 @@ int filterPostScriptColor( const char *psName, GPViewPageNode* gp_view_page_node string next_lt ; string new_buf_ptr ; string line_color ; - int red , blue , green ; + unsigned int red , blue , green ; int number_of_plots = (int)gp_view_page_node->plot_node_list.size(); //! Populate buf with file content. diff --git a/trick_source/sim_services/Executive/Executive_write_s_job_execution.cpp b/trick_source/sim_services/Executive/Executive_write_s_job_execution.cpp index f6cd0428..79bcc9ee 100644 --- a/trick_source/sim_services/Executive/Executive_write_s_job_execution.cpp +++ b/trick_source/sim_services/Executive/Executive_write_s_job_execution.cpp @@ -76,7 +76,7 @@ int Trick::Executive::write_s_job_execution(FILE *fp) { fprintf(fp, "\n===================================================================================================\n") ; fprintf(fp, "Scheduled Loop:\n\n") ; for ( ii = 0 ; ii < threads.size() ; ii++ ) { - fprintf(fp, "Thread %d:\n", ii) ; + fprintf(fp, "Thread %u:\n", ii) ; threads[ii]->job_queue.write_sched_queue(fp) ; fprintf(fp, "\n") ; } @@ -87,7 +87,7 @@ int Trick::Executive::write_s_job_execution(FILE *fp) { fprintf(fp, "Thread 0:\n"); top_of_frame_queue.write_sched_queue(fp) ; for ( ii = 1 ; ii < threads.size() ; ii++ ) { - fprintf(fp, "Thread %d:\n", ii) ; + fprintf(fp, "Thread %u:\n", ii) ; threads[ii]->top_of_frame_queue.write_sched_queue(fp) ; fprintf(fp, "\n") ; } @@ -98,7 +98,7 @@ int Trick::Executive::write_s_job_execution(FILE *fp) { fprintf(fp, "Thread 0:\n"); end_of_frame_queue.write_sched_queue(fp) ; for ( ii = 1 ; ii < threads.size() ; ii++ ) { - fprintf(fp, "Thread %d:\n", ii) ; + fprintf(fp, "Thread %u:\n", ii) ; threads[ii]->end_of_frame_queue.write_sched_queue(fp) ; fprintf(fp, "\n") ; } diff --git a/trick_source/sim_services/FrameLog/FrameLog.cpp b/trick_source/sim_services/FrameLog/FrameLog.cpp index 7ff87b6c..7893ca1d 100644 --- a/trick_source/sim_services/FrameLog/FrameLog.cpp +++ b/trick_source/sim_services/FrameLog/FrameLog.cpp @@ -782,7 +782,7 @@ int Trick::FrameLog::create_DP_job_files() { fprintf(fpx, " \n"); for ( ii = 0 ; ii < 8 and (page_count * 8 + ii + 1) < drg_users.size() ; ii++ ) { fprintf(fpx, " \n"); - fprintf(fpx, " Child thread %d Frame Scheduled Jobs\n", (page_count * 8 + ii + 1)); + fprintf(fpx, " Child thread %u Frame Scheduled Jobs\n", (page_count * 8 + ii + 1)); fprintf(fpx, " s \n"); fprintf(fpx, " \n"); fprintf(fpx, " \n"); diff --git a/trick_source/sim_services/InputProcessor/MTV.cpp b/trick_source/sim_services/InputProcessor/MTV.cpp index 560ecfb0..e2767c64 100644 --- a/trick_source/sim_services/InputProcessor/MTV.cpp +++ b/trick_source/sim_services/InputProcessor/MTV.cpp @@ -100,28 +100,28 @@ int Trick::MTV::send_event_data() { int jj; for (ii=0; ii < mtv_count; ii++) { - sprintf(varname, "%s[%d][0].name", mtv_name,ii); + sprintf(varname, "%s[%u][0].name", mtv_name,ii); var_add(varname); - sprintf(varname, "%s[%d][0].active", mtv_name,ii); + sprintf(varname, "%s[%u][0].active", mtv_name,ii); var_add(varname); - sprintf(varname, "%s[%d][0].added", mtv_name,ii); + sprintf(varname, "%s[%u][0].added", mtv_name,ii); var_add(varname); - sprintf(varname, "%s[%d][0].condition_count", mtv_name,ii); + sprintf(varname, "%s[%u][0].condition_count", mtv_name,ii); var_add(varname); - sprintf(varname, "%s[%d][0].action_count", mtv_name,ii); + sprintf(varname, "%s[%u][0].action_count", mtv_name,ii); var_add(varname); - sprintf(varname, "%s[%d][0].before_after", mtv_name,ii); + sprintf(varname, "%s[%u][0].before_after", mtv_name,ii); var_add(varname); for (jj=0; jj< mtv_list[ii]->condition_count; jj++) { - sprintf(varname, "%s[%d][0].cond[%d].comment", mtv_name,ii,jj); + sprintf(varname, "%s[%u][0].cond[%d].comment", mtv_name,ii,jj); var_add(varname); } for (jj=0; jj< mtv_list[ii]->action_count; jj++) { - sprintf(varname, "%s[%d][0].act[%d].comment", mtv_name,ii,jj); + sprintf(varname, "%s[%u][0].act[%d].comment", mtv_name,ii,jj); var_add(varname); } if (mtv_list[ii]->get_before_after() > 0) { - sprintf(varname, "%s[%d][0].target_name", mtv_name,ii); + sprintf(varname, "%s[%u][0].target_name", mtv_name,ii); var_add(varname); } } diff --git a/trick_source/sim_services/MonteCarlo/MonteVarFile.cpp b/trick_source/sim_services/MonteCarlo/MonteVarFile.cpp index b763926e..660e32fd 100644 --- a/trick_source/sim_services/MonteCarlo/MonteVarFile.cpp +++ b/trick_source/sim_services/MonteCarlo/MonteVarFile.cpp @@ -72,7 +72,7 @@ std::string Trick::MonteVarFile::get_next_value() { // Verify the input column number is valid. if ((column == 0) || (column > ntokens)) { char string[100]; - sprintf(string, "Trick:MonteVarFile An invalid column number %d, valid column numbers are 1 - %d", column, ntokens); + sprintf(string, "Trick:MonteVarFile An invalid column number %u, valid column numbers are 1 - %u", column, ntokens); exec_terminate_with_return(-1, __FILE__, __LINE__, string); } diff --git a/trick_source/sim_services/VariableServer/VariableServerThread_commands.cpp b/trick_source/sim_services/VariableServer/VariableServerThread_commands.cpp index b2dfe0f1..cb182d86 100644 --- a/trick_source/sim_services/VariableServer/VariableServerThread_commands.cpp +++ b/trick_source/sim_services/VariableServer/VariableServerThread_commands.cpp @@ -424,7 +424,7 @@ int Trick::VariableServerThread::transmit_file(std::string sie_file) { fseek(fp , 0L, SEEK_END) ; file_size = ftell(fp) ; - sprintf(buffer, "%d\t%d\n" , VS_SIE_RESOURCE, file_size) ; + sprintf(buffer, "%d\t%u\n" , VS_SIE_RESOURCE, file_size) ; tc_write(&connection , buffer , strlen(buffer)) ; rewind(fp) ;