Code format fixes

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
Mark Charlebois
2016-02-19 16:59:42 +01:00
committed by Julian Oes
parent d6a99c79c1
commit 5846a22a8f
11 changed files with 284 additions and 238 deletions
+35 -32
View File
@@ -68,28 +68,30 @@ static void run_cmd(map<string, px4_main_t> &apps, const vector<string> &appargs
string command = appargs[0];
//replaces app.find with iterator code to avoid null pointer exception
for (map<string,px4_main_t>::iterator it=apps.begin(); it!=apps.end(); ++it)
if (it->first == command) {
const char *arg[2 + 1];
for (map<string, px4_main_t>::iterator it = apps.begin(); it != apps.end(); ++it)
if (it->first == command) {
const char *arg[2 + 1];
unsigned int i = 0;
unsigned int i = 0;
while (i < appargs.size() && appargs[i].c_str()[0] != '\0') {
arg[i] = (char *)appargs[i].c_str();
PX4_WARN(" arg%d = '%s'\n", i, arg[i]);
++i;
}
arg[i] = (char *)0;
//PX4_DEBUG_PRINTF(i);
if (apps[command] == NULL) {
PX4_ERR("Null function !!\n");
} else {
apps[command](i, (char **)arg);
break;
}
while (i < appargs.size() && appargs[i].c_str()[0] != '\0') {
arg[i] = (char *)appargs[i].c_str();
PX4_WARN(" arg%d = '%s'\n", i, arg[i]);
++i;
}
arg[i] = (char *)0;
//PX4_DEBUG_PRINTF(i);
if(apps[command]==NULL)
PX4_ERR("Null function !!\n");
else {
apps[command](i, (char **)arg);
break;
}
}
}
void eat_whitespace(const char *&b, int &i)
@@ -108,7 +110,7 @@ static void process_commands(map<string, px4_main_t> &apps, const char *cmds)
const char *b = cmds;
char arg[256];
// Eat leading whitespace
eat_whitespace(b, i);
@@ -170,26 +172,27 @@ const char *get_commands()
{
int fd = open(COMMANDS_ADSP_FILE, O_RDONLY);
if(fd>0)
{
if (fd > 0) {
static char *commands;
char buf[4096];
int bytes_read, total_bytes=0;
int bytes_read, total_bytes = 0;
PX4_INFO("reading commands from %s\n", COMMANDS_ADSP_FILE);
do{
bytes_read = read(fd, (void*)buf, sizeof(buf));
if(bytes_read>0)
{
commands=(char*)realloc(commands, total_bytes+bytes_read);
memcpy(commands+total_bytes, buf, bytes_read);
do {
bytes_read = read(fd, (void *)buf, sizeof(buf));
if (bytes_read > 0) {
commands = (char *)realloc(commands, total_bytes + bytes_read);
memcpy(commands + total_bytes, buf, bytes_read);
total_bytes += bytes_read;
}
}while((unsigned int)bytes_read>0);
} while ((unsigned int)bytes_read > 0);
close(fd);
return (const char*)commands;
return (const char *)commands;
}
PX4_ERR("Could not open %s\n", COMMANDS_ADSP_FILE);
static const char *commands =