Get rid off debug features and dead code
This commit is contained in:
parent
205f323b87
commit
0443954c26
1 changed files with 1 additions and 20 deletions
|
@ -146,7 +146,6 @@ intmax_t saturating_add(intmax_t a, intmax_t b) {
|
||||||
// b < INTMAX_MIN - a
|
// b < INTMAX_MIN - a
|
||||||
if (b < INTMAX_MIN - a) {
|
if (b < INTMAX_MIN - a) {
|
||||||
// Underflow
|
// Underflow
|
||||||
fprintf(stderr, "a+b underflow\n"); // debg
|
|
||||||
return INTMAX_MIN;
|
return INTMAX_MIN;
|
||||||
}
|
}
|
||||||
} else if (a < 0 && b >= 0) {
|
} else if (a < 0 && b >= 0) {
|
||||||
|
@ -168,7 +167,6 @@ intmax_t saturating_add(intmax_t a, intmax_t b) {
|
||||||
// b > INTMAX_MAX - a
|
// b > INTMAX_MAX - a
|
||||||
if (b > INTMAX_MAX - a) {
|
if (b > INTMAX_MAX - a) {
|
||||||
// Overflow
|
// Overflow
|
||||||
fprintf(stderr, "a+b overflow\n"); // debg
|
|
||||||
return INTMAX_MAX;
|
return INTMAX_MAX;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,7 +184,6 @@ intmax_t saturating_sub(intmax_t a, intmax_t b) {
|
||||||
// a - b + c - c
|
// a - b + c - c
|
||||||
// a - (b - c) - c
|
// a - (b - c) - c
|
||||||
// a + (c - b) - c
|
// a + (c - b) - c
|
||||||
fprintf(stderr, "-b overflow\n"); // debg
|
|
||||||
intmax_t c = saturating_sub(b, -INTMAX_MAX);
|
intmax_t c = saturating_sub(b, -INTMAX_MAX);
|
||||||
return saturating_sub(saturating_add(a, c - b), c);
|
return saturating_sub(saturating_add(a, c - b), c);
|
||||||
} else {
|
} else {
|
||||||
|
@ -209,7 +206,6 @@ intmax_t saturating_mul(intmax_t a, intmax_t b) {
|
||||||
|
|
||||||
if (INTMAX_MAX / a < b) {
|
if (INTMAX_MAX / a < b) {
|
||||||
// Overflow
|
// Overflow
|
||||||
fprintf(stderr, "a*b overflow\n"); // debg
|
|
||||||
return INTMAX_MAX;
|
return INTMAX_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,21 +243,6 @@ int wait_ms_until(struct timespec then) {
|
||||||
return (int)ms;
|
return (int)ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
char hexify(int nybble) {
|
|
||||||
assert(0 <= nybble && nybble <= 16);
|
|
||||||
return "0123456789abcdef"[nybble];
|
|
||||||
}
|
|
||||||
|
|
||||||
void format_mac(const unsigned char binary_address[6], char formatted[18]) {
|
|
||||||
for (size_t i = 0; i < 6; i++) {
|
|
||||||
unsigned char byte = binary_address[i];
|
|
||||||
formatted[3*i] = hexify(byte >> 4);
|
|
||||||
formatted[3*i + 1] = hexify(byte & 0xf);
|
|
||||||
formatted[3*i + 2] = ':';
|
|
||||||
}
|
|
||||||
formatted[17] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
void drop_privileges(void) {
|
void drop_privileges(void) {
|
||||||
uid_t uid = getuid();
|
uid_t uid = getuid();
|
||||||
gid_t gid = getgid();
|
gid_t gid = getgid();
|
||||||
|
@ -497,7 +478,7 @@ void read_command(void) {
|
||||||
} else if (cmd == 'm') {
|
} else if (cmd == 'm') {
|
||||||
read_message();
|
read_message();
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "?"); //debg
|
errx(1, "Frontend sent an unknown command %c", cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue