[Openmp-commits] [openmp] r288054 - Cleanup: memory leaks on warnings printing fixed; some memory freeing cleaned; poor indents and one typo fixed.

Andrey Churbanov via Openmp-commits openmp-commits at lists.llvm.org
Mon Nov 28 11:23:10 PST 2016


Author: achurbanov
Date: Mon Nov 28 13:23:09 2016
New Revision: 288054

URL: http://llvm.org/viewvc/llvm-project?rev=288054&view=rev
Log:
Cleanup: memory leaks on warnings printing fixed; some memory freeing cleaned; poor indents and one typo fixed.

Patch by Victor Campos.

Differential Revision: https://reviews.llvm.org/D26786

Modified:
    openmp/trunk/runtime/src/kmp_environment.c
    openmp/trunk/runtime/src/kmp_i18n.c
    openmp/trunk/runtime/src/kmp_itt.c
    openmp/trunk/runtime/src/kmp_settings.c
    openmp/trunk/runtime/src/kmp_str.c
    openmp/trunk/runtime/src/z_Linux_util.c
    openmp/trunk/runtime/src/z_Windows_NT_util.c

Modified: openmp/trunk/runtime/src/kmp_environment.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_environment.c?rev=288054&r1=288053&r2=288054&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_environment.c (original)
+++ openmp/trunk/runtime/src/kmp_environment.c Mon Nov 28 13:23:09 2016
@@ -566,11 +566,10 @@ __kmp_env_blk_free(
 ) {
 
     KMP_INTERNAL_FREE( (void *) block->vars );
-    KMP_INTERNAL_FREE( (void *) block->bulk );
+    __kmp_str_free(&(block->bulk));
 
     block->count = 0;
     block->vars  = NULL;
-    block->bulk  = NULL;
 
 } // __kmp_env_blk_free
 

Modified: openmp/trunk/runtime/src/kmp_i18n.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_i18n.c?rev=288054&r1=288053&r2=288054&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_i18n.c (original)
+++ openmp/trunk/runtime/src/kmp_i18n.c Mon Nov 28 13:23:09 2016
@@ -109,13 +109,13 @@ __kmp_i18n_do_catopen(
     KMP_DEBUG_ASSERT( cat    == KMP_I18N_NULLCAT );
 
     english =
-	lang == NULL                       ||  // In all these cases English language is used.
-	strcmp( lang, "" )            == 0 ||
+        lang == NULL                       ||  // In all these cases English language is used.
+        strcmp( lang, "" )            == 0 ||
         strcmp( lang, " " )           == 0 ||
-              // Workaround for Fortran RTL bug DPD200137873 "Fortran runtime resets LANG env var
-              // to space if it is not set".
-	strcmp( lang, "C" )           == 0 ||
-	strcmp( lang, "POSIX" )       == 0;
+        // Workaround for Fortran RTL bug DPD200137873 "Fortran runtime resets LANG env var
+        // to space if it is not set".
+        strcmp( lang, "C" )           == 0 ||
+        strcmp( lang, "POSIX" )       == 0;
 
     if ( ! english ) {  // English language is not yet detected, let us continue.
         // Format of LANG is: [language[_territory][.codeset][@modifier]]
@@ -132,8 +132,8 @@ __kmp_i18n_do_catopen(
     // Do not try to open English catalog because internal messages are
     // exact copy of messages in English catalog.
     if ( english ) {
-	status = KMP_I18N_ABSENT;  // mark catalog as absent so it will not be re-opened.
-	return;
+        status = KMP_I18N_ABSENT;  // mark catalog as absent so it will not be re-opened.
+        return;
     }
 
     cat = catopen( name, 0 );
@@ -141,36 +141,41 @@ __kmp_i18n_do_catopen(
     status = ( cat == KMP_I18N_NULLCAT ? KMP_I18N_ABSENT : KMP_I18N_OPENED );
 
     if ( status == KMP_I18N_ABSENT ) {
-      if (__kmp_generate_warnings > kmp_warnings_low) { // AC: only issue warning in case explicitly asked to
-        int    error   = errno; // Save errno immediately.
-	char * nlspath = __kmp_env_get( "NLSPATH" );
-        char * lang    = __kmp_env_get( "LANG" );
-
-	// Infinite recursion will not occur -- status is KMP_I18N_ABSENT now, so
-	// __kmp_i18n_catgets() will not try to open catalog, but will return default message.
-	__kmp_msg(
-	    kmp_ms_warning,
-	    KMP_MSG( CantOpenMessageCatalog, name ),
-	    KMP_ERR( error ),
-	    KMP_HNT( CheckEnvVar, "NLSPATH", nlspath ),
-            KMP_HNT( CheckEnvVar, "LANG", lang ),
-	    __kmp_msg_null
-	);
-	KMP_INFORM( WillUseDefaultMessages );
-        KMP_INTERNAL_FREE( nlspath );
-        KMP_INTERNAL_FREE( lang );
-      }
+        if (__kmp_generate_warnings > kmp_warnings_low) { // AC: only issue warning in case explicitly asked to
+            int    error   = errno; // Save errno immediately.
+            char * nlspath = __kmp_env_get( "NLSPATH" );
+            char * lang    = __kmp_env_get( "LANG" );
+
+            // Infinite recursion will not occur -- status is KMP_I18N_ABSENT now, so
+            // __kmp_i18n_catgets() will not try to open catalog, but will return default message.
+            kmp_msg_t err_code = KMP_ERR( error );
+            __kmp_msg(
+                kmp_ms_warning,
+                KMP_MSG( CantOpenMessageCatalog, name ),
+                err_code,
+                KMP_HNT( CheckEnvVar, "NLSPATH", nlspath ),
+                KMP_HNT( CheckEnvVar, "LANG", lang ),
+                __kmp_msg_null
+            );
+            if (__kmp_generate_warnings == kmp_warnings_off) {
+                __kmp_str_free(&err_code.str);
+            }
+
+            KMP_INFORM( WillUseDefaultMessages );
+            KMP_INTERNAL_FREE( nlspath );
+            KMP_INTERNAL_FREE( lang );
+        }
     } else { // status == KMP_I18N_OPENED
 
         int section = get_section( kmp_i18n_prp_Version );
         int number  = get_number( kmp_i18n_prp_Version );
         char const * expected = __kmp_i18n_default_table.sect[ section ].str[ number ];
-            // Expected version of the catalog.
+        // Expected version of the catalog.
         kmp_str_buf_t version;   // Actual version of the catalog.
         __kmp_str_buf_init( & version );
         __kmp_str_buf_print( & version, "%s", catgets( cat, section, number, NULL ) );
 
-            // String returned by catgets is invalid after closing the catalog, so copy it.
+        // String returned by catgets is invalid after closing the catalog, so copy it.
         if ( strcmp( version.str, expected ) != 0 ) {
             __kmp_i18n_catclose();     // Close bad catalog.
             status = KMP_I18N_ABSENT;  // And mark it as absent.
@@ -317,7 +322,7 @@ kmp_i18n_table_free(
     table->size = 0;
     KMP_INTERNAL_FREE( (void *) table->sect );
     table->sect = NULL;
-} // kmp_i8n_table_free
+} // kmp_i18n_table_free
 
 
 void
@@ -325,7 +330,7 @@ __kmp_i18n_do_catopen(
 ) {
 
     LCID          locale_id = GetThreadLocale();
-    WORD 	  lang_id = LANGIDFROMLCID( locale_id );
+    WORD          lang_id = LANGIDFROMLCID( locale_id );
     WORD          primary_lang_id = PRIMARYLANGID( lang_id );
     kmp_str_buf_t path;
 
@@ -337,8 +342,8 @@ __kmp_i18n_do_catopen(
     // Do not try to open English catalog because internal messages are
     // exact copy of messages in English catalog.
     if ( primary_lang_id == LANG_ENGLISH ) {
-	status = KMP_I18N_ABSENT;  // mark catalog as absent so it will not be re-opened.
-	goto end;
+        status = KMP_I18N_ABSENT;  // mark catalog as absent so it will not be re-opened.
+        goto end;
     }; // if
 
     // Construct resource DLL name.
@@ -395,30 +400,35 @@ __kmp_i18n_do_catopen(
 
     if ( status == KMP_I18N_ABSENT ) {
       if (__kmp_generate_warnings > kmp_warnings_low) { // AC: only issue warning in case explicitly asked to
-	DWORD error = GetLastError();
-	// Infinite recursion will not occur -- status is KMP_I18N_ABSENT now, so
-	// __kmp_i18n_catgets() will not try to open catalog but will return default message.
+        DWORD error = GetLastError();
+        // Infinite recursion will not occur -- status is KMP_I18N_ABSENT now, so
+        // __kmp_i18n_catgets() will not try to open catalog but will return default message.
         /*
-         If message catalog for another architecture found (e.g. OpenMP RTL
-	 for IA-32 architecture opens libompui.dll for Intel(R) 64)
-	 Windows* OS returns error 193 (ERROR_BAD_EXE_FORMAT). However,
-         FormatMessage fails to return a message for this error, so user
-	 will see:
-
-         OMP: Warning #2: Cannot open message catalog "1041\libompui.dll":
-         OMP: System error #193: (No system error message available)
-         OMP: Info #3: Default messages will be used.
+          If message catalog for another architecture found (e.g. OpenMP RTL
+          for IA-32 architecture opens libompui.dll for Intel(R) 64)
+          Windows* OS returns error 193 (ERROR_BAD_EXE_FORMAT). However,
+          FormatMessage fails to return a message for this error, so user
+          will see:
+
+          OMP: Warning #2: Cannot open message catalog "1041\libompui.dll":
+          OMP: System error #193: (No system error message available)
+          OMP: Info #3: Default messages will be used.
 
-         Issue a hint in this case to let cause of trouble more understandable.
+          Issue a hint in this case to let cause of trouble more understandable.
         */
-	__kmp_msg(
-	    kmp_ms_warning,
-	    KMP_MSG( CantOpenMessageCatalog, path.str ),
-	    KMP_SYSERRCODE( error ),
+        __kmp_msg_t err_code = KMP_SYSERRCODE(error);
+        __kmp_msg(
+            kmp_ms_warning,
+            KMP_MSG( CantOpenMessageCatalog, path.str ),
+            err_code,
             ( error == ERROR_BAD_EXE_FORMAT ? KMP_HNT( BadExeFormat, path.str, KMP_ARCH_STR ) : __kmp_msg_null ),
-	    __kmp_msg_null
-	);
-	KMP_INFORM( WillUseDefaultMessages );
+            __kmp_msg_null
+        );
+        if (__kmp_generate_warnings == kmp_warnings_off) {
+            __kmp_str_free(&err_code.str);
+        }
+
+        KMP_INFORM( WillUseDefaultMessages );
       }
     } else { // status == KMP_I18N_OPENED
 
@@ -824,7 +834,6 @@ sys_error(
             // XSI version of strerror_r.
 
             int    size   = 2048;
-            // TODO: Add checking result of malloc().
             char * buffer = (char *) KMP_INTERNAL_MALLOC( size );
             int    rc;
             if (buffer == NULL) {
@@ -932,9 +941,9 @@ __kmp_msg(
         };
     }; // switch
     fmsg = __kmp_msg_format( format, message.num, message.str );
-    KMP_INTERNAL_FREE( (void *) message.str );
+    __kmp_str_free(&message.str);
     __kmp_str_buf_cat( & buffer, fmsg.str, fmsg.len );
-    KMP_INTERNAL_FREE( (void *) fmsg.str );
+    __kmp_str_free(&fmsg.str);
 
     // Format other messages.
     va_start( args, message );
@@ -958,9 +967,9 @@ __kmp_msg(
             };
         }; // switch
         fmsg = __kmp_msg_format( format, message.num, message.str );
-        KMP_INTERNAL_FREE( (void *) message.str );
+        __kmp_str_free(&message.str);
         __kmp_str_buf_cat( & buffer, fmsg.str, fmsg.len );
-        KMP_INTERNAL_FREE( (void *) fmsg.str );
+        __kmp_str_free(&fmsg.str);
     }; // forever
     va_end( args );
 

Modified: openmp/trunk/runtime/src/kmp_itt.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_itt.c?rev=288054&r1=288053&r2=288054&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_itt.c (original)
+++ openmp/trunk/runtime/src/kmp_itt.c Mon Nov 28 13:23:09 2016
@@ -103,13 +103,21 @@ __itt_error_handler(
     switch ( err ) {
         case __itt_error_no_module : {
             char const * library = va_arg( args, char const * );
-            #if KMP_OS_WINDOWS
-                int sys_err = va_arg( args, int );
-                __kmp_msg( kmp_ms_warning, KMP_MSG( IttLoadLibFailed, library ), KMP_SYSERRCODE( sys_err ), __kmp_msg_null );
-            #else
-                char const * sys_err = va_arg( args, char const * );
-                __kmp_msg( kmp_ms_warning, KMP_MSG( IttLoadLibFailed, library ), KMP_SYSERRMESG( sys_err ), __kmp_msg_null );
-            #endif
+#if KMP_OS_WINDOWS
+            int sys_err = va_arg( args, int );
+            kmp_msg_t err_code = KMP_SYSERRCODE( sys_err );
+            __kmp_msg( kmp_ms_warning, KMP_MSG( IttLoadLibFailed, library ), err_code, __kmp_msg_null );
+            if (__kmp_generate_warnings == kmp_warnings_off) {
+              __kmp_str_free(&err_code.str);
+            }
+#else
+            char const * sys_err = va_arg( args, char const * );
+            kmp_msg_t err_code = KMP_SYSERRMESG( sys_err );
+            __kmp_msg( kmp_ms_warning, KMP_MSG( IttLoadLibFailed, library ), err_code, __kmp_msg_null );
+            if (__kmp_generate_warnings == kmp_warnings_off) {
+              __kmp_str_free(&err_code.str);
+            }
+#endif
         } break;
         case __itt_error_no_symbol : {
             char const * library = va_arg( args, char const * );
@@ -130,12 +138,20 @@ __itt_error_handler(
         case __itt_error_cant_read_env : {
             char const * var     = va_arg( args, char const * );
             int          sys_err = va_arg( args, int );
-            __kmp_msg( kmp_ms_warning, KMP_MSG( CantGetEnvVar, var ), KMP_ERR( sys_err ), __kmp_msg_null );
+            kmp_msg_t err_code = KMP_ERR( sys_err );
+            __kmp_msg( kmp_ms_warning, KMP_MSG( CantGetEnvVar, var ), err_code, __kmp_msg_null );
+            if (__kmp_generate_warnings == kmp_warnings_off) {
+              __kmp_str_free(&err_code.str);
+            }
         } break;
         case __itt_error_system : {
             char const * func    = va_arg( args, char const * );
             int          sys_err = va_arg( args, int );
-            __kmp_msg( kmp_ms_warning, KMP_MSG( IttFunctionError, func ), KMP_SYSERRCODE( sys_err ), __kmp_msg_null );
+            kmp_msg_t err_code = KMP_SYSERRCODE( sys_err );
+            __kmp_msg( kmp_ms_warning, KMP_MSG( IttFunctionError, func ), err_code, __kmp_msg_null );
+            if (__kmp_generate_warnings == kmp_warnings_off) {
+              __kmp_str_free(&err_code.str);
+            }
         } break;
         default : {
             KMP_WARNING( IttUnknownError, err );

Modified: openmp/trunk/runtime/src/kmp_settings.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_settings.c?rev=288054&r1=288053&r2=288054&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_settings.c (original)
+++ openmp/trunk/runtime/src/kmp_settings.c Mon Nov 28 13:23:09 2016
@@ -360,7 +360,7 @@ __kmp_stg_parse_str(
     char const *      value,
     char const * *    out
 ) {
-    KMP_INTERNAL_FREE( (void *) * out );
+    __kmp_str_free(out);
     * out = __kmp_str_format( "%s", value );
 } // __kmp_stg_parse_str
 #endif
@@ -418,12 +418,12 @@ __kmp_stg_parse_file(
     char buffer[256];
     char *t;
     int hasSuffix;
-    KMP_INTERNAL_FREE( (void *) * out );
+    __kmp_str_free(out);
     t = (char *) strrchr(value, '.');
     hasSuffix = t && __kmp_str_eqf( t, suffix );
     t = __kmp_str_format( "%s%s", value, hasSuffix ? "" : suffix );
     __kmp_expand_file_name( buffer, sizeof(buffer), t);
-    KMP_INTERNAL_FREE(t);
+    __kmp_str_free(&t);
     * out = __kmp_str_format( "%s", buffer );
 } // __kmp_stg_parse_file
 #endif
@@ -2235,7 +2235,7 @@ __kmp_parse_affinity_env( char const * n
     #undef set_respect
     #undef set_granularity
 
-    KMP_INTERNAL_FREE( buffer );
+    __kmp_str_free((const char **) &buffer);
 
     if ( proclist ) {
         if ( ! type ) {

Modified: openmp/trunk/runtime/src/kmp_str.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_str.c?rev=288054&r1=288053&r2=288054&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_str.c (original)
+++ openmp/trunk/runtime/src/kmp_str.c Mon Nov 28 13:23:09 2016
@@ -420,8 +420,7 @@ __kmp_str_loc_free(
     kmp_str_loc_t * loc
 ) {
     __kmp_str_fname_free( & loc->fname );
-    KMP_INTERNAL_FREE( loc->_bulk );
-    loc->_bulk = NULL;
+    __kmp_str_free((const char **) &(loc->_bulk));
     loc->file  = NULL;
     loc->func  = NULL;
 } // kmp_str_loc_free
@@ -478,8 +477,6 @@ __kmp_str_eqf(         // True, if strin
     So standard malloc() is the only available option.
 */
 
-// TODO: Find and replace all regular free() with __kmp_str_free().
-
 char *
 __kmp_str_format(           // Allocated string.
     char const * format,    // Format string.

Modified: openmp/trunk/runtime/src/z_Linux_util.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/z_Linux_util.c?rev=288054&r1=288053&r2=288054&view=diff
==============================================================================
--- openmp/trunk/runtime/src/z_Linux_util.c (original)
+++ openmp/trunk/runtime/src/z_Linux_util.c Mon Nov 28 13:23:09 2016
@@ -165,12 +165,16 @@ __kmp_affinity_determine_capable(const c
           && (__kmp_affinity_type != affinity_default)
           && (__kmp_affinity_type != affinity_disabled))) {
             int error = errno;
+            kmp_msg_t err_code = KMP_ERR( error );
             __kmp_msg(
                 kmp_ms_warning,
                 KMP_MSG( GetAffSysCallNotSupported, env_var ),
-                KMP_ERR( error ),
+                err_code,
                 __kmp_msg_null
             );
+            if (__kmp_generate_warnings == kmp_warnings_off) {
+                __kmp_str_free(&err_code.str);
+            }
         }
         KMP_AFFINITY_DISABLE();
         KMP_INTERNAL_FREE(buf);
@@ -193,12 +197,16 @@ __kmp_affinity_determine_capable(const c
                   && (__kmp_affinity_type != affinity_default)
                   && (__kmp_affinity_type != affinity_disabled))) {
                     int error = errno;
+                    kmp_msg_t err_code = KMP_ERR( error );
                     __kmp_msg(
                         kmp_ms_warning,
                         KMP_MSG( SetAffSysCallNotSupported, env_var ),
-                        KMP_ERR( error ),
+                        err_code,
                         __kmp_msg_null
                     );
+                    if (__kmp_generate_warnings == kmp_warnings_off) {
+                        __kmp_str_free(&err_code.str);
+                    }
                 }
                 KMP_AFFINITY_DISABLE();
                 KMP_INTERNAL_FREE(buf);
@@ -241,12 +249,16 @@ __kmp_affinity_determine_capable(const c
                   && (__kmp_affinity_type != affinity_default)
                   && (__kmp_affinity_type != affinity_disabled))) {
                     int error = errno;
+                    kmp_msg_t err_code = KMP_ERR( error );
                     __kmp_msg(
                         kmp_ms_warning,
                         KMP_MSG( GetAffSysCallNotSupported, env_var ),
-                        KMP_ERR( error ),
+                        err_code,
                         __kmp_msg_null
                     );
+                    if (__kmp_generate_warnings == kmp_warnings_off) {
+                        __kmp_str_free(&err_code.str);
+                    }
                 }
                 KMP_AFFINITY_DISABLE();
                 KMP_INTERNAL_FREE(buf);
@@ -272,12 +284,16 @@ __kmp_affinity_determine_capable(const c
                   && (__kmp_affinity_type != affinity_default)
                   && (__kmp_affinity_type != affinity_disabled))) {
                     int error = errno;
+                    kmp_msg_t err_code = KMP_ERR( error );
                     __kmp_msg(
                         kmp_ms_warning,
                         KMP_MSG( SetAffSysCallNotSupported, env_var ),
-                        KMP_ERR( error ),
+                        err_code,
                         __kmp_msg_null
                     );
+                    if (__kmp_generate_warnings == kmp_warnings_off) {
+                        __kmp_str_free(&err_code.str);
+                    }
                 }
                 KMP_AFFINITY_DISABLE();
                 KMP_INTERNAL_FREE(buf);
@@ -710,13 +726,17 @@ __kmp_launch_monitor( void *thr )
                 rc = sched_setscheduler( 0, sched, & param );
                 if ( rc != 0 ) {
                     int error = errno;
-                  __kmp_msg(
-                      kmp_ms_warning,
-                      KMP_MSG( CantChangeMonitorPriority ),
-                      KMP_ERR( error ),
-                      KMP_MSG( MonitorWillStarve ),
-                      __kmp_msg_null
-                  );
+                    kmp_msg_t err_code = KMP_ERR( error );
+                    __kmp_msg(
+                        kmp_ms_warning,
+                        KMP_MSG( CantChangeMonitorPriority ),
+                        err_code,
+                        KMP_MSG( MonitorWillStarve ),
+                        __kmp_msg_null
+                    );
+                    if (__kmp_generate_warnings == kmp_warnings_off) {
+                        __kmp_str_free(&err_code.str);
+                    }
                 }; // if
             } else {
                 // We cannot abort here, because number of CPUs may be enough for all the threads,
@@ -959,7 +979,11 @@ __kmp_create_worker( int gtid, kmp_info_
 #ifdef KMP_THREAD_ATTR
     status = pthread_attr_destroy( & thread_attr );
     if ( status ) {
-        __kmp_msg(kmp_ms_warning, KMP_MSG( CantDestroyThreadAttrs ), KMP_ERR( status ), __kmp_msg_null);
+        kmp_msg_t err_code = KMP_ERR( status );
+        __kmp_msg(kmp_ms_warning, KMP_MSG( CantDestroyThreadAttrs ), err_code, __kmp_msg_null);
+        if (__kmp_generate_warnings == kmp_warnings_off) {
+            __kmp_str_free(&err_code.str);
+        }
     }; // if
 #endif /* KMP_THREAD_ATTR */
 
@@ -1055,13 +1079,17 @@ __kmp_create_monitor( kmp_info_t *th )
                 __kmp_monitor_stksize *= 2;
                 goto retry;
             }
+            kmp_msg_t err_code = KMP_ERR( status );
             __kmp_msg(
                 kmp_ms_warning,  // should this be fatal?  BB
                 KMP_MSG( CantSetMonitorStackSize, (long int) __kmp_monitor_stksize ),
-                KMP_ERR( status ),
+                err_code,
                 KMP_HNT( ChangeMonitorStackSize ),
                 __kmp_msg_null
             );
+            if (__kmp_generate_warnings == kmp_warnings_off) {
+                __kmp_str_free(&err_code.str);
+            }
         }; // if
     #endif /* _POSIX_THREAD_ATTR_STACKSIZE */
 
@@ -1117,12 +1145,16 @@ __kmp_create_monitor( kmp_info_t *th )
     #ifdef KMP_THREAD_ATTR
         status = pthread_attr_destroy( & thread_attr );
         if ( status != 0 ) {
-            __kmp_msg(    //
+            kmp_msg_t err_code = KMP_ERR( status );
+            __kmp_msg( 
                 kmp_ms_warning,
                 KMP_MSG( CantDestroyThreadAttrs ),
-                KMP_ERR( status ),
+                err_code,
                 __kmp_msg_null
             );
+            if (__kmp_generate_warnings == kmp_warnings_off) {
+                __kmp_str_free(&err_code.str);
+            }
         }; // if
     #endif
 

Modified: openmp/trunk/runtime/src/z_Windows_NT_util.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/z_Windows_NT_util.c?rev=288054&r1=288053&r2=288054&view=diff
==============================================================================
--- openmp/trunk/runtime/src/z_Windows_NT_util.c (original)
+++ openmp/trunk/runtime/src/z_Windows_NT_util.c Mon Nov 28 13:23:09 2016
@@ -560,12 +560,16 @@ __kmp_affinity_bind_thread( int proc )
         if (__kmp_SetThreadGroupAffinity(GetCurrentThread(), &ga, NULL) == 0) {
             DWORD error = GetLastError();
             if (__kmp_affinity_verbose) { // AC: continue silently if not verbose
+                kmp_msg_t err_code = KMP_ERR( error );
                 __kmp_msg(
                     kmp_ms_warning,
                     KMP_MSG( CantSetThreadAffMask ),
-                    KMP_ERR( error ),
+                    err_code,
                     __kmp_msg_null
                 );
+                if (__kmp_generate_warnings == kmp_warnings_off) {
+                    __kmp_str_free(&err_code.str);
+                }
             }
         }
     } else {




More information about the Openmp-commits mailing list