Fix some style issues
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
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 @@
#ifdef _MSC_VER
/* https://docs.microsoft.com/en-us/cpp/intrinsics/returnaddress */
-#pragma intrinsic(_ReturnAddress)
+#pragma intrinsic( _ReturnAddress )
#else
/* https://gcc.gnu.org/onlinedocs/gcc/Return-Address.html */
#ifndef _ReturnAddress
-#define _ReturnAddress() (__builtin_extract_return_addr(__builtin_return_address(0)))
+#define _ReturnAddress( ) ( __builtin_extract_return_addr( __builtin_return_address( 0 ) ) )
#endif
#endif
@@ -90,12 +90,12 @@ static BOOL local_add( HMODULE hModule )
pobject = local_search( hModule );
/* Do not add object again if it's already on the list */
- if( pobject )
+ if( pobject != NULL )
return TRUE;
for( pobject = &first_object; pobject->next; pobject = pobject->next );
- nobject = (local_object*) malloc( sizeof( local_object ) );
+ nobject = (local_object *) malloc( sizeof( local_object ) );
if( !nobject )
{
@@ -120,7 +120,7 @@ static void local_rem( HMODULE hModule )
pobject = local_search( hModule );
- if( !pobject )
+ if( pobject == NULL )
return;
if( pobject->next )
@@ -159,7 +159,7 @@ static void save_err_str( const char *str )
*/
pos = 0;
error_buffer[pos++] = '"';
- memcpy( error_buffer+pos, str, len );
+ memcpy( error_buffer + pos, str, len );
pos += len;
error_buffer[pos++] = '"';
error_buffer[pos++] = ':';
@@ -167,7 +167,7 @@ static void save_err_str( const char *str )
ret = FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwMessageId,
MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ),
- error_buffer+pos, (DWORD) (sizeof(error_buffer)-pos), NULL );
+ error_buffer + pos, (DWORD) ( sizeof( error_buffer ) - pos ), NULL );
pos += ret;
/* When FormatMessageA() fails it returns zero and does not touch buffer
@@ -197,7 +197,7 @@ static void save_err_ptr_str( const void *ptr )
for( i = 0; i < 2 * sizeof( ptr ); i++ )
{
num = ( ( (ULONG_PTR) ptr ) >> ( 8 * sizeof( ptr ) - 4 * ( i + 1 ) ) ) & 0xF;
- ptr_buf[2+i] = num + ( ( num < 0xA ) ? '0' : ( 'A' - 0xA ) );
+ ptr_buf[2 + i] = num + ( ( num < 0xA ) ? '0' : ( 'A' - 0xA ) );
}
ptr_buf[2 + 2 * sizeof( ptr )] = 0;
@@ -234,9 +234,9 @@ void *dlopen( const char *file, int mode )
/* Do not let Windows display the critical-error-handler message box */
uMode = SetErrorMode( SEM_FAILCRITICALERRORS );
- if( file == 0 )
+ if( file == NULL )
{
- /* POSIX says that if the value of file is 0, a handle on a global
+ /* POSIX says that if the value of file is NULL, a handle on a global
* symbol object must be provided. That object must be able to access
* all symbols from the original program file, and any objects loaded
* 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()
*(void **) (&fwrite_local) = dlsym( global, "fwrite" );
if (!fwrite_local)
{
- error = dlerror();
+ error = dlerror( );
printf("ERROR\tCould not get symbol from global handle: %s\n",
error ? error : "");
CLOSE_LIB;
@@ -360,7 +360,7 @@ int main()
*(void **) (&fputs_default) = dlsym( RTLD_DEFAULT, "fputs" );
if (!fputs_default)
{
- error = dlerror();
+ error = dlerror( );
printf("ERROR\tCould not get symbol from default handle: %s\n",
error ? error : "");
CLOSE_LIB;
@@ -623,7 +623,7 @@ int main()
*(void **) (&function) = dlsym( global, "fwrite" );
if (!function)
{
- error = dlerror();
+ error = dlerror( );
printf("ERROR\tCould not get symbol from global handle: %s\n",
error ? error : "");
CLOSE_LIB;
@@ -659,7 +659,7 @@ int main()
*(void **) (&function) = dlsym( global, "function3" );
if (!function)
{
- error = dlerror();
+ error = dlerror( );
printf("ERROR\tCould not get symbol from global handle: %s\n",
error ? error : "");
CLOSE_LIB;