c++/c99-style for loops in firmware

This commit is contained in:
Clifford Wolf 2015-07-04 11:47:43 +02:00
parent 91f75bdf1f
commit 21da66db68
4 changed files with 7 additions and 11 deletions

View File

@ -30,7 +30,6 @@ uint32_t *irq(uint32_t *regs, uint32_t irqs)
if ((irqs & 6) != 0)
{
int i, k;
uint32_t pc = regs[0] - 4;
uint32_t instr = *(uint32_t*)pc;
@ -59,8 +58,8 @@ uint32_t *irq(uint32_t *regs, uint32_t irqs)
print_str("\n");
}
for (i = 0; i < 8; i++)
for (k = 0; k < 4; k++)
for (int i = 0; i < 8; i++)
for (int k = 0; k < 4; k++)
{
int r = i + k*8;

View File

@ -17,8 +17,7 @@ static uint32_t xorshift32(void) {
void multest(void)
{
int i;
for (i = 0; i < 10; i++)
for (int i = 0; i < 10; i++)
{
uint32_t a = xorshift32();
uint32_t b = xorshift32();

View File

@ -35,8 +35,7 @@ void print_dec(unsigned int val)
void print_hex(unsigned int val)
{
int i;
for (i = 32-4; i >= 0; i -= 4)
for (int i = 32-4; i >= 0; i -= 4)
*((volatile uint32_t*)OUTPORT) = "0123456789ABCDEF"[(val >> i) % 16];
}

View File

@ -54,18 +54,17 @@ static void print_prime(int idx, int val)
void sieve(void)
{
int i, j, k;
int idx = 1;
hash = 5381;
print_prime(idx++, 2);
for (i = 0; i < BITMAP_SIZE; i++) {
for (int i = 0; i < BITMAP_SIZE; i++) {
if (bitmap_get(i))
continue;
print_prime(idx++, 3+2*i);
for (j = 2*(3+2*i);; j += 3+2*i) {
for (int j = 2*(3+2*i);; j += 3+2*i) {
if (j%2 == 0)
continue;
k = (j-3)/2;
int k = (j-3)/2;
if (k >= BITMAP_SIZE)
break;
bitmap_set(k);