if (s == (uint32_t)-1) {
printf(" -");
} else if (s < 1200) {
- printf("%4ld", s);
+ printf("%4lu", s);
} else if (s < 36000) {
- printf("%3ldm", s / 60);
+ printf("%3lum", s / 60);
} else if (s < 345600) {
- printf("%3ldh", s / 3600);
+ printf("%3luh", s / 3600);
} else {
d = s / 86400;
if (d > 999) {
- printf("%3ldy", d / 365);
+ printf("%3luy", d / 365);
} else {
- printf("%3ldd", d);
+ printf("%3lud", d);
}
}
}
snprintf(hash_name, sizeof (hash_name), "MD5");
#endif
- if (sscanf(line, "%u %16s %d", &id, hash_name, &bits))
+ if (sscanf(line, "%u %16s %u", &id, hash_name, &bits))
;
length = CLAMP(10, (bits + 7) / 8, sizeof (key));
continue;
if (!CPS_ParseKey(line, &key_id, &hashname, &keyval)) {
- LOG(LOGS_WARN, "Could not parse key at line %d in file %s", line_number, key_file);
+ LOG(LOGS_WARN, "Could not parse key at line %u in file %s", line_number, key_file);
continue;
}
/* It's not a reply to our request, don't return success */
return 0;
} else {
- DEBUG_LOG("NTP packet discarded pkt_mode=%d our_mode=%d", pkt_mode, inst->mode);
+ DEBUG_LOG("NTP packet discarded pkt_mode=%d our_mode=%u", pkt_mode, inst->mode);
return 0;
}
}
/* Fall through */
default:
/* Discard */
- DEBUG_LOG("NTP packet discarded pkt_mode=%d", pkt_mode);
+ DEBUG_LOG("NTP packet discarded pkt_mode=%u", pkt_mode);
return;
}
break;
default:
/* Discard packets in other modes */
- DEBUG_LOG("NTP packet discarded auth_mode=%d", auth_mode);
+ DEBUG_LOG("NTP packet discarded auth_mode=%u", auth_mode);
return;
}
}
return;
#endif
- DEBUG_LOG("Received %d bytes from %s:%d to %s fd=%d if=%d tss=%d delay=%.9f",
+ DEBUG_LOG("Received %d bytes from %s:%d to %s fd=%d if=%d tss=%u delay=%.9f",
length, UTI_IPToString(&remote_addr.ip_addr), remote_addr.port,
UTI_IPToString(&local_addr.ip_addr), local_addr.sock_fd, local_addr.if_index,
local_ts.source, UTI_DiffTimespecsToDouble(&sched_ts, &local_ts.ts));
return 0;
if (setsockopt(sock_fd, SOL_SOCKET, SO_TIMESTAMPING, &option, sizeof (option)) < 0) {
- DEBUG_LOG("Could not enable timestamping option %x", option);
+ DEBUG_LOG("Could not enable timestamping option %x", (unsigned int)option);
close(sock_fd);
return 0;
}
l2_length = length;
length = extract_udp_data(hdr->msg_iov[0].iov_base, remote_addr, length);
- DEBUG_LOG("Received %d (%d) bytes from error queue for %s:%d fd=%d if=%d tss=%d",
+ DEBUG_LOG("Received %d (%d) bytes from error queue for %s:%d fd=%d if=%d tss=%u",
l2_length, length, UTI_IPToString(&remote_addr->ip_addr), remote_addr->port,
local_addr->sock_fd, local_addr->if_index, local_ts->source);
if (sample.magic != SOCK_MAGIC) {
LOG(LOGS_WARN, "Unexpected magic number in SOCK sample : %x != %x",
- sample.magic, SOCK_MAGIC);
+ (unsigned int)sample.magic, (unsigned int)SOCK_MAGIC);
return;
}
}
DEBUG_LOG("badstat=%d sel=%d badstat_reach=%x sel_reach=%x max_reach_ago=%f",
- n_badstats_sources, n_sel_sources, max_badstat_reach,
- max_sel_reach, max_reach_sample_ago);
+ n_badstats_sources, n_sel_sources, (unsigned int)max_badstat_reach,
+ (unsigned int)max_sel_reach, max_reach_sample_ago);
/* Wait for the next call if we have no source selected and there is
a source with bad stats (has less than 3 samples) with reachability
sources[i]->sel_score = 1.0 / distance;
}
- DEBUG_LOG("select score=%f refid=%"PRIx32" match_refid=%"PRIx32" status=%d dist=%f",
+ DEBUG_LOG("select score=%f refid=%"PRIx32" match_refid=%"PRIx32" status=%u dist=%f",
sources[i]->sel_score, sources[i]->ref_id,
updated_inst ? updated_inst->ref_id : 0,
sources[i]->status, distance);
}
}
- DEBUG_LOG("records %d", ARR_GetSize(records));
+ DEBUG_LOG("records %u", ARR_GetSize(records));
TEST_CHECK(ARR_GetSize(records) == 64);
for (i = j = 0; i < 10000; i++) {
j++;
}
- DEBUG_LOG("requests %u responses %u", i, j);
+ DEBUG_LOG("requests %d responses %d", i, j);
TEST_CHECK(j * 4 < i && j * 6 > i);
CLG_Finalise();
double passed_lo = DBL_MAX, passed_hi = DBL_MIN;
SRC_SelectSource(srcs[k]);
- DEBUG_LOG("source %d status %d", k, sources[k]->status);
+ DEBUG_LOG("source %d status %u", k, sources[k]->status);
for (l = 0; l <= j; l++) {
TEST_CHECK(sources[l]->status > SRC_OK && sources[l]->status <= SRC_SELECTED);
b = (ip>>16) & 0xff;
c = (ip>> 8) & 0xff;
d = (ip>> 0) & 0xff;
- snprintf(result, BUFFER_LENGTH, "%ld.%ld.%ld.%ld", a, b, c, d);
+ snprintf(result, BUFFER_LENGTH, "%lu.%lu.%lu.%lu", a, b, c, d);
break;
case IPADDR_INET6:
ip6 = addr->addr.in6;
#ifdef FEAT_IPV6
inet_ntop(AF_INET6, ip6, result, BUFFER_LENGTH);
#else
- snprintf(result, BUFFER_LENGTH, "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
- ip6[0], ip6[1], ip6[2], ip6[3], ip6[4], ip6[5], ip6[6], ip6[7],
- ip6[8], ip6[9], ip6[10], ip6[11], ip6[12], ip6[13], ip6[14], ip6[15]);
+ assert(BUFFER_LENGTH >= 40);
+ for (a = 0; a < 8; a++)
+ snprintf(result + a * 5, 40 - a * 5, "%04x:",
+ (unsigned int)(ip6[2 * a] << 8 | ip6[2 * a + 1]));
#endif
break;
default:
}
if (buf.st_uid != uid) {
- LOG(LOGS_ERR, "Wrong owner of %s (%s != %d)", path, "UID", uid);
+ LOG(LOGS_ERR, "Wrong owner of %s (%s != %u)", path, "UID", uid);
return 0;
}
if (buf.st_gid != gid) {
- LOG(LOGS_ERR, "Wrong owner of %s (%s != %d)", path, "GID", gid);
+ LOG(LOGS_ERR, "Wrong owner of %s (%s != %u)", path, "GID", gid);
return 0;
}
/* Set effective, saved and real group ID */
if (setgid(gid))
- LOG_FATAL("setgid(%d) failed : %s", gid, strerror(errno));
+ LOG_FATAL("setgid(%u) failed : %s", gid, strerror(errno));
/* Set effective, saved and real user ID */
if (setuid(uid))
- LOG_FATAL("setuid(%d) failed : %s", uid, strerror(errno));
+ LOG_FATAL("setuid(%u) failed : %s", uid, strerror(errno));
- DEBUG_LOG("Dropped root privileges: UID %d GID %d", uid, gid);
+ DEBUG_LOG("Dropped root privileges: UID %u GID %u", uid, gid);
}
/* ================================================== */