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:
parent
d1e226b2eb
commit
583f43f2fe
@ -798,8 +798,7 @@ static void SetupSampling( int64_t& samplingPeriod )
|
||||
|
||||
#ifdef __ANDROID__
|
||||
|
||||
// The following Android-specific code is motivated by the following Android-specific
|
||||
// aspects:
|
||||
// This code is motivated by the following Android-specific aspects:
|
||||
// 1. On Android, graphical applications ("intents") never run as root, not even
|
||||
// if spawned from a root shell. See:
|
||||
// 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'`.
|
||||
SuRoot,
|
||||
// We don't know how to run a command as root on this device.
|
||||
// This should be caught early during initialization.
|
||||
None
|
||||
};
|
||||
|
||||
@ -930,8 +930,8 @@ static int ExeclpAsRoot( char* argv0, ... ) {
|
||||
args[args_count++] = "su";
|
||||
args[args_count++] = "root";
|
||||
break;
|
||||
case RootMethod::None:
|
||||
break; // just cross fingers!
|
||||
default:
|
||||
break;
|
||||
}
|
||||
va_list l;
|
||||
va_start( l, argv0 );
|
||||
@ -950,23 +950,22 @@ static int ExeclpAsRoot( char* argv0, ... ) {
|
||||
// a shell command, then this function fixes that up by inserting
|
||||
// `sh -c` in the command.
|
||||
static int SystemAsRoot( const char* command ) {
|
||||
const char* command_format = "";
|
||||
const char* format = "";
|
||||
switch( GetRootMethod() ) {
|
||||
case RootMethod::AlreadyRoot:
|
||||
command_format = "%s"; // no need to prepend any args.
|
||||
format = "%s"; // no need to prepend any args.
|
||||
break;
|
||||
case RootMethod::SuDashC:
|
||||
command_format = "su -c '%s'";
|
||||
format = "su -c '%s'";
|
||||
break;
|
||||
case RootMethod::SuRoot:
|
||||
command_format = "su root sh -c '%s'";
|
||||
format = "su root sh -c '%s'";
|
||||
break;
|
||||
case RootMethod::None:
|
||||
command_format = "%s"; // just cross fingers!
|
||||
default:
|
||||
break;
|
||||
}
|
||||
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 );
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user