Address review: harden dtls_bench time source and -z usage

Fail loudly if clock_gettime() ever fails instead of computing
throughput from uninitialized stack, and warn when -z is combined with
-s since the sink-send only applies to the client.
This commit is contained in:
Juliusz Sosinowicz
2026-06-10 02:46:02 +00:00
parent 000d407dee
commit 94d0a49497
+9 -1
View File
@@ -116,7 +116,10 @@ typedef struct cfg {
static double now_sec(void)
{
struct timespec ts;
(void)clock_gettime(CLOCK_MONOTONIC, &ts);
if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
perror("clock_gettime");
exit(EXIT_FAILURE);
}
return (double)ts.tv_sec + (double)ts.tv_nsec / 1e9;
}
@@ -240,6 +243,11 @@ static int parse_args(int argc, char** argv, cfg_t* c)
fprintf(stderr, "MTU must be between 64 and 16384\n");
return -1;
}
if (c->isServer && c->sinkSend) {
fprintf(stderr, "warning: -z only applies to the client (the send "
"side); ignoring it in server mode\n");
c->sinkSend = 0;
}
if (c->recordSz < 1) {
fprintf(stderr, "record size must be > 0\n");
return -1;