Check the return value of I/O operations for failure
This commit is contained in:
parent
f066db7fcd
commit
ea83cedcf6
3 changed files with 13 additions and 5 deletions
|
@ -65,7 +65,9 @@ HexFile::loadSections(Port *memPort)
|
||||||
Addr MemAddr;
|
Addr MemAddr;
|
||||||
uint32_t Data;
|
uint32_t Data;
|
||||||
while (!feof(fp)) {
|
while (!feof(fp)) {
|
||||||
fgets(Line, 64, fp);
|
char *ret = fgets(Line, sizeof(Line), fp);
|
||||||
|
if (!ret)
|
||||||
|
panic("malformed file");
|
||||||
parseLine(Line, &MemAddr, &Data);
|
parseLine(Line, &MemAddr, &Data);
|
||||||
if (MemAddr != 0) {
|
if (MemAddr != 0) {
|
||||||
// Now, write to memory
|
// Now, write to memory
|
||||||
|
|
|
@ -346,14 +346,16 @@ uint8_t
|
||||||
BaseRemoteGDB::getbyte()
|
BaseRemoteGDB::getbyte()
|
||||||
{
|
{
|
||||||
uint8_t b;
|
uint8_t b;
|
||||||
::read(fd, &b, 1);
|
if (::read(fd, &b, 1) != 1)
|
||||||
|
warn("could not read byte from debugger");
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BaseRemoteGDB::putbyte(uint8_t b)
|
BaseRemoteGDB::putbyte(uint8_t b)
|
||||||
{
|
{
|
||||||
::write(fd, &b, 1);
|
if (::write(fd, &b, 1) != 1)
|
||||||
|
warn("could not write byte to debugger");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send a packet to gdb
|
// Send a packet to gdb
|
||||||
|
|
|
@ -182,8 +182,12 @@ EtherTap::recvPacket(EthPacketPtr packet)
|
||||||
DPRINTF(Ethernet, "EtherTap output len=%d\n", packet->length);
|
DPRINTF(Ethernet, "EtherTap output len=%d\n", packet->length);
|
||||||
DDUMP(EthernetData, packet->data, packet->length);
|
DDUMP(EthernetData, packet->data, packet->length);
|
||||||
uint32_t len = htonl(packet->length);
|
uint32_t len = htonl(packet->length);
|
||||||
write(socket, &len, sizeof(len));
|
ssize_t ret = write(socket, &len, sizeof(len));
|
||||||
write(socket, packet->data, packet->length);
|
if (ret != sizeof(len))
|
||||||
|
return false;
|
||||||
|
ret = write(socket, packet->data, packet->length);
|
||||||
|
if (ret != packet->length)
|
||||||
|
return false;
|
||||||
|
|
||||||
interface->recvDone();
|
interface->recvDone();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue