Skip to content

Commit

Permalink
Fix a few minor typos
Browse files Browse the repository at this point in the history
  • Loading branch information
petabyt committed Nov 17, 2023
1 parent a1a047e commit c2f3182
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/camlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ struct PtpRuntime {
// Set to 1 to kill all IO operations. By default, this is 1. When a valid connection
// is achieved by libusb, libwpd, and tcp backends, it will be set to 0. On IO error, it
// will be set to 1.
// TODO: Should the IO backend toggle the IO kill switch
uint8_t io_kill_switch;

// Is set to USB by default
Expand Down
2 changes: 1 addition & 1 deletion src/canon_adv.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ int ptp_eos_evproc_run(struct PtpRuntime *r, char *fmt, ...) {
return PTP_RUNTIME_ERR;
}

rc = ptp_eos_exec_evproc(r, data, length, 1);
rc = ptp_eos_exec_evproc(r, data, length, 0);
if (rc) {
return rc;
}
Expand Down
3 changes: 1 addition & 2 deletions src/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
#include <camlib.h>
#include <ptp.h>

// Reset all fields of PtpRuntime - this must be updated when new fields are added
// Reset all fields of PtpRuntime - use this before reconnecting
void ptp_generic_reset(struct PtpRuntime *r) {
r->io_kill_switch = 1;
r->transaction = 0;
r->session = 0;
r->connection_type = PTP_USB;
r->caller_unlocks_mutex = 0;
r->mutex = NULL;
r->wait_for_response = 1;
}

Expand Down
6 changes: 5 additions & 1 deletion src/libusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ struct LibUSBBackend {
libusb_device_handle *handle;
};

// TODO: If this is accidentally called in the middle of a connection, it will cause a huge fault
int ptp_comm_init(struct PtpRuntime *r) {
ptp_generic_reset(r);

Expand Down Expand Up @@ -268,7 +269,10 @@ int ptp_device_reset(struct PtpRuntime *r) {

int ptp_cmd_write(struct PtpRuntime *r, void *to, int length) {
struct LibUSBBackend *backend = (struct LibUSBBackend *)r->comm_backend;
if (backend == NULL || r->io_kill_switch) return -1;
if (backend == NULL || r->io_kill_switch) {
puts("KIll switch");
return -1;
}
int transferred;
int rc = libusb_bulk_transfer(
backend->handle,
Expand Down
2 changes: 1 addition & 1 deletion src/libwpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ int ptp_comm_init(struct PtpRuntime *r) {
r->comm_backend = malloc(sizeof(struct WpdStruct));

// We are not using low-level I/O operations, so this is never used
r->r->max_packet_size = 512;
r->max_packet_size = 512;

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ int ptpusb_read_all_packets(struct PtpRuntime *r) {
r->wait_for_response = 1;

if (rc < 0) {
ptp_verbose_log("Failed to read packets: %d\n");
ptp_verbose_log("Failed to read packets: %d\n", rc);
return PTP_IO_ERR;
}

Expand Down

0 comments on commit c2f3182

Please sign in to comment.