Skip to content

Commit

Permalink
Remove some warnings on NT/Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
grafikrobot committed Feb 26, 2020
1 parent 66869d1 commit 520ebfd
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
7 changes: 3 additions & 4 deletions src/engine/builtins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1952,7 +1952,7 @@ LIST *builtin_readlink( FRAME * frame, int flags )
int length = buf.reparse.SymbolicLinkReparseBuffer.SubstituteNameLength / 2;
char cbuf[MAX_PATH + 1];
int numchars = WideCharToMultiByte( CP_ACP, 0, buf.reparse.SymbolicLinkReparseBuffer.PathBuffer + index, length, cbuf, sizeof(cbuf), NULL, NULL );
if( numchars >= sizeof(cbuf) )
if( numchars >= int(sizeof(cbuf)) )
{
return 0;
}
Expand All @@ -1966,7 +1966,7 @@ LIST *builtin_readlink( FRAME * frame, int flags )
char cbuf[MAX_PATH + 1];
const char * result;
int numchars = WideCharToMultiByte( CP_ACP, 0, buf.reparse.MountPointReparseBuffer.PathBuffer + index, length, cbuf, sizeof(cbuf), NULL, NULL );
if( numchars >= sizeof(cbuf) )
if( numchars >= int(sizeof(cbuf)) )
{
return 0;
}
Expand Down Expand Up @@ -2690,7 +2690,6 @@ LIST * builtin_glob_archive( FRAME * frame, int flags )
{
LIST * const l = lol_get( frame->args, 0 );
LIST * const r1 = lol_get( frame->args, 1 );
LIST * const r2 = lol_get( frame->args, 2 );
LIST * const r3 = lol_get( frame->args, 3 );

LISTITER iter;
Expand All @@ -2705,7 +2704,7 @@ LIST * builtin_glob_archive( FRAME * frame, int flags )
# if defined( OS_NT ) || defined( OS_CYGWIN ) || defined( OS_VMS )
l; /* Always case-insensitive. */
# else
r2;
lol_get( frame->args, 2 ); // r2
# endif

if ( globbing.case_insensitive )
Expand Down
16 changes: 9 additions & 7 deletions src/engine/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -891,18 +891,20 @@ static void debug_parent_child_exited( int pid, int exit_code )
}
}

static void debug_parent_child_signalled( int pid, int sigid )
#if !NT

static void debug_parent_child_signalled( int pid, int id )
{

if ( debug_interface == DEBUG_INTERFACE_CONSOLE )
{
printf( "Child %d exited on signal %d\n", child_pid, sigid );
printf( "Child %d exited on signal %d\n", child_pid, id );
}
else if ( debug_interface == DEBUG_INTERFACE_MI )
{
const char * name = "unknown";
const char * meaning = "unknown";
switch( sigid )
switch( id )
{
case SIGINT: name = "SIGINT"; meaning = "Interrupt"; break;
}
Expand All @@ -914,6 +916,8 @@ static void debug_parent_child_signalled( int pid, int sigid )
}
}

#endif

static void debug_parent_on_breakpoint( void )
{
FRAME_INFO base;
Expand Down Expand Up @@ -1055,8 +1059,6 @@ void debug_init_handles( const char * in, const char * out )

static void init_parent_handles( HANDLE out, HANDLE in )
{
int read_fd, write_fd;

command_child = _fdopen( _open_osfhandle( (intptr_t)in, _O_RDONLY ), "r" );
command_output = _fdopen( _open_osfhandle( (intptr_t)out, _O_WRONLY ), "w" );
}
Expand Down Expand Up @@ -1107,12 +1109,12 @@ static void debug_start_child( int argc, const char * * argv )
assert( debug_state == DEBUG_NO_CHILD );
if ( ! CreatePipe( &pipe1[ 0 ], &pipe1[ 1 ], &sa, 0 ) )
{
printf("internal error: CreatePipe:1: 0x$08x\n", GetLastError());
printf("internal error: CreatePipe:1: 0x%08x\n", GetLastError());
return;
}
if ( ! CreatePipe( &pipe2[ 0 ], &pipe2[ 1 ], &sa, 0 ) )
{
printf("internal error: CreatePipe:2: 0x$08x\n", GetLastError());
printf("internal error: CreatePipe:2: 0x%08x\n", GetLastError());
CloseHandle( pipe1[ 0 ] );
CloseHandle( pipe1[ 1 ] );
return;
Expand Down
20 changes: 10 additions & 10 deletions src/engine/execnt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void execnt_unit_test()
* Use a table instead.
*/
{
typedef struct test { char * command; int result; } test;
typedef struct test { const char * command; int result; } test;
test tests[] = {
{ "", 0 },
{ " ", 0 },
Expand Down Expand Up @@ -279,7 +279,7 @@ int exec_check
/* Check prerequisites for executing raw commands. */
if ( is_raw_command_request( *pShell ) )
{
int const raw_cmd_length = raw_command_length( command->value );
long const raw_cmd_length = raw_command_length( command->value );
if ( raw_cmd_length < 0 )
{
/* Invalid characters detected - fallback to default shell. */
Expand Down Expand Up @@ -342,6 +342,7 @@ void exec_cmd
shell = default_shell;

if ( DEBUG_EXECCMD )
{
if ( is_raw_cmd )
out_printf( "Executing raw command directly\n" );
else
Expand All @@ -350,6 +351,7 @@ void exec_cmd
list_print( shell );
out_printf( "\n" );
}
}

/* If we are running a raw command directly - trim its leading whitespaces
* as well as any trailing all-whitespace lines but keep any trailing
Expand All @@ -367,7 +369,7 @@ void exec_cmd
end = p;
string_new( cmd_local );
string_append_range( cmd_local, start, end );
assert( cmd_local->size == raw_command_length( cmd_orig->value ) );
assert( long(cmd_local->size) == raw_command_length( cmd_orig->value ) );
}
/* If we are not running a raw command directly, prepare a command file to
* be executed using an external shell and the actual command string using
Expand Down Expand Up @@ -767,7 +769,7 @@ static void read_pipe
{
DWORD bytesInBuffer = 0;
DWORD bytesAvailable = 0;
int i;
DWORD i;

for (;;)
{
Expand Down Expand Up @@ -840,7 +842,6 @@ static void CALLBACK try_wait_callback( void * data, BOOLEAN is_timeout )
static int try_wait_impl( DWORD timeout )
{
int job_index;
int timed_out;
int res = WaitForSingleObject( process_queue.read_okay, timeout );
if ( res != WAIT_OBJECT_0 )
return -1;
Expand All @@ -853,7 +854,6 @@ static void register_wait( int job_id )
{
if ( globs.jobs > MAXIMUM_WAIT_OBJECTS )
{
HANDLE ignore;
RegisterWaitForSingleObject( &cmdtab[ job_id ].wait_handle,
cmdtab[ job_id ].pi.hProcess,
&try_wait_callback, &cmdtab[ job_id ], INFINITE,
Expand Down Expand Up @@ -1201,7 +1201,7 @@ static FILE * open_command_file( int const slot )
string_new( command_file );
string_reserve( command_file, tmpdir->size + 64 );
command_file->size = sprintf( command_file->value,
"%s\\jam%d-%02d-##.bat", tmpdir->value, procID, slot );
"%s\\jam%ul-%02d-##.bat", tmpdir->value, procID, slot );
}

/* For some reason opening a command file can fail intermittently. But doing
Expand Down Expand Up @@ -1314,15 +1314,15 @@ static void reportWindowsError( char const * const apiName, int slot )
(LPSTR)&errorMessage, /* __out LPTSTR lpBuffer */
0, /* __in DWORD nSize */
0 ); /* __in_opt va_list * Arguments */

/* Build a message as if the process had written to stderr. */
if ( globs.pipe_action )
err_buf = cmdtab[ slot ].buffer_err;
else
err_buf = cmdtab[ slot ].buffer_out;
string_append( err_buf, apiName );
string_append( err_buf, "() Windows API failed: " );
sprintf( buf, "%d", errorCode );
sprintf( buf, "%ul", errorCode );
string_append( err_buf, buf );

if ( !apiResult )
Expand All @@ -1347,7 +1347,7 @@ static void reportWindowsError( char const * const apiName, int slot )
(*cmdtab[ slot ].func)( cmdtab[ slot ].closure, EXEC_CMD_FAIL, &time,
cmdtab[ slot ].buffer_out->value, cmdtab[ slot ].buffer_err->value,
EXIT_OK );

/* Clean up any handles that were opened. */
closeWinHandle( &cmdtab[ slot ].pi.hProcess );
closeWinHandle( &cmdtab[ slot ].pi.hThread );
Expand Down
7 changes: 3 additions & 4 deletions src/engine/filent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ void file_archscan( char const * arch, scanback func, void * closure )
for ( ; iter != end ; iter = filelist_next( iter ) )
{
file_info_t * member_file = filelist_item( iter );
LIST * symbols = member_file->files;

/* Construct member path: 'archive-path(member-name)'
*/
Expand Down Expand Up @@ -481,13 +480,13 @@ int file_collect_archive_content_( file_archive_info_t * const archive )
/* strip leading directory names, an NT specialty */
{
char * c;
if ( c = strrchr( name, '/' ) )
if ( (c = strrchr( name, '/' )) != nullptr )
name = c + 1;
if ( c = strrchr( name, '\\' ) )
if ( (c = strrchr( name, '\\' )) != nullptr )
name = c + 1;
}

sprintf( buf, "%.*s", endname - name, name );
sprintf( buf, "%.*s", int(endname - name), name );

if ( strcmp( buf, "") != 0 )
{
Expand Down
2 changes: 1 addition & 1 deletion src/engine/pathnt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static int canonicWindowsPath( char const * const path, int const path_length,

/* Special case '\' && 'D:\' - include trailing '\'. */
if ( p == path ||
p == path + 2 && path[ 1 ] == ':' )
(p == path + 2 && path[ 1 ] == ':') )
++p;

missing_parent = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/engine/w32_getreg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ LIST * builtin_system_registry( FRAME * frame, int flags )

case REG_EXPAND_SZ:
{
long len;
unsigned long len;
string expanded[1];
string_new(expanded);

Expand Down Expand Up @@ -112,7 +112,7 @@ LIST * builtin_system_registry( FRAME * frame, int flags )
case REG_DWORD:
{
char buf[100];
sprintf( buf, "%u", *(PDWORD)data );
sprintf( buf, "%lu", *(PDWORD)data );
result = list_push_back( result, object_new(buf) );
}
break;
Expand Down

0 comments on commit 520ebfd

Please sign in to comment.