1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 21:57:35 +00:00

Kernel: Some more int => size_t in NetworkAdapter and subclasses

This commit is contained in:
Andreas Kling 2020-01-29 18:29:04 +01:00
parent 1e948f1766
commit 164d9ecad7
8 changed files with 13 additions and 13 deletions

View file

@ -371,12 +371,12 @@ u32 E1000NetworkAdapter::in32(u16 address)
return IO::in32(m_io_base + address); return IO::in32(m_io_base + address);
} }
void E1000NetworkAdapter::send_raw(const u8* data, int length) void E1000NetworkAdapter::send_raw(const u8* data, size_t length)
{ {
disable_irq(); disable_irq();
u32 tx_current = in32(REG_TXDESCTAIL); u32 tx_current = in32(REG_TXDESCTAIL);
#ifdef E1000_DEBUG #ifdef E1000_DEBUG
kprintf("E1000: Sending packet (%d bytes)\n", length); kprintf("E1000: Sending packet (%zu bytes)\n", length);
#endif #endif
auto& descriptor = m_tx_descriptors[tx_current]; auto& descriptor = m_tx_descriptors[tx_current];
ASSERT(length <= 8192); ASSERT(length <= 8192);
@ -417,7 +417,7 @@ void E1000NetworkAdapter::receive()
auto* buffer = (u8*)(m_rx_descriptors[rx_current].addr + 0xc0000000); auto* buffer = (u8*)(m_rx_descriptors[rx_current].addr + 0xc0000000);
u16 length = m_rx_descriptors[rx_current].length; u16 length = m_rx_descriptors[rx_current].length;
#ifdef E1000_DEBUG #ifdef E1000_DEBUG
kprintf("E1000: Received 1 packet @ %p (%u) bytes!\n", buffer, length); kprintf("E1000: Received 1 packet @ %p (%zu) bytes!\n", buffer, length);
#endif #endif
did_receive(buffer, length); did_receive(buffer, length);
m_rx_descriptors[rx_current].status = 0; m_rx_descriptors[rx_current].status = 0;

View file

@ -39,7 +39,7 @@ public:
E1000NetworkAdapter(PCI::Address, u8 irq); E1000NetworkAdapter(PCI::Address, u8 irq);
virtual ~E1000NetworkAdapter() override; virtual ~E1000NetworkAdapter() override;
virtual void send_raw(const u8*, int) override; virtual void send_raw(const u8*, size_t) override;
virtual bool link_up() override; virtual bool link_up() override;
private: private:

View file

@ -44,7 +44,7 @@ LoopbackAdapter::~LoopbackAdapter()
{ {
} }
void LoopbackAdapter::send_raw(const u8* data, int size) void LoopbackAdapter::send_raw(const u8* data, size_t size)
{ {
dbgprintf("LoopbackAdapter: Sending %d byte(s) to myself.\n", size); dbgprintf("LoopbackAdapter: Sending %d byte(s) to myself.\n", size);
did_receive(data, size); did_receive(data, size);

View file

@ -35,7 +35,7 @@ public:
virtual ~LoopbackAdapter() override; virtual ~LoopbackAdapter() override;
virtual void send_raw(const u8*, int) override; virtual void send_raw(const u8*, size_t) override;
virtual const char* class_name() const override { return "LoopbackAdapter"; } virtual const char* class_name() const override { return "LoopbackAdapter"; }
private: private:

View file

@ -127,7 +127,7 @@ void NetworkAdapter::send_ipv4(const MACAddress& destination_mac, const IPv4Addr
send_raw((const u8*)&eth, ethernet_frame_size); send_raw((const u8*)&eth, ethernet_frame_size);
} }
void NetworkAdapter::did_receive(const u8* data, int length) void NetworkAdapter::did_receive(const u8* data, size_t length)
{ {
InterruptDisabler disabler; InterruptDisabler disabler;
m_packets_in++; m_packets_in++;
@ -140,7 +140,7 @@ void NetworkAdapter::did_receive(const u8* data, int length)
} else { } else {
buffer = m_unused_packet_buffers.take_first(); buffer = m_unused_packet_buffers.take_first();
--m_unused_packet_buffers_count; --m_unused_packet_buffers_count;
if ((size_t)length <= buffer.value().size()) { if (length <= buffer.value().size()) {
memcpy(buffer.value().data(), data, length); memcpy(buffer.value().data(), data, length);
buffer.value().set_size(length); buffer.value().set_size(length);
} else { } else {

View file

@ -81,8 +81,8 @@ protected:
NetworkAdapter(); NetworkAdapter();
void set_interface_name(const StringView& basename); void set_interface_name(const StringView& basename);
void set_mac_address(const MACAddress& mac_address) { m_mac_address = mac_address; } void set_mac_address(const MACAddress& mac_address) { m_mac_address = mac_address; }
virtual void send_raw(const u8*, int) = 0; virtual void send_raw(const u8*, size_t) = 0;
void did_receive(const u8*, int); void did_receive(const u8*, size_t);
private: private:
MACAddress m_mac_address; MACAddress m_mac_address;

View file

@ -291,7 +291,7 @@ void RTL8139NetworkAdapter::read_mac_address()
set_mac_address(mac); set_mac_address(mac);
} }
void RTL8139NetworkAdapter::send_raw(const u8* data, int length) void RTL8139NetworkAdapter::send_raw(const u8* data, size_t length)
{ {
#ifdef RTL8139_DEBUG #ifdef RTL8139_DEBUG
kprintf("RTL8139NetworkAdapter::send_raw length=%d\n", length); kprintf("RTL8139NetworkAdapter::send_raw length=%d\n", length);
@ -332,7 +332,7 @@ void RTL8139NetworkAdapter::send_raw(const u8* data, int length)
// 60 bytes if necessary to make sure the whole thing is large enough. // 60 bytes if necessary to make sure the whole thing is large enough.
if (length < 60) { if (length < 60) {
#ifdef RTL8139_DEBUG #ifdef RTL8139_DEBUG
kprintf("RTL8139NetworkAdapter: adjusting payload size from %d to 60\n", length); kprintf("RTL8139NetworkAdapter: adjusting payload size from %zu to 60\n", length);
#endif #endif
length = 60; length = 60;
} }

View file

@ -41,7 +41,7 @@ public:
RTL8139NetworkAdapter(PCI::Address, u8 irq); RTL8139NetworkAdapter(PCI::Address, u8 irq);
virtual ~RTL8139NetworkAdapter() override; virtual ~RTL8139NetworkAdapter() override;
virtual void send_raw(const u8*, int) override; virtual void send_raw(const u8*, size_t) override;
virtual bool link_up() override { return m_link_up; } virtual bool link_up() override { return m_link_up; }
private: private: