1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

ttsnoop: resolve coverity 176047, 176046, 176044, 176043, 176042 and 176040

This commit is contained in:
Jon Trulson 2018-07-05 13:42:36 -06:00
parent e91f12cc54
commit 16ee3d1be5
3 changed files with 12 additions and 14 deletions

View file

@ -466,8 +466,7 @@ DtTtSetLabel(
Tt_status status = tt_ptr_error( val ); Tt_status status = tt_ptr_error( val );
std::ostringstream errStream; std::ostringstream errStream;
errStream << func << " = " << val << " (" << status << ")" << ends; errStream << func << " = " << val << " (" << status << ")" << ends;
const char *label = errStream.str().c_str(); DtTtSetLabel( labelWidget, errStream.str().c_str() );
DtTtSetLabel( labelWidget, label );
return status; return status;
} }
@ -480,8 +479,7 @@ DtTtSetLabel(
{ {
std::ostringstream errStream; std::ostringstream errStream;
errStream << func << " = " << status << ends; errStream << func << " = " << status << ends;
const char *label = errStream.str().c_str(); DtTtSetLabel( labelWidget, errStream.str().c_str() );
DtTtSetLabel( labelWidget, label );
return status; return status;
} }
@ -494,8 +492,8 @@ DtTtSetLabel(
{ {
std::ostringstream errStream; std::ostringstream errStream;
errStream << func << " = " << returnVal << ends; errStream << func << " = " << returnVal << ends;
const char *label = errStream.str().c_str(); DtTtSetLabel( labelWidget,
DtTtSetLabel( labelWidget, label ); const_cast<char *>(errStream.str().c_str()) );
return returnVal; return returnVal;
} }
@ -521,8 +519,8 @@ _DtTtChoices(
tt_free( name ); tt_free( name );
} }
itemStream << ends; itemStream << ends;
char *string = const_cast<char *>(itemStream.str().c_str()); items[ i ] =
items[ i ] = XmStringCreateLocalized( string ); XmStringCreateLocalized(const_cast<char *>(itemStream.str().c_str()));
} }
return items; return items;
} }
@ -571,8 +569,8 @@ _DtTtChoices(
tt_free( id ); tt_free( id );
} }
itemStream << ends; itemStream << ends;
char *string = const_cast<char *>(itemStream.str().c_str()); items[ i ] =
items[ i ] = XmStringCreateLocalized( string ); XmStringCreateLocalized(const_cast<char *>(itemStream.str().c_str()));
} }
return items; return items;
case DTTT_PATTERN: case DTTT_PATTERN:

View file

@ -89,7 +89,7 @@ char * snoopFile = 0;
Boolean unlinkSnoopFile = True; Boolean unlinkSnoopFile = True;
char * traceFile = 0; char * traceFile = 0;
Boolean unlinkTraceFile = True; Boolean unlinkTraceFile = True;
const char * traceScript = 0; std::string traceScript;
int globalTimeout = 20000; int globalTimeout = 20000;
unsigned int globalSaveLines = 5000; unsigned int globalSaveLines = 5000;
const char * globalVersionString = "1.0"; const char * globalVersionString = "1.0";
@ -667,7 +667,7 @@ main(int argc, char **argv)
std::ostringstream envStr; std::ostringstream envStr;
envStr << "TT_TRACE_SCRIPT=> "; envStr << "TT_TRACE_SCRIPT=> ";
envStr << traceFile << ends; envStr << traceFile << ends;
traceScript = envStr.str().c_str(); traceScript = envStr.str();
if (optImmediateTracing) { if (optImmediateTracing) {
turnOnTracing( 0, 0, 0 ); turnOnTracing( 0, 0, 0 );
} }

View file

@ -47,7 +47,7 @@ extern "C" { const char *_tt_lib_version; };
extern std::ofstream snoopStream; extern std::ofstream snoopStream;
extern unsigned int globalSaveLines; extern unsigned int globalSaveLines;
extern char * traceScript; extern std::string traceScript;
extern const char * globalVersionString; extern const char * globalVersionString;
extern Tt_pattern snoopPat; extern Tt_pattern snoopPat;
extern Boolean snoopPatIsRegistered; extern Boolean snoopPatIsRegistered;
@ -118,7 +118,7 @@ turnOnTracing(
DtTtSetLabel( instance->cancelButton, "Stop" ); DtTtSetLabel( instance->cancelButton, "Stop" );
XtManageChild(instance->tracer_shellform); XtManageChild(instance->tracer_shellform);
tt_trace_control( 0 ); tt_trace_control( 0 );
putenv( traceScript ); putenv( const_cast<char *>(traceScript.c_str()) );
tt_trace_control( 1 ); tt_trace_control( 1 );
/*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/ /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
} }