Skip to content

Commit

Permalink
raop_ntp.c, utils.c : fixes #192
Browse files Browse the repository at this point in the history
  • Loading branch information
fduncanh committed Apr 18, 2023
1 parent 803217c commit 0b9e2a6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 6 additions & 6 deletions lib/raop_ntp.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,14 @@ raop_ntp_thread(void *arg)
// Send request
uint64_t send_time = raop_ntp_get_local_time(raop_ntp);
byteutils_put_ntp_timestamp(request, 24, send_time);
if (logger_debug) {
char *str = utils_data_to_string(request, sizeof(request), 16);
logger_log(raop_ntp->logger, LOGGER_DEBUG, "\nraop_ntp send time type_t=%d packetlen = %d, now = %8.6f\n%s",
request[1] &~0x80, sizeof(request), (double) send_time / SECOND_IN_NSECS, str);
free(str);
}
int send_len = sendto(raop_ntp->tsock, (char *)request, sizeof(request), 0,
(struct sockaddr *) &raop_ntp->remote_saddr, raop_ntp->remote_saddr_len);
if (logger_debug) {
char *str = utils_data_to_string(request, send_len, 16);
logger_log(raop_ntp->logger, LOGGER_DEBUG, "\nraop_ntp send time type_t=%d send_len = %d, now = %8.6f\n%s",
request[1] &~0x80, send_len, (double) send_time / SECOND_IN_NSECS, str);
free(str);
}
if (send_len < 0) {
logger_log(raop_ntp->logger, LOGGER_ERR, "raop_ntp error sending request");
} else {
Expand Down
3 changes: 2 additions & 1 deletion lib/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ char *utils_parse_hex(const char *str, int str_len, int *data_len) {
}

char *utils_data_to_string(const unsigned char *data, int datalen, int chars_per_line) {
int len = 3*datalen + ((datalen-1)/chars_per_line ) + 1;
assert(datalen > 0);
int len = 3*datalen + ((datalen-1)/chars_per_line ) + 1;
char *str = (char *) calloc(len + 1, sizeof(char));
assert(str);
char *p = str;
Expand Down

0 comments on commit 0b9e2a6

Please sign in to comment.