From: Jon Trulson Date: Thu, 5 Jul 2018 19:42:36 +0000 (-0600) Subject: ttsnoop: resolve coverity 176047, 176046, 176044, 176043, 176042 and 176040 X-Git-Tag: 2.3.0a~152 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=16ee3d1be574129b84d3b14a3be873324ee6e106;p=oweals%2Fcde.git ttsnoop: resolve coverity 176047, 176046, 176044, 176043, 176042 and 176040 --- diff --git a/cde/programs/ttsnoop/DtTt.C b/cde/programs/ttsnoop/DtTt.C index 24d97707..ffd208fa 100644 --- a/cde/programs/ttsnoop/DtTt.C +++ b/cde/programs/ttsnoop/DtTt.C @@ -466,8 +466,7 @@ DtTtSetLabel( Tt_status status = tt_ptr_error( val ); std::ostringstream errStream; errStream << func << " = " << val << " (" << status << ")" << ends; - const char *label = errStream.str().c_str(); - DtTtSetLabel( labelWidget, label ); + DtTtSetLabel( labelWidget, errStream.str().c_str() ); return status; } @@ -480,8 +479,7 @@ DtTtSetLabel( { std::ostringstream errStream; errStream << func << " = " << status << ends; - const char *label = errStream.str().c_str(); - DtTtSetLabel( labelWidget, label ); + DtTtSetLabel( labelWidget, errStream.str().c_str() ); return status; } @@ -494,8 +492,8 @@ DtTtSetLabel( { std::ostringstream errStream; errStream << func << " = " << returnVal << ends; - const char *label = errStream.str().c_str(); - DtTtSetLabel( labelWidget, label ); + DtTtSetLabel( labelWidget, + const_cast(errStream.str().c_str()) ); return returnVal; } @@ -521,8 +519,8 @@ _DtTtChoices( tt_free( name ); } itemStream << ends; - char *string = const_cast(itemStream.str().c_str()); - items[ i ] = XmStringCreateLocalized( string ); + items[ i ] = + XmStringCreateLocalized(const_cast(itemStream.str().c_str())); } return items; } @@ -571,8 +569,8 @@ _DtTtChoices( tt_free( id ); } itemStream << ends; - char *string = const_cast(itemStream.str().c_str()); - items[ i ] = XmStringCreateLocalized( string ); + items[ i ] = + XmStringCreateLocalized(const_cast(itemStream.str().c_str())); } return items; case DTTT_PATTERN: diff --git a/cde/programs/ttsnoop/ttsnoop.C.src b/cde/programs/ttsnoop/ttsnoop.C.src index 5deb6fd8..e80312aa 100644 --- a/cde/programs/ttsnoop/ttsnoop.C.src +++ b/cde/programs/ttsnoop/ttsnoop.C.src @@ -89,7 +89,7 @@ char * snoopFile = 0; Boolean unlinkSnoopFile = True; char * traceFile = 0; Boolean unlinkTraceFile = True; -const char * traceScript = 0; +std::string traceScript; int globalTimeout = 20000; unsigned int globalSaveLines = 5000; const char * globalVersionString = "1.0"; @@ -667,7 +667,7 @@ main(int argc, char **argv) std::ostringstream envStr; envStr << "TT_TRACE_SCRIPT=> "; envStr << traceFile << ends; - traceScript = envStr.str().c_str(); + traceScript = envStr.str(); if (optImmediateTracing) { turnOnTracing( 0, 0, 0 ); } diff --git a/cde/programs/ttsnoop/ttsnoop_stubs.C.src b/cde/programs/ttsnoop/ttsnoop_stubs.C.src index f57104a4..0ee8414a 100644 --- a/cde/programs/ttsnoop/ttsnoop_stubs.C.src +++ b/cde/programs/ttsnoop/ttsnoop_stubs.C.src @@ -47,7 +47,7 @@ extern "C" { const char *_tt_lib_version; }; extern std::ofstream snoopStream; extern unsigned int globalSaveLines; -extern char * traceScript; +extern std::string traceScript; extern const char * globalVersionString; extern Tt_pattern snoopPat; extern Boolean snoopPatIsRegistered; @@ -118,7 +118,7 @@ turnOnTracing( DtTtSetLabel( instance->cancelButton, "Stop" ); XtManageChild(instance->tracer_shellform); tt_trace_control( 0 ); - putenv( traceScript ); + putenv( const_cast(traceScript.c_str()) ); tt_trace_control( 1 ); /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/ }