From: Michael Gernoth Date: Sun, 16 Feb 2014 08:27:24 +0000 (+0100) Subject: more minor cleanups X-Git-Tag: v0.100~33 X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/hmcfgusb/commitdiff_plain/268d2cc6b55cc9e0eeace4fccc59d585399b8da7?hp=da4ab9712d756cdf258cc51c6d3ced0fb5826fc6 more minor cleanups --- diff --git a/flash-ota.c b/flash-ota.c index 1fd11d8..f8431a6 100644 --- a/flash-ota.c +++ b/flash-ota.c @@ -121,7 +121,7 @@ int send_hm_message(struct hmcfgusb_dev *dev, struct recv_data *rdata, uint8_t * memcpy(&out[0x0f], msg, msg[0] + 1); memset(rdata, 0, sizeof(struct recv_data)); - hmcfgusb_send(dev, out, sizeof(out), 2); + hmcfgusb_send(dev, out, sizeof(out), 1); while (1) { if (rdata->message_type == MESSAGE_TYPE_R) { @@ -129,7 +129,7 @@ int send_hm_message(struct hmcfgusb_dev *dev, struct recv_data *rdata, uint8_t * ((rdata->status & 0xff) == 0x02)) { break; } else { - fprintf(stderr, "\n\nInvalid status: %04x\n\n", rdata->status); + fprintf(stderr, "\nInvalid status: %04x\n", rdata->status); return 0; } } @@ -158,7 +158,7 @@ static int switch_speed(struct hmcfgusb_dev *dev, struct recv_data *rdata, uint8 out[0] = 'G'; out[1] = speed; - hmcfgusb_send(dev, out, sizeof(out), 2); + hmcfgusb_send(dev, out, sizeof(out), 1); while (1) { errno = 0; @@ -271,7 +271,7 @@ int main(int argc, char **argv) out[2] = (hmid >> 8) & 0xff; out[3] = hmid & 0xff; - hmcfgusb_send(dev, out, sizeof(out), 2); + hmcfgusb_send(dev, out, sizeof(out), 1); switchcnt = 3; do { @@ -330,6 +330,10 @@ int main(int argc, char **argv) } } while ((!switched) && (switchcnt--)); + if (!switched) { + fprintf(stderr, "Too many errors, giving up!\n"); + exit(EXIT_FAILURE); + } printf("Yes!\n");