fastboot: Cleanup and fix crash

Clean up some old and broken code in the fastboot implementation.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
This commit is contained in:
Bjorn Andersson
2018-03-12 14:28:55 -07:00
parent 7a5b4334a1
commit 1ea73dfbed
2 changed files with 2 additions and 3 deletions

View File

@@ -77,7 +77,7 @@ static int fastboot_read(struct fastboot *fb, char *buf, size_t len)
}
return n - 4;
} else if (strncmp(status, "FAIL", 4) == 0) {
fb->ops->tty_write(status + 4, n - 4, true);
fprintf(stderr, "%s\n", status + 4);
return -ENXIO;
} else if (strncmp(status, "DATA", 4) == 0) {
return strtol(status + 4, NULL, 16);
@@ -267,7 +267,7 @@ static int handle_udev_event(int fd, void *data)
if (fastboot->ops && fastboot->ops->opened)
fastboot->ops->opened(fastboot, fastboot->data);
} else if (!strcmp(action, "remove")) {
if (strcmp(dev_path, fastboot->dev_path))
if (!fastboot->dev_path || strcmp(dev_path, fastboot->dev_path))
goto unref_dev;
close(fastboot->fd);

View File

@@ -7,7 +7,6 @@ struct fastboot_ops {
void (*opened)(struct fastboot *, void *);
void (*disconnect)(void *);
void (*info)(struct fastboot *, const void *, size_t);
ssize_t (*tty_write)(const void *, size_t, bool);
};
struct fastboot *fastboot_open(const char *serial, struct fastboot_ops *ops, void *);