Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

##No check for end of array##

No check for end of array

incByte() doesn't check if i >= 0. So if all bytes are 0xff, it will happily start reading/writing to state[-1].

##Simplification##

Simplification

Actually, I would remove the recursion. If byte is of size 1 byte, you could also simplify the check for overflow past 0xff:

void incByte(byte *state, int i)
{
 do {
 if (++state[i] != 0)
 return;
 i--;
 } while (i >= 0);
}

##No check for end of array##

incByte() doesn't check if i >= 0. So if all bytes are 0xff, it will happily start reading/writing to state[-1].

##Simplification##

Actually, I would remove the recursion. If byte is of size 1 byte, you could also simplify the check for overflow past 0xff:

void incByte(byte *state, int i)
{
 do {
 if (++state[i] != 0)
 return;
 i--;
 } while (i >= 0);
}

No check for end of array

incByte() doesn't check if i >= 0. So if all bytes are 0xff, it will happily start reading/writing to state[-1].

Simplification

Actually, I would remove the recursion. If byte is of size 1 byte, you could also simplify the check for overflow past 0xff:

void incByte(byte *state, int i)
{
 do {
 if (++state[i] != 0)
 return;
 i--;
 } while (i >= 0);
}
added 4 characters in body
Source Link
JS1
  • 28.9k
  • 3
  • 41
  • 83

##No check for end of array##

incByte() doesn't check if i >= 0. So if all bytes are 0xff, it will happily start reading/writing to state[-1].

##Simplification##

Actually, I would remove the recursion. If byte is of size 1 byte, you could also simplify the check for overflow past 0xff:

void incByte(byte *state, int i)
{
 while (i >= 0)do {
 if (++state[i] != 0)
 return;
 i--;
 } while (i >= 0);
}

##No check for end of array##

incByte() doesn't check if i >= 0. So if all bytes are 0xff, it will happily start reading/writing to state[-1].

##Simplification##

Actually, I would remove the recursion. If byte is of size 1 byte, you could also simplify the check for overflow past 0xff:

void incByte(byte *state, int i)
{
 while (i >= 0) {
 if (++state[i] != 0)
 return;
 i--;
 }
}

##No check for end of array##

incByte() doesn't check if i >= 0. So if all bytes are 0xff, it will happily start reading/writing to state[-1].

##Simplification##

Actually, I would remove the recursion. If byte is of size 1 byte, you could also simplify the check for overflow past 0xff:

void incByte(byte *state, int i)
{
 do {
 if (++state[i] != 0)
 return;
 i--;
 } while (i >= 0);
}
added 13 characters in body
Source Link
JS1
  • 28.9k
  • 3
  • 41
  • 83

##No check for end of array##

incByte() doesn't check if i >= 0. So if all bytes are 0xff, it will happily start reading/writing to state[-1].

##Simplification##

Actually, I would remove the recursion. Also if If byte is of size 1 byte, you could also simplify the if statementcheck for overflow past 0xff:

void incByte(byte *state, int i)
{
 while (i >= 0) {
 if (++state[i] != 0)
 return;
 i--;
 }
}

##No check for end of array##

incByte() doesn't check if i >= 0. So if all bytes are 0xff, it will happily start reading/writing to state[-1].

##Simplification##

Actually, I would remove the recursion. Also if byte is of size 1 byte, you could also simplify the if statement:

void incByte(byte *state, int i)
{
 while (i >= 0) {
 if (++state[i] != 0)
 return;
 i--;
 }
}

##No check for end of array##

incByte() doesn't check if i >= 0. So if all bytes are 0xff, it will happily start reading/writing to state[-1].

##Simplification##

Actually, I would remove the recursion. If byte is of size 1 byte, you could also simplify the check for overflow past 0xff:

void incByte(byte *state, int i)
{
 while (i >= 0) {
 if (++state[i] != 0)
 return;
 i--;
 }
}
Source Link
JS1
  • 28.9k
  • 3
  • 41
  • 83
Loading
lang-c

AltStyle によって変換されたページ (->オリジナル) /