fix -Wshadow warnings

Rename variables to avoid conflicts in naming of local and global
variables.
This commit is contained in:
Miroslav Lichvar
2025-11-19 16:05:38 +01:00
parent 0fec9e5cfa
commit 42e7a7ae12
8 changed files with 81 additions and 81 deletions

View File

@@ -328,30 +328,28 @@ expand_hashtable(void)
/* ================================================== */ /* ================================================== */
static void static void
set_bucket_params(int interval, int burst, uint16_t *max_tokens, set_bucket_params(int interval, int burst, uint16_t *mtokens, uint16_t *tphit, int *tshift)
uint16_t *tokens_per_packet, int *token_shift)
{ {
interval = CLAMP(MIN_LIMIT_INTERVAL, interval, MAX_LIMIT_INTERVAL); interval = CLAMP(MIN_LIMIT_INTERVAL, interval, MAX_LIMIT_INTERVAL);
burst = CLAMP(MIN_LIMIT_BURST, burst, MAX_LIMIT_BURST); burst = CLAMP(MIN_LIMIT_BURST, burst, MAX_LIMIT_BURST);
if (interval >= -TS_FRAC) { if (interval >= -TS_FRAC) {
/* Find the smallest shift with which the maximum number fits in 16 bits */ /* Find the smallest shift with which the maximum number fits in 16 bits */
for (*token_shift = 0; *token_shift < interval + TS_FRAC; (*token_shift)++) { for (*tshift = 0; *tshift < interval + TS_FRAC; (*tshift)++) {
if (burst << (TS_FRAC + interval - *token_shift) < 1U << 16) if (burst << (TS_FRAC + interval - *tshift) < 1U << 16)
break; break;
} }
} else { } else {
/* Coarse rate limiting */ /* Coarse rate limiting */
*token_shift = interval + TS_FRAC; *tshift = interval + TS_FRAC;
*tokens_per_packet = 1; *tphit = 1;
burst = MAX(1U << -*token_shift, burst); burst = MAX(1U << -*tshift, burst);
} }
*tokens_per_packet = 1U << (TS_FRAC + interval - *token_shift); *tphit = 1U << (TS_FRAC + interval - *tshift);
*max_tokens = *tokens_per_packet * burst; *mtokens = *tphit * burst;
DEBUG_LOG("Tokens max %d packet %d shift %d", DEBUG_LOG("Tokens max %d packet %d shift %d", *mtokens, *tphit, *tshift);
*max_tokens, *tokens_per_packet, *token_shift);
} }
/* ================================================== */ /* ================================================== */

20
conf.c
View File

@@ -968,7 +968,7 @@ parse_ratelimit(char *line, int *enabled, int *interval, int *burst, int *leak,
static void static void
parse_refclock(char *line) parse_refclock(char *line)
{ {
int n, poll, dpoll, filter_length, pps_rate, min_samples, max_samples, sel_options; int n, poll, dpoll, filter_length, pps_rate, min_samples_, max_samples_, sel_options;
int local, max_lock_age, max_unreach, pps_forced, sel_option, stratum, tai; int local, max_lock_age, max_unreach, pps_forced, sel_option, stratum, tai;
uint32_t ref_id, lock_ref_id; uint32_t ref_id, lock_ref_id;
double offset, delay, precision, max_dispersion, pulse_width; double offset, delay, precision, max_dispersion, pulse_width;
@@ -981,8 +981,8 @@ parse_refclock(char *line)
local = 0; local = 0;
pps_forced = 0; pps_forced = 0;
pps_rate = 0; pps_rate = 0;
min_samples = SRC_DEFAULT_MINSAMPLES; min_samples_ = SRC_DEFAULT_MINSAMPLES;
max_samples = SRC_DEFAULT_MAXSAMPLES; max_samples_ = SRC_DEFAULT_MAXSAMPLES;
max_unreach = SRC_DEFAULT_MAXUNREACH; max_unreach = SRC_DEFAULT_MAXUNREACH;
sel_options = 0; sel_options = 0;
offset = 0.0; offset = 0.0;
@@ -1040,13 +1040,13 @@ parse_refclock(char *line)
if (!SSCANF_IN_RANGE(line, "%d%n", &pps_rate, &n, 1, INT_MAX)) if (!SSCANF_IN_RANGE(line, "%d%n", &pps_rate, &n, 1, INT_MAX))
break; break;
} else if (!strcasecmp(cmd, "minsamples")) { } else if (!strcasecmp(cmd, "minsamples")) {
if (!SSCANF_IN_RANGE(line, "%d%n", &min_samples, &n, 0, INT_MAX)) if (!SSCANF_IN_RANGE(line, "%d%n", &min_samples_, &n, 0, INT_MAX))
break; break;
} else if (!strcasecmp(cmd, "maxlockage")) { } else if (!strcasecmp(cmd, "maxlockage")) {
if (!SSCANF_IN_RANGE(line, "%d%n", &max_lock_age, &n, 0, INT_MAX)) if (!SSCANF_IN_RANGE(line, "%d%n", &max_lock_age, &n, 0, INT_MAX))
break; break;
} else if (!strcasecmp(cmd, "maxsamples")) { } else if (!strcasecmp(cmd, "maxsamples")) {
if (!SSCANF_IN_RANGE(line, "%d%n", &max_samples, &n, 0, INT_MAX)) if (!SSCANF_IN_RANGE(line, "%d%n", &max_samples_, &n, 0, INT_MAX))
break; break;
} else if (!strcasecmp(cmd, "maxunreach")) { } else if (!strcasecmp(cmd, "maxunreach")) {
if (!SSCANF_IN_RANGE(line, "%d%n", &max_unreach, &n, 0, INT_MAX)) if (!SSCANF_IN_RANGE(line, "%d%n", &max_unreach, &n, 0, INT_MAX))
@@ -1098,8 +1098,8 @@ parse_refclock(char *line)
refclock->local = local; refclock->local = local;
refclock->pps_forced = pps_forced; refclock->pps_forced = pps_forced;
refclock->pps_rate = pps_rate; refclock->pps_rate = pps_rate;
refclock->min_samples = min_samples; refclock->min_samples = min_samples_;
refclock->max_samples = max_samples; refclock->max_samples = max_samples_;
refclock->max_unreach = max_unreach; refclock->max_unreach = max_unreach;
refclock->sel_options = sel_options; refclock->sel_options = sel_options;
refclock->stratum = stratum; refclock->stratum = stratum;
@@ -2448,16 +2448,16 @@ CNF_GetLogChange(void)
/* ================================================== */ /* ================================================== */
void void
CNF_GetMailOnChange(int *enabled, double *threshold, char **user) CNF_GetMailOnChange(int *enabled, double *threshold, char **user_)
{ {
if (mail_user_on_change) { if (mail_user_on_change) {
*enabled = 1; *enabled = 1;
*threshold = mail_change_threshold; *threshold = mail_change_threshold;
*user = mail_user_on_change; *user_ = mail_user_on_change;
} else { } else {
*enabled = 0; *enabled = 0;
*threshold = 0.0; *threshold = 0.0;
*user = NULL; *user_ = NULL;
} }
} }

View File

@@ -104,7 +104,7 @@ static int logged_connection_error;
/* ================================================== */ /* ================================================== */
static void read_write_socket(int sock_fd, int event, void *anything); static void read_write_socket(int fd, int event, void *anything);
/* ================================================== */ /* ================================================== */
@@ -193,7 +193,7 @@ process_response(SignInstance *inst)
/* ================================================== */ /* ================================================== */
static void static void
read_write_socket(int sock_fd, int event, void *anything) read_write_socket(int fd, int event, void *anything)
{ {
SignInstance *inst; SignInstance *inst;
uint32_t response_length; uint32_t response_length;
@@ -208,7 +208,7 @@ read_write_socket(int sock_fd, int event, void *anything)
if (!inst->sent) if (!inst->sent)
SCH_GetLastEventTime(NULL, NULL, &inst->request_ts); SCH_GetLastEventTime(NULL, NULL, &inst->request_ts);
s = SCK_Send(sock_fd, (char *)&inst->request + inst->sent, s = SCK_Send(fd, (char *)&inst->request + inst->sent,
inst->request_length - inst->sent, 0); inst->request_length - inst->sent, 0);
if (s < 0) { if (s < 0) {
@@ -223,7 +223,7 @@ read_write_socket(int sock_fd, int event, void *anything)
return; return;
/* Disable output and wait for a response */ /* Disable output and wait for a response */
SCH_SetFileHandlerEvent(sock_fd, SCH_FILE_OUTPUT, 0); SCH_SetFileHandlerEvent(fd, SCH_FILE_OUTPUT, 0);
} }
if (event == SCH_FILE_INPUT) { if (event == SCH_FILE_INPUT) {
@@ -234,7 +234,7 @@ read_write_socket(int sock_fd, int event, void *anything)
} }
assert(inst->received < sizeof (inst->response)); assert(inst->received < sizeof (inst->response));
s = SCK_Receive(sock_fd, (char *)&inst->response + inst->received, s = SCK_Receive(fd, (char *)&inst->response + inst->received,
sizeof (inst->response) - inst->received, 0); sizeof (inst->response) - inst->received, 0);
if (s <= 0) { if (s <= 0) {
@@ -265,7 +265,7 @@ read_write_socket(int sock_fd, int event, void *anything)
/* Move the head and enable output for the next packet */ /* Move the head and enable output for the next packet */
queue_head = NEXT_QUEUE_INDEX(queue_head); queue_head = NEXT_QUEUE_INDEX(queue_head);
if (!IS_QUEUE_EMPTY()) if (!IS_QUEUE_EMPTY())
SCH_SetFileHandlerEvent(sock_fd, SCH_FILE_OUTPUT, 1); SCH_SetFileHandlerEvent(fd, SCH_FILE_OUTPUT, 1);
} }
} }

View File

@@ -51,7 +51,7 @@
static void measurement_timeout(void *any); static void measurement_timeout(void *any);
static void read_from_device(int fd_, int event, void *any); static void read_from_device(int fd, int event, void *any);
/* ================================================== */ /* ================================================== */
@@ -65,7 +65,7 @@ static OperatingMode operating_mode = OM_NORMAL;
/* ================================================== */ /* ================================================== */
static int fd; static int rtc_fd;
#define LOWEST_MEASUREMENT_PERIOD 15 #define LOWEST_MEASUREMENT_PERIOD 15
#define HIGHEST_MEASUREMENT_PERIOD 480 #define HIGHEST_MEASUREMENT_PERIOD 480
@@ -522,21 +522,21 @@ int
RTC_Linux_Initialise(void) RTC_Linux_Initialise(void)
{ {
/* Try to open the device */ /* Try to open the device */
fd = open(CNF_GetRtcDevice(), O_RDWR); rtc_fd = open(CNF_GetRtcDevice(), O_RDWR);
if (fd < 0) { if (rtc_fd < 0) {
LOG(LOGS_ERR, "Could not open RTC device %s : %s", LOG(LOGS_ERR, "Could not open RTC device %s : %s",
CNF_GetRtcDevice(), strerror(errno)); CNF_GetRtcDevice(), strerror(errno));
return 0; return 0;
} }
/* Make sure the RTC supports interrupts */ /* Make sure the RTC supports interrupts */
if (!RTC_Linux_SwitchInterrupt(fd, 1) || !RTC_Linux_SwitchInterrupt(fd, 0)) { if (!RTC_Linux_SwitchInterrupt(rtc_fd, 1) || !RTC_Linux_SwitchInterrupt(rtc_fd, 0)) {
close(fd); close(rtc_fd);
return 0; return 0;
} }
/* Close on exec */ /* Close on exec */
UTI_FdSetCloexec(fd); UTI_FdSetCloexec(rtc_fd);
rtc_sec = MallocArray(time_t, MAX_SAMPLES); rtc_sec = MallocArray(time_t, MAX_SAMPLES);
system_times = MallocArray(struct timespec, MAX_SAMPLES); system_times = MallocArray(struct timespec, MAX_SAMPLES);
@@ -557,7 +557,7 @@ RTC_Linux_Initialise(void)
operating_mode = OM_NORMAL; operating_mode = OM_NORMAL;
/* Register file handler */ /* Register file handler */
SCH_AddFileHandler(fd, SCH_FILE_INPUT, read_from_device, NULL); SCH_AddFileHandler(rtc_fd, SCH_FILE_INPUT, read_from_device, NULL);
/* Register slew handler */ /* Register slew handler */
LCL_AddParameterChangeHandler(slew_samples, NULL); LCL_AddParameterChangeHandler(slew_samples, NULL);
@@ -577,10 +577,10 @@ RTC_Linux_Finalise(void)
timeout_id = 0; timeout_id = 0;
/* Remove input file handler */ /* Remove input file handler */
if (fd >= 0) { if (rtc_fd >= 0) {
SCH_RemoveFileHandler(fd); SCH_RemoveFileHandler(rtc_fd);
RTC_Linux_SwitchInterrupt(fd, 0); RTC_Linux_SwitchInterrupt(rtc_fd, 0);
close(fd); close(rtc_fd);
/* Save the RTC data */ /* Save the RTC data */
(void) RTC_Linux_WriteParameters(); (void) RTC_Linux_WriteParameters();
@@ -600,7 +600,7 @@ static void
measurement_timeout(void *any) measurement_timeout(void *any)
{ {
timeout_id = 0; timeout_id = 0;
RTC_Linux_SwitchInterrupt(fd, 1); RTC_Linux_SwitchInterrupt(rtc_fd, 1);
} }
/* ================================================== */ /* ================================================== */
@@ -613,7 +613,7 @@ set_rtc(time_t new_rtc_time)
rtc_from_t(&new_rtc_time, &rtc_raw, rtc_on_utc); rtc_from_t(&new_rtc_time, &rtc_raw, rtc_on_utc);
status = ioctl(fd, RTC_SET_TIME, &rtc_raw); status = ioctl(rtc_fd, RTC_SET_TIME, &rtc_raw);
if (status < 0) { if (status < 0) {
LOG(LOGS_ERR, "Could not set RTC time"); LOG(LOGS_ERR, "Could not set RTC time");
} }
@@ -810,25 +810,26 @@ RTC_Linux_ReadTimeAfterInterrupt(int fd, int utc,
} }
static void static void
read_from_device(int fd_, int event, void *any) read_from_device(int fd, int event, void *any)
{ {
struct timespec sys_time; struct timespec sys_time;
int status, error = 0; int status, error = 0;
time_t rtc_t; time_t rtc_t;
status = RTC_Linux_CheckInterrupt(fd); status = RTC_Linux_CheckInterrupt(rtc_fd);
if (status < 0) { if (status < 0) {
SCH_RemoveFileHandler(fd); SCH_RemoveFileHandler(rtc_fd);
RTC_Linux_SwitchInterrupt(fd, 0); /* Likely to raise error too, but just to be sure... */ /* Likely to raise error too, but just to be sure... */
close(fd); RTC_Linux_SwitchInterrupt(rtc_fd, 0);
fd = -1; close(rtc_fd);
rtc_fd = -1;
return; return;
} else if (status == 0) { } else if (status == 0) {
/* Wait for the next interrupt, this one may be bogus */ /* Wait for the next interrupt, this one may be bogus */
return; return;
} }
rtc_t = RTC_Linux_ReadTimeAfterInterrupt(fd, rtc_on_utc, &sys_time, NULL); rtc_t = RTC_Linux_ReadTimeAfterInterrupt(rtc_fd, rtc_on_utc, &sys_time, NULL);
if (rtc_t == (time_t)-1) { if (rtc_t == (time_t)-1) {
error = 1; error = 1;
goto turn_off_interrupt; goto turn_off_interrupt;
@@ -857,7 +858,7 @@ turn_off_interrupt:
operating_mode = OM_NORMAL; operating_mode = OM_NORMAL;
(after_init_hook)(after_init_hook_arg); (after_init_hook)(after_init_hook_arg);
RTC_Linux_SwitchInterrupt(fd, 0); RTC_Linux_SwitchInterrupt(rtc_fd, 0);
timeout_id = SCH_AddTimeoutByDelay((double) measurement_period, measurement_timeout, NULL); timeout_id = SCH_AddTimeoutByDelay((double) measurement_period, measurement_timeout, NULL);
} }
@@ -869,7 +870,7 @@ turn_off_interrupt:
DEBUG_LOG("Could not complete after trim relock due to errors"); DEBUG_LOG("Could not complete after trim relock due to errors");
operating_mode = OM_NORMAL; operating_mode = OM_NORMAL;
RTC_Linux_SwitchInterrupt(fd, 0); RTC_Linux_SwitchInterrupt(rtc_fd, 0);
timeout_id = SCH_AddTimeoutByDelay((double) measurement_period, measurement_timeout, NULL); timeout_id = SCH_AddTimeoutByDelay((double) measurement_period, measurement_timeout, NULL);
} }
@@ -877,7 +878,7 @@ turn_off_interrupt:
break; break;
case OM_NORMAL: case OM_NORMAL:
RTC_Linux_SwitchInterrupt(fd, 0); RTC_Linux_SwitchInterrupt(rtc_fd, 0);
timeout_id = SCH_AddTimeoutByDelay((double) measurement_period, measurement_timeout, NULL); timeout_id = SCH_AddTimeoutByDelay((double) measurement_period, measurement_timeout, NULL);
@@ -899,7 +900,7 @@ RTC_Linux_TimeInit(void (*after_hook)(void *), void *anything)
operating_mode = OM_INITIAL; operating_mode = OM_INITIAL;
timeout_id = 0; timeout_id = 0;
RTC_Linux_SwitchInterrupt(fd, 1); RTC_Linux_SwitchInterrupt(rtc_fd, 1);
} }
/* ================================================== */ /* ================================================== */
@@ -917,7 +918,7 @@ RTC_Linux_WriteParameters(void)
{ {
int retval; int retval;
if (fd < 0) { if (rtc_fd < 0) {
return RTC_ST_NODRV; return RTC_ST_NODRV;
} }
@@ -1086,7 +1087,7 @@ RTC_Linux_Trim(void)
/* And start rapid sampling, interrupts on now */ /* And start rapid sampling, interrupts on now */
SCH_RemoveTimeout(timeout_id); SCH_RemoveTimeout(timeout_id);
timeout_id = 0; timeout_id = 0;
RTC_Linux_SwitchInterrupt(fd, 1); RTC_Linux_SwitchInterrupt(rtc_fd, 1);
} }
return 1; return 1;

View File

@@ -94,7 +94,7 @@ static int current_delta_tick;
static int max_tick_bias; static int max_tick_bias;
/* The kernel USER_HZ constant */ /* The kernel USER_HZ constant */
static int hz; static int sys_hz;
static double dhz; /* And dbl prec version of same for arithmetic */ static double dhz; /* And dbl prec version of same for arithmetic */
/* The assumed rate at which the effective frequency and tick values are /* The assumed rate at which the effective frequency and tick values are
@@ -149,8 +149,8 @@ set_frequency(double freq_ppm)
USER_HZ <= 250, the maximum frequency adjustment of 500 ppm overlaps at USER_HZ <= 250, the maximum frequency adjustment of 500 ppm overlaps at
least two ticks and we can stick to the current tick if it's next to the least two ticks and we can stick to the current tick if it's next to the
required tick. */ required tick. */
if (hz <= 250 && (required_delta_tick + 1 == current_delta_tick || if (sys_hz <= 250 && (required_delta_tick + 1 == current_delta_tick ||
required_delta_tick - 1 == current_delta_tick)) { required_delta_tick - 1 == current_delta_tick)) {
required_delta_tick = current_delta_tick; required_delta_tick = current_delta_tick;
} }
@@ -278,13 +278,14 @@ get_kernel_version(int *major, int *minor, int *patch)
static void static void
get_version_specific_details(void) get_version_specific_details(void)
{ {
int major, minor, patch; int hz, major, minor, patch;
hz = get_hz(); hz = get_hz();
if (!hz) if (!hz)
hz = guess_hz(); hz = guess_hz();
sys_hz = hz;
dhz = (double) hz; dhz = (double) hz;
nominal_tick = (1000000L + (hz/2))/hz; /* Mirror declaration in kernel */ nominal_tick = (1000000L + (hz/2))/hz; /* Mirror declaration in kernel */
max_tick_bias = nominal_tick / 10; max_tick_bias = nominal_tick / 10;

View File

@@ -115,20 +115,20 @@ read_timeout(void *arg)
} }
static void static void
read_points(const char *filename) read_points(const char *path)
{ {
FILE *f; FILE *f;
char line[256]; char line[256];
struct Point *p; struct Point *p;
f = UTI_OpenFile(NULL, filename, NULL, 'R', 0); f = UTI_OpenFile(NULL, path, NULL, 'R', 0);
points = ARR_CreateInstance(sizeof (struct Point)); points = ARR_CreateInstance(sizeof (struct Point));
while (fgets(line, sizeof (line), f)) { while (fgets(line, sizeof (line), f)) {
p = (struct Point *)ARR_GetNewElement(points); p = (struct Point *)ARR_GetNewElement(points);
if (sscanf(line, "%lf %lf", &p->temp, &p->comp) != 2) { if (sscanf(line, "%lf %lf", &p->temp, &p->comp) != 2) {
LOG_FATAL("Could not read tempcomp point from %s", filename); LOG_FATAL("Could not read tempcomp point from %s", path);
break; break;
} }
} }
@@ -136,7 +136,7 @@ read_points(const char *filename)
fclose(f); fclose(f);
if (ARR_GetSize(points) < 2) if (ARR_GetSize(points) < 2)
LOG_FATAL("Not enough points in %s", filename); LOG_FATAL("Not enough points in %s", path);
} }
void void

View File

@@ -84,7 +84,7 @@ uint32_t write_random_key(FILE *f)
} }
static void static void
generate_key_file(const char *name, uint32_t *keys) generate_key_file(const char *name, uint32_t *key_ids)
{ {
FILE *f; FILE *f;
int i; int i;
@@ -92,7 +92,7 @@ generate_key_file(const char *name, uint32_t *keys)
f = fopen(name, "w"); f = fopen(name, "w");
TEST_CHECK(f); TEST_CHECK(f);
for (i = 0; i < KEYS; i++) for (i = 0; i < KEYS; i++)
keys[i] = write_random_key(f); key_ids[i] = write_random_key(f);
fclose(f); fclose(f);
} }
@@ -100,7 +100,7 @@ void
test_unit(void) test_unit(void)
{ {
int i, j, data_len, auth_len, type, bits, s, timing_fails, timing_iters; int i, j, data_len, auth_len, type, bits, s, timing_fails, timing_iters;
uint32_t keys[KEYS], key; uint32_t key_ids[KEYS], key;
unsigned char data[100], auth[MAX_HASH_LENGTH], auth2[MAX_HASH_LENGTH]; unsigned char data[100], auth[MAX_HASH_LENGTH], auth2[MAX_HASH_LENGTH];
struct timespec ts1, ts2; struct timespec ts1, ts2;
double diff1, diff2; double diff1, diff2;
@@ -113,41 +113,41 @@ test_unit(void)
CNF_ParseLine(NULL, i + 1, conf[i]); CNF_ParseLine(NULL, i + 1, conf[i]);
LCL_Initialise(); LCL_Initialise();
generate_key_file(KEYFILE, keys); generate_key_file(KEYFILE, key_ids);
KEY_Initialise(); KEY_Initialise();
for (i = 0; i < 100; i++) { for (i = 0; i < 100; i++) {
DEBUG_LOG("iteration %d", i); DEBUG_LOG("iteration %d", i);
if (i) { if (i) {
generate_key_file(KEYFILE, keys); generate_key_file(KEYFILE, key_ids);
KEY_Reload(); KEY_Reload();
} }
UTI_GetRandomBytes(data, sizeof (data)); UTI_GetRandomBytes(data, sizeof (data));
for (j = 0; j < KEYS; j++) { for (j = 0; j < KEYS; j++) {
TEST_CHECK(KEY_KeyKnown(keys[j])); TEST_CHECK(KEY_KeyKnown(key_ids[j]));
TEST_CHECK(KEY_GetAuthLength(keys[j]) >= 16); TEST_CHECK(KEY_GetAuthLength(key_ids[j]) >= 16);
data_len = random() % (sizeof (data) + 1); data_len = random() % (sizeof (data) + 1);
auth_len = KEY_GenerateAuth(keys[j], data, data_len, auth, sizeof (auth)); auth_len = KEY_GenerateAuth(key_ids[j], data, data_len, auth, sizeof (auth));
TEST_CHECK(auth_len >= 16); TEST_CHECK(auth_len >= 16);
TEST_CHECK(KEY_CheckAuth(keys[j], data, data_len, auth, auth_len, auth_len)); TEST_CHECK(KEY_CheckAuth(key_ids[j], data, data_len, auth, auth_len, auth_len));
if (j > 0 && keys[j - 1] != keys[j]) if (j > 0 && key_ids[j - 1] != key_ids[j])
TEST_CHECK(!KEY_CheckAuth(keys[j - 1], data, data_len, auth, auth_len, auth_len)); TEST_CHECK(!KEY_CheckAuth(key_ids[j - 1], data, data_len, auth, auth_len, auth_len));
auth_len = random() % auth_len + 1; auth_len = random() % auth_len + 1;
if (auth_len < MAX_HASH_LENGTH) if (auth_len < MAX_HASH_LENGTH)
auth[auth_len]++; auth[auth_len]++;
TEST_CHECK(KEY_CheckAuth(keys[j], data, data_len, auth, auth_len, auth_len)); TEST_CHECK(KEY_CheckAuth(key_ids[j], data, data_len, auth, auth_len, auth_len));
auth[auth_len - 1]++; auth[auth_len - 1]++;
TEST_CHECK(!KEY_CheckAuth(keys[j], data, data_len, auth, auth_len, auth_len)); TEST_CHECK(!KEY_CheckAuth(key_ids[j], data, data_len, auth, auth_len, auth_len));
TEST_CHECK(KEY_GetKeyInfo(keys[j], &type, &bits)); TEST_CHECK(KEY_GetKeyInfo(key_ids[j], &type, &bits));
TEST_CHECK(type > 0 && bits > 0); TEST_CHECK(type > 0 && bits > 0);
} }

View File

@@ -134,13 +134,13 @@ verify_message(NKSN_Instance inst)
static int static int
handle_request(void *arg) handle_request(void *arg)
{ {
NKSN_Instance server = arg; NKSN_Instance inst = arg;
verify_message(server); verify_message(inst);
request_received = 1; request_received = 1;
send_message(server); send_message(inst);
return 1; return 1;
} }
@@ -148,11 +148,11 @@ handle_request(void *arg)
static int static int
handle_response(void *arg) handle_response(void *arg)
{ {
NKSN_Instance client = arg; NKSN_Instance inst = arg;
response_received = 1; response_received = 1;
verify_message(client); verify_message(inst);
return 1; return 1;
} }