diff options
-rw-r--r-- | src/dlfcn.c | 20 | ||||
-rw-r--r-- | tests/test.c | 8 |
2 files changed, 14 insertions, 14 deletions
diff --git a/src/dlfcn.c b/src/dlfcn.c index abbd58d..9620692 100644 --- a/src/dlfcn.c +++ b/src/dlfcn.c | |||
@@ -38,11 +38,11 @@ | |||
38 | 38 | ||
39 | #ifdef _MSC_VER | 39 | #ifdef _MSC_VER |
40 | /* https://docs.microsoft.com/en-us/cpp/intrinsics/returnaddress */ | 40 | /* https://docs.microsoft.com/en-us/cpp/intrinsics/returnaddress */ |
41 | #pragma intrinsic(_ReturnAddress) | 41 | #pragma intrinsic( _ReturnAddress ) |
42 | #else | 42 | #else |
43 | /* https://gcc.gnu.org/onlinedocs/gcc/Return-Address.html */ | 43 | /* https://gcc.gnu.org/onlinedocs/gcc/Return-Address.html */ |
44 | #ifndef _ReturnAddress | 44 | #ifndef _ReturnAddress |
45 | #define _ReturnAddress() (__builtin_extract_return_addr(__builtin_return_address(0))) | 45 | #define _ReturnAddress( ) ( __builtin_extract_return_addr( __builtin_return_address( 0 ) ) ) |
46 | #endif | 46 | #endif |
47 | #endif | 47 | #endif |
48 | 48 | ||
@@ -90,12 +90,12 @@ static BOOL local_add( HMODULE hModule ) | |||
90 | pobject = local_search( hModule ); | 90 | pobject = local_search( hModule ); |
91 | 91 | ||
92 | /* Do not add object again if it's already on the list */ | 92 | /* Do not add object again if it's already on the list */ |
93 | if( pobject ) | 93 | if( pobject != NULL ) |
94 | return TRUE; | 94 | return TRUE; |
95 | 95 | ||
96 | for( pobject = &first_object; pobject->next; pobject = pobject->next ); | 96 | for( pobject = &first_object; pobject->next; pobject = pobject->next ); |
97 | 97 | ||
98 | nobject = (local_object*) malloc( sizeof( local_object ) ); | 98 | nobject = (local_object *) malloc( sizeof( local_object ) ); |
99 | 99 | ||
100 | if( !nobject ) | 100 | if( !nobject ) |
101 | { | 101 | { |
@@ -120,7 +120,7 @@ static void local_rem( HMODULE hModule ) | |||
120 | 120 | ||
121 | pobject = local_search( hModule ); | 121 | pobject = local_search( hModule ); |
122 | 122 | ||
123 | if( !pobject ) | 123 | if( pobject == NULL ) |
124 | return; | 124 | return; |
125 | 125 | ||
126 | if( pobject->next ) | 126 | if( pobject->next ) |
@@ -159,7 +159,7 @@ static void save_err_str( const char *str ) | |||
159 | */ | 159 | */ |
160 | pos = 0; | 160 | pos = 0; |
161 | error_buffer[pos++] = '"'; | 161 | error_buffer[pos++] = '"'; |
162 | memcpy( error_buffer+pos, str, len ); | 162 | memcpy( error_buffer + pos, str, len ); |
163 | pos += len; | 163 | pos += len; |
164 | error_buffer[pos++] = '"'; | 164 | error_buffer[pos++] = '"'; |
165 | error_buffer[pos++] = ':'; | 165 | error_buffer[pos++] = ':'; |
@@ -167,7 +167,7 @@ static void save_err_str( const char *str ) | |||
167 | 167 | ||
168 | ret = FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwMessageId, | 168 | ret = FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwMessageId, |
169 | MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), | 169 | MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), |
170 | error_buffer+pos, (DWORD) (sizeof(error_buffer)-pos), NULL ); | 170 | error_buffer + pos, (DWORD) ( sizeof( error_buffer ) - pos ), NULL ); |
171 | pos += ret; | 171 | pos += ret; |
172 | 172 | ||
173 | /* When FormatMessageA() fails it returns zero and does not touch buffer | 173 | /* When FormatMessageA() fails it returns zero and does not touch buffer |
@@ -197,7 +197,7 @@ static void save_err_ptr_str( const void *ptr ) | |||
197 | for( i = 0; i < 2 * sizeof( ptr ); i++ ) | 197 | for( i = 0; i < 2 * sizeof( ptr ); i++ ) |
198 | { | 198 | { |
199 | num = ( ( (ULONG_PTR) ptr ) >> ( 8 * sizeof( ptr ) - 4 * ( i + 1 ) ) ) & 0xF; | 199 | num = ( ( (ULONG_PTR) ptr ) >> ( 8 * sizeof( ptr ) - 4 * ( i + 1 ) ) ) & 0xF; |
200 | ptr_buf[2+i] = num + ( ( num < 0xA ) ? '0' : ( 'A' - 0xA ) ); | 200 | ptr_buf[2 + i] = num + ( ( num < 0xA ) ? '0' : ( 'A' - 0xA ) ); |
201 | } | 201 | } |
202 | 202 | ||
203 | ptr_buf[2 + 2 * sizeof( ptr )] = 0; | 203 | ptr_buf[2 + 2 * sizeof( ptr )] = 0; |
@@ -234,9 +234,9 @@ void *dlopen( const char *file, int mode ) | |||
234 | /* Do not let Windows display the critical-error-handler message box */ | 234 | /* Do not let Windows display the critical-error-handler message box */ |
235 | uMode = SetErrorMode( SEM_FAILCRITICALERRORS ); | 235 | uMode = SetErrorMode( SEM_FAILCRITICALERRORS ); |
236 | 236 | ||
237 | if( file == 0 ) | 237 | if( file == NULL ) |
238 | { | 238 | { |
239 | /* POSIX says that if the value of file is 0, a handle on a global | 239 | /* POSIX says that if the value of file is NULL, a handle on a global |
240 | * symbol object must be provided. That object must be able to access | 240 | * symbol object must be provided. That object must be able to access |
241 | * all symbols from the original program file, and any objects loaded | 241 | * all symbols from the original program file, and any objects loaded |
242 | * with the RTLD_GLOBAL flag. | 242 | * with the RTLD_GLOBAL flag. |
diff --git a/tests/test.c b/tests/test.c index 132ede6..1d0d437 100644 --- a/tests/test.c +++ b/tests/test.c | |||
@@ -342,7 +342,7 @@ int main() | |||
342 | *(void **) (&fwrite_local) = dlsym( global, "fwrite" ); | 342 | *(void **) (&fwrite_local) = dlsym( global, "fwrite" ); |
343 | if (!fwrite_local) | 343 | if (!fwrite_local) |
344 | { | 344 | { |
345 | error = dlerror(); | 345 | error = dlerror( ); |
346 | printf("ERROR\tCould not get symbol from global handle: %s\n", | 346 | printf("ERROR\tCould not get symbol from global handle: %s\n", |
347 | error ? error : ""); | 347 | error ? error : ""); |
348 | CLOSE_LIB; | 348 | CLOSE_LIB; |
@@ -360,7 +360,7 @@ int main() | |||
360 | *(void **) (&fputs_default) = dlsym( RTLD_DEFAULT, "fputs" ); | 360 | *(void **) (&fputs_default) = dlsym( RTLD_DEFAULT, "fputs" ); |
361 | if (!fputs_default) | 361 | if (!fputs_default) |
362 | { | 362 | { |
363 | error = dlerror(); | 363 | error = dlerror( ); |
364 | printf("ERROR\tCould not get symbol from default handle: %s\n", | 364 | printf("ERROR\tCould not get symbol from default handle: %s\n", |
365 | error ? error : ""); | 365 | error ? error : ""); |
366 | CLOSE_LIB; | 366 | CLOSE_LIB; |
@@ -623,7 +623,7 @@ int main() | |||
623 | *(void **) (&function) = dlsym( global, "fwrite" ); | 623 | *(void **) (&function) = dlsym( global, "fwrite" ); |
624 | if (!function) | 624 | if (!function) |
625 | { | 625 | { |
626 | error = dlerror(); | 626 | error = dlerror( ); |
627 | printf("ERROR\tCould not get symbol from global handle: %s\n", | 627 | printf("ERROR\tCould not get symbol from global handle: %s\n", |
628 | error ? error : ""); | 628 | error ? error : ""); |
629 | CLOSE_LIB; | 629 | CLOSE_LIB; |
@@ -659,7 +659,7 @@ int main() | |||
659 | *(void **) (&function) = dlsym( global, "function3" ); | 659 | *(void **) (&function) = dlsym( global, "function3" ); |
660 | if (!function) | 660 | if (!function) |
661 | { | 661 | { |
662 | error = dlerror(); | 662 | error = dlerror( ); |
663 | printf("ERROR\tCould not get symbol from global handle: %s\n", | 663 | printf("ERROR\tCould not get symbol from global handle: %s\n", |
664 | error ? error : ""); | 664 | error ? error : ""); |
665 | CLOSE_LIB; | 665 | CLOSE_LIB; |