Merge pull request #87 from riscv/gdb_next_port

When gdb_port is 0, don't increment it.
FE_402_fix
Tim Newsome 2017-08-08 10:01:26 -07:00 committed by GitHub
commit 97ea54030c
2 changed files with 9 additions and 2 deletions

View File

@ -3113,7 +3113,13 @@ static int gdb_target_add_one(struct target *target)
if (!*end) {
if (parse_long(gdb_port_next, &portnumber) == ERROR_OK) {
free(gdb_port_next);
if (portnumber) {
gdb_port_next = alloc_printf("%d", portnumber+1);
} else {
/* Don't increment if gdb_port is 0, since we're just
* trying to allocate an unused port. */
gdb_port_next = alloc_printf("0");
}
}
}
}

View File

@ -273,7 +273,8 @@ int add_service(char *name,
c->sin.sin_port = htons(c->portnumber);
if (bind(c->fd, (struct sockaddr *)&c->sin, sizeof(c->sin)) == -1) {
LOG_ERROR("couldn't bind %s to socket: %s", name, strerror(errno));
LOG_ERROR("couldn't bind %s to socket on port %d: %s", name,
c->portnumber, strerror(errno));
close_socket(c->fd);
free_service(c);
return ERROR_FAIL;