Commit 53f701a3 authored by Johannes Kanig's avatar Johannes Kanig Committed by Sylvain Dailler

(no-tn-check) fix loop style to C99 style

Change-Id: Ie756bd146b822782bac977326a6a2b996d075dec
(cherry picked from commit 6339d6678c3260b6e4e42f944581c4515c2ed567)
parent a20677f0
......@@ -33,8 +33,7 @@ bool list_is_empty(plist l) {
}
int list_lookup_index(plist l, int key) {
int i;
for (i = 0; i < l->len; i++) {
for (int i = 0; i < l->len; i++) {
if (l->key[i] == key) {
return i;
}
......
......@@ -29,8 +29,7 @@ int copy_up_to_semicolon(char* buf, int begin, int len, char** result);
int count_semicolons(char* buf, int len) {
int cnt = 0;
int i = 0;
for (i = 0; i < len; i++) {
for (int i = 0; i < len; i++) {
if (buf[i] == ';') {
cnt++;
}
......@@ -57,7 +56,6 @@ int copy_up_to_semicolon(char* buf, int begin, int len, char** result) {
prequest parse_request(char* str_req, int len, int key) {
int numargs, semic, parallel_arg;
int i = 0;
int pos = 0;
prequest req;
char* tmp;
......@@ -112,17 +110,16 @@ prequest parse_request(char* str_req, int len, int key) {
free(tmp);
pos = copy_up_to_semicolon(str_req, pos, len, &(req->cmd));
req->args = (char**)malloc(sizeof(char*) * (numargs));
for (i = 0; i < numargs; i++) {
for (int i = 0; i < numargs; i++) {
pos = copy_up_to_semicolon(str_req, pos, len, &(req->args[i]));
}
return req;
}
void print_request(prequest r) {
int i;
if (r) {
printf("%s %d %d %s", r->id, r->timeout, r->memlimit, r->cmd);
for (i = 0; i < r->numargs; i++) {
for (int i = 0; i < r->numargs; i++) {
printf(" %s", r->args[i]);
}
} else {
......@@ -131,9 +128,8 @@ void print_request(prequest r) {
}
void free_request(prequest r) {
int i;
free(r->cmd);
for (i = 0;i < r->numargs; i++) {
for (int i = 0;i < r->numargs; i++) {
free(r->args[i]);
}
free(r->args);
......
......@@ -75,12 +75,11 @@ static int cpipe[2];
void shutdown_with_msg(char* msg);
void shutdown_with_msg(char* msg) {
int i;
if (server_sock != -1) {
close(server_sock);
}
if (clients != NULL) {
for (i = 0; i < list_length(clients); i++) {
for (int i = 0; i < list_length(clients); i++) {
close(((pclient) clients->data[i])->fd);
}
}
......@@ -102,8 +101,7 @@ void add_to_poll_list(int sock, short events) {
}
struct pollfd* poll_list_lookup(int fd) {
int i;
for (i = 0; i < poll_num; i++) {
for (int i = 0; i < poll_num; i++) {
if (poll_list[i].fd == fd) {
return poll_list+i;
}
......@@ -257,7 +255,6 @@ pid_t create_process(char* cmd,
int timelimit,
int memlimit) {
struct rlimit res;
int i;
char** unix_argv;
int count = argc;
// in the case of usestdin, the last argument is in fact not passed to
......@@ -268,7 +265,7 @@ pid_t create_process(char* cmd,
unix_argv = (char**)malloc(sizeof(char*) * (count + 2));
unix_argv[0] = cmd;
unix_argv[count + 1] = NULL;
for (i = 0; i < count; i++) {
for (int i = 0; i < count; i++) {
unix_argv[i + 1] = argv[i];
}
......@@ -544,7 +541,6 @@ void schedule_new_jobs() {
}
int main(int argc, char **argv) {
int i;
char ch;
int res;
struct pollfd* cur;
......@@ -558,7 +554,7 @@ int main(int argc, char **argv) {
if (res == -1) {
shutdown_with_msg("call to poll failed");
}
for (i = 0; i < poll_num; i++) {
for (int i = 0; i < poll_num; i++) {
cur = (struct pollfd*) poll_list + i;
if (cur->revents == 0) {
continue;
......
......@@ -103,7 +103,6 @@ void shutdown_with_msg(char* msg);
void shutdown_with_msg(char* msg) {
pproc proc;
int i;
if (completion_port != NULL) {
CloseHandle (completion_port);
}
......@@ -111,12 +110,12 @@ void shutdown_with_msg(char* msg) {
CloseHandle (server_socket->handle);
}
if (clients != NULL) {
for (i = 0; i < list_length(clients); i++) {
for (int i = 0; i < list_length(clients); i++) {
CloseHandle(((pclient) clients->data[i])->handle);
}
}
if (processes != NULL) {
for (i = 0; i < list_length(processes); i++) {
for (int i = 0; i < list_length(processes); i++) {
proc = processes->data[i];
CloseHandle(proc->handle);
CloseHandle(proc->job);
......@@ -292,18 +291,16 @@ void run_request (prequest r) {
/* Now take care of the arguments */
{
int k;
for (k = 0; k < argcount; k++)
for (int k = 0; k < argcount; k++)
{
char *ca = r->args[k]; /* current arg */
int ca_index; /* index of the current character in ca */
int need_quote = 1; /* set to 1 if quotes are needed */
/* Should we quote the string ? */
if (strlen(ca) > 0)
need_quote = 0;
for (ca_index = 0; ca_index < strlen(ca); ca_index++)
for (int ca_index = 0; ca_index < strlen(ca); ca_index++)
{
if (ca[ca_index] == ' ' || ca[ca_index] == '"')
{
......@@ -322,7 +319,7 @@ void run_request (prequest r) {
/* Open the double quoted string */
cmd[cl_index] = '"'; cl_index++;
for (ca_index = 0; ca_index < strlen(ca); ca_index++)
for (int ca_index = 0; ca_index < strlen(ca); ca_index++)
{
/* We have a double in the argument. It should be escaped
......@@ -333,8 +330,7 @@ void run_request (prequest r) {
They should be quoted. */
if (ca_index > 0 && ca[ca_index - 1] == '\\')
{
int j;
for (j = ca_index - 1; j >= 0 && ca[j] == '\\' ;j--)
for (int j = ca_index - 1; j >= 0 && ca[j] == '\\' ;j--)
{
cmd[cl_index] = '\\'; cl_index++;
}
......@@ -352,8 +348,7 @@ void run_request (prequest r) {
They should be quoted. */
if (ca[ca_index] == '\\' && ca_index + 1 == strlen(ca))
{
int j;
for (j = ca_index; j >= 0 && ca[j] == '\\' ;j--)
for (int j = ca_index; j >= 0 && ca[j] == '\\' ;j--)
{
cmd[cl_index] = '\\'; cl_index++;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment