The tracecmd_tsync_proto_getall () function returns a bitmask of all registered timestamp synchronization plugins, which match given criteria. There was a bug in that logic - it was working with wrong bitmask size, which leads to broken bitmask. Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@xxxxxxxxx> --- lib/trace-cmd/trace-timesync.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/trace-cmd/trace-timesync.c b/lib/trace-cmd/trace-timesync.c index 10ab82f0..2fbb319b 100644 --- a/lib/trace-cmd/trace-timesync.c +++ b/lib/trace-cmd/trace-timesync.c @@ -217,21 +217,21 @@ int tracecmd_tsync_proto_getall(char **proto_mask, int *words, const char *clock if (proto->proto_id > proto_max) proto_max = proto->proto_id; - count = proto_max / PROTO_MASK_SIZE + 1; - protos = calloc(count, sizeof(char)); + count = proto_max / PROTO_MASK_BITS + 1; + protos = calloc(count, PROTO_MASK_SIZE); if (!protos) return -1; for (proto = tsync_proto_list; proto; proto = proto->next) { - if ((proto->proto_id / PROTO_MASK_SIZE) >= count) + if ((proto->proto_id / PROTO_MASK_BITS) >= count) continue; if (!(proto->roles & role)) continue; if (proto->supported_clocks && clock_id && !(proto->supported_clocks & clock_id)) continue; - protos[proto->proto_id / PROTO_MASK_SIZE] |= - (1 << (proto->proto_id % PROTO_MASK_SIZE)); + protos[proto->proto_id / PROTO_MASK_BITS] |= + (1 << (proto->proto_id % PROTO_MASK_BITS)); } *proto_mask = protos; -- 2.26.2