1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

mostly coding style fixes

This commit is contained in:
Benoit Jacob 2020-11-16 22:56:59 -05:00
parent d1e226b2eb
commit 583f43f2fe

View File

@ -798,8 +798,7 @@ static void SetupSampling( int64_t& samplingPeriod )
#ifdef __ANDROID__ #ifdef __ANDROID__
// The following Android-specific code is motivated by the following Android-specific // This code is motivated by the following Android-specific aspects:
// aspects:
// 1. On Android, graphical applications ("intents") never run as root, not even // 1. On Android, graphical applications ("intents") never run as root, not even
// if spawned from a root shell. See: // if spawned from a root shell. See:
// https://stackoverflow.com/questions/18479288/can-i-start-an-android-intent-as-root // https://stackoverflow.com/questions/18479288/can-i-start-an-android-intent-as-root
@ -884,6 +883,7 @@ enum class RootMethod {
// `su root sh -c 'command'`. // `su root sh -c 'command'`.
SuRoot, SuRoot,
// We don't know how to run a command as root on this device. // We don't know how to run a command as root on this device.
// This should be caught early during initialization.
None None
}; };
@ -930,8 +930,8 @@ static int ExeclpAsRoot( char* argv0, ... ) {
args[args_count++] = "su"; args[args_count++] = "su";
args[args_count++] = "root"; args[args_count++] = "root";
break; break;
case RootMethod::None: default:
break; // just cross fingers! break;
} }
va_list l; va_list l;
va_start( l, argv0 ); va_start( l, argv0 );
@ -950,23 +950,22 @@ static int ExeclpAsRoot( char* argv0, ... ) {
// a shell command, then this function fixes that up by inserting // a shell command, then this function fixes that up by inserting
// `sh -c` in the command. // `sh -c` in the command.
static int SystemAsRoot( const char* command ) { static int SystemAsRoot( const char* command ) {
const char* command_format = ""; const char* format = "";
switch( GetRootMethod() ) { switch( GetRootMethod() ) {
case RootMethod::AlreadyRoot: case RootMethod::AlreadyRoot:
command_format = "%s"; // no need to prepend any args. format = "%s"; // no need to prepend any args.
break; break;
case RootMethod::SuDashC: case RootMethod::SuDashC:
command_format = "su -c '%s'"; format = "su -c '%s'";
break; break;
case RootMethod::SuRoot: case RootMethod::SuRoot:
command_format = "su root sh -c '%s'"; format = "su root sh -c '%s'";
break; break;
case RootMethod::None: default:
command_format = "%s"; // just cross fingers!
break; break;
} }
char actual_command[256] = {}; char actual_command[256] = {};
snprintf(actual_command, sizeof actual_command, command_format, command); snprintf( actual_command, sizeof actual_command, format, command );
return system( actual_command ); return system( actual_command );
} }