Get rid off debug features and dead code

This commit is contained in:
Juhani Krekelä 2019-07-14 22:54:17 +03:00
parent 205f323b87
commit 0443954c26
1 changed files with 1 additions and 20 deletions

View File

@ -146,7 +146,6 @@ intmax_t saturating_add(intmax_t a, intmax_t b) {
// b < INTMAX_MIN - a
if (b < INTMAX_MIN - a) {
// Underflow
fprintf(stderr, "a+b underflow\n"); // debg
return INTMAX_MIN;
}
} else if (a < 0 && b >= 0) {
@ -168,7 +167,6 @@ intmax_t saturating_add(intmax_t a, intmax_t b) {
// b > INTMAX_MAX - a
if (b > INTMAX_MAX - a) {
// Overflow
fprintf(stderr, "a+b overflow\n"); // debg
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 + (c - b) - c
fprintf(stderr, "-b overflow\n"); // debg
intmax_t c = saturating_sub(b, -INTMAX_MAX);
return saturating_sub(saturating_add(a, c - b), c);
} else {
@ -209,7 +206,6 @@ intmax_t saturating_mul(intmax_t a, intmax_t b) {
if (INTMAX_MAX / a < b) {
// Overflow
fprintf(stderr, "a*b overflow\n"); // debg
return INTMAX_MAX;
}
@ -247,21 +243,6 @@ int wait_ms_until(struct timespec then) {
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) {
uid_t uid = getuid();
gid_t gid = getgid();
@ -497,7 +478,7 @@ void read_command(void) {
} else if (cmd == 'm') {
read_message();
} else {
fprintf(stderr, "?"); //debg
errx(1, "Frontend sent an unknown command %c", cmd);
}
}