From 8e9bae0977c26942173344d08dd503d43749ccbf Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 23 Apr 2024 00:31:22 -0400 Subject: [PATCH] Fix some const casts --- src/ip.c | 2 +- src/lib.c | 15 +-------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/src/ip.c b/src/ip.c index 1bdc399..9655162 100644 --- a/src/ip.c +++ b/src/ip.c @@ -38,7 +38,7 @@ static int set_nonblocking_io(int sockfd, int enable) { return fcntl(sockfd, F_SETFL, flags); } -int ptpip_new_timeout_socket(char *addr, int port) { +int ptpip_new_timeout_socket(const char *addr, int port) { int sockfd = socket(AF_INET, SOCK_STREAM, 0); int yes = 1; diff --git a/src/lib.c b/src/lib.c index 860bae4..1db4d05 100644 --- a/src/lib.c +++ b/src/lib.c @@ -108,6 +108,7 @@ int ptp_buffer_resize(struct PtpRuntime *r, size_t size) { if (size < r->data_length) { ptp_panic("You cannot downsize the data buffer (%u -> %u)", r->data_length, size); } + // realloc with a little extra space to minimize reallocs later on static int extra = 100; ptp_verbose_log("Extending IO buffer to %X\n", size + extra); @@ -130,7 +131,6 @@ void ptp_mutex_keep_locked(struct PtpRuntime *r) { pthread_mutex_lock(r->mutex); } -// 'pop' the mutex stack, will only unlock the mutex once stack is at zero void ptp_mutex_unlock(struct PtpRuntime *r) { if (r->mutex == NULL) return; pthread_mutex_unlock(r->mutex); @@ -166,12 +166,6 @@ int ptp_send(struct PtpRuntime *r, struct PtpCommand *cmd) { return PTP_IO_ERR; } - // if (ptp_get_last_transaction_id(r) != r->transaction) { - // ptp_verbose_log("Mismatch transaction ID\n"); - // ptp_mutex_unlock(r); - // return PTP_IO_ERR; - // } - r->transaction++; if (ptp_get_return_code(r) != PTP_RC_OK) { @@ -232,13 +226,6 @@ int ptp_send_data(struct PtpRuntime *r, struct PtpCommand *cmd, void *data, int return PTP_IO_ERR; } - // TODO: doesn't work on windows (IDs are made up) - //if (ptp_get_last_transaction_id(r) != r->transaction) { - //ptp_verbose_log("ptp_send_data: Mismatch transaction ID (%d/%d)\n", ptp_get_last_transaction_id(r), r->transaction); - //ptp_mutex_unlock(r); - //return PTP_IO_ERR; - //} - r->transaction++; if (ptp_get_return_code(r) != PTP_RC_OK) {