From: Miroslav Lichvar Date: Fri, 14 Jun 2013 17:18:36 +0000 (+0200) Subject: Fix printing of negative offset with settime command X-Git-Tag: 1.28-pre1~24 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=0193688671d92cc54193087a9d13ab82c0de78c4;p=thirdparty%2Fchrony.git Fix printing of negative offset with settime command --- diff --git a/client.c b/client.c index d247977f..99d33a5f 100644 --- a/client.c +++ b/client.c @@ -2356,7 +2356,7 @@ process_cmd_settime(char *line) request.command = htons(REQ_SETTIME); if (request_reply(&request, &reply, RPY_MANUAL_TIMESTAMP, 1)) { offset_cs = ntohl(reply.data.manual_timestamp.centiseconds); - offset = 0.01 * (double) offset_cs; + offset = 0.01 * (double)(int32_t)offset_cs; dfreq_ppm = UTI_FloatNetworkToHost(reply.data.manual_timestamp.dfreq_ppm); new_afreq_ppm = UTI_FloatNetworkToHost(reply.data.manual_timestamp.new_afreq_ppm); printf("Clock was %.2f seconds fast. Frequency change = %.2fppm, new frequency = %.2fppm\n", diff --git a/cmdmon.c b/cmdmon.c index b61e776a..f0eeb7cd 100644 --- a/cmdmon.c +++ b/cmdmon.c @@ -950,7 +950,7 @@ handle_settime(CMD_Request *rx_message, CMD_Reply *tx_message) if (MNL_AcceptTimestamp(&ts, &offset_cs, &dfreq_ppm, &new_afreq_ppm)) { tx_message->status = htons(STT_SUCCESS); tx_message->reply = htons(RPY_MANUAL_TIMESTAMP); - tx_message->data.manual_timestamp.centiseconds = htonl(offset_cs); + tx_message->data.manual_timestamp.centiseconds = htonl((int32_t)offset_cs); tx_message->data.manual_timestamp.dfreq_ppm = UTI_FloatHostToNetwork(dfreq_ppm); tx_message->data.manual_timestamp.new_afreq_ppm = UTI_FloatHostToNetwork(new_afreq_ppm); } else {