Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang-tidy-baseline.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
384
170
4 changes: 2 additions & 2 deletions include/platform/posix/net_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static inline int someip_shutdown_socket(someip_socket_t fd) {

/** @implements REQ_PAL_NET_NONBLOCK, REQ_PAL_NET_MODE_E01 */
static inline int someip_set_nonblocking(someip_socket_t fd) {
int flags = fcntl(fd, F_GETFL, 0);
const int flags = fcntl(fd, F_GETFL, 0);
if (flags < 0) {
return -1;
}
Expand All @@ -53,7 +53,7 @@ static inline int someip_set_nonblocking(someip_socket_t fd) {

/** @implements REQ_PAL_NET_BLOCK, REQ_PAL_NET_MODE_E01 */
static inline int someip_set_blocking(someip_socket_t fd) {
int flags = fcntl(fd, F_GETFL, 0);
const int flags = fcntl(fd, F_GETFL, 0);
if (flags < 0) {
return -1;
}
Expand Down
13 changes: 10 additions & 3 deletions include/serialization/serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <vector>
#include <cstdint>
#include <cstdlib>
#include <string>
#include <memory>
#include <optional>
Expand Down Expand Up @@ -77,14 +78,20 @@ class DeserializationResult {
* @brief Get the value (only valid if is_success() returns true)
*/
const T& get_value() const {
return value_.value();
if (!value_.has_value()) {
std::abort();
}
return *value_;
}

/**
* @brief Get the value with move semantics (only valid if is_success() returns true)
*/
T&& move_value() {
return std::move(value_.value());
if (!value_.has_value()) {
std::abort();
}
return std::move(*value_);
}
Comment thread
vtz marked this conversation as resolved.

private:
Expand Down Expand Up @@ -328,7 +335,7 @@ DeserializationResult<std::vector<T>> Deserializer::deserialize_dynamic_array()
return DeserializationResult<std::vector<T>>::error(length_result.get_error());
}

uint32_t byte_length = length_result.get_value();
const uint32_t byte_length = length_result.get_value();

// Validate that byte length is multiple of element size (REQ_SER_082_E01)
size_t element_size = sizeof(T);
Expand Down
2 changes: 1 addition & 1 deletion include/someip/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class Message {

// Utility methods
size_t get_total_size() const {
size_t e2e_size = e2e_header_.has_value() ? e2e::E2EHeader::get_header_size() : 0;
const size_t e2e_size = e2e_header_.has_value() ? e2e::E2EHeader::get_header_size() : 0;
return HEADER_SIZE + e2e_size + payload_.size();
}
static size_t get_header_size() { return HEADER_SIZE; }
Expand Down
2 changes: 1 addition & 1 deletion src/e2e/e2e_crc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const std::array<uint32_t, 256>& get_crc32_table() {
for (uint32_t i = 0; i < 256; ++i) {
uint32_t crc = i << 24U;
for (int j = 0; j < 8; ++j) {
if (crc & 0x80000000U) {
if ((crc & 0x80000000U) != 0U) {
crc = (crc << 1U) ^ CRC32_POLY;
} else {
crc <<= 1U;
Expand Down
1 change: 1 addition & 0 deletions src/e2e/e2e_profile_registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "e2e/e2e_profile_registry.h"

#include "e2e/e2e_profile.h"
#include "platform/thread.h"

#include <cstdint>
Expand Down
10 changes: 5 additions & 5 deletions src/events/event_subscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class EventSubscriberImpl : public transport::ITransportListener {
bool set_event_filters(uint16_t service_id, uint16_t instance_id, uint16_t eventgroup_id,
const std::vector<EventFilter>& filters) {
platform::ScopedLock const subs_lock(subscriptions_mutex_);
std::string key = make_subscription_key(service_id, instance_id, eventgroup_id);
std::string const key = make_subscription_key(service_id, instance_id, eventgroup_id);

auto it = subscriptions_.find(key);
if (it == subscriptions_.end()) {
Expand All @@ -228,7 +228,7 @@ class EventSubscriberImpl : public transport::ITransportListener {
SubscriptionState get_subscription_status(uint16_t service_id, uint16_t instance_id,
uint16_t eventgroup_id) const {
platform::ScopedLock const subs_lock(subscriptions_mutex_);
std::string key = make_subscription_key(service_id, instance_id, eventgroup_id);
std::string const key = make_subscription_key(service_id, instance_id, eventgroup_id);

auto it = subscriptions_.find(key);
if (it == subscriptions_.end()) {
Expand Down Expand Up @@ -272,8 +272,8 @@ class EventSubscriberImpl : public transport::ITransportListener {
// Check if this is for one of our subscriptions
platform::ScopedLock const subs_lock(subscriptions_mutex_);

uint16_t service_id = message->get_service_id();
uint16_t event_id = message->get_method_id(); // Event ID is in method ID field for notifications
uint16_t const service_id = message->get_service_id();
uint16_t const event_id = message->get_method_id(); // Event ID is in method ID field for notifications

// Find matching subscription (we need to check all subscriptions for this service)
for (auto& sub_pair : subscriptions_) {
Expand All @@ -300,7 +300,7 @@ class EventSubscriberImpl : public transport::ITransportListener {

// Check if this is a field response
platform::ScopedLock const field_lock(field_requests_mutex_);
std::string field_key = make_field_key(service_id, 0, event_id); // Simplified
std::string const field_key = make_field_key(service_id, 0, event_id); // Simplified

auto field_it = field_requests_.find(field_key);
if (field_it != field_requests_.end()) {
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/rpc_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class RpcClientImpl : public transport::ITransportListener {

const auto handle = call_method_async(service_id, method_id, parameters,
[state](const RpcResponse& response) {
platform::ScopedLock lk(state->mtx);
platform::ScopedLock const lk(state->mtx);
state->resp = std::make_shared<RpcResponse>(response);
state->ready.store(true);
}, timeout);
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/rpc_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class RpcServerImpl : public transport::ITransportListener {
/** @implements REQ_MSG_115, REQ_MSG_117, REQ_MSG_117_E01, REQ_MSG_129 */
void send_error_response(MessagePtr const& request, const transport::Endpoint& sender, ReturnCode error_code) {
const MessageId response_msg_id(request->get_service_id(), request->get_method_id());
Message response(response_msg_id, request->get_request_id(),
Message const response(response_msg_id, request->get_request_id(),
MessageType::ERROR, error_code);

const Result result = transport_->send_message(response, sender);
Expand Down
2 changes: 1 addition & 1 deletion src/sd/sd_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class SdClientImpl : public transport::ITransportListener {
platform::ScopedLock const lock(subscriptions_mutex_);

// Check if already subscribed
bool already_exists = service_subscriptions_.count(service_id) > 0;
bool const already_exists = service_subscriptions_.count(service_id) > 0;
if (!already_exists) {
service_subscriptions_[service_id] = {
std::move(available_callback),
Expand Down
2 changes: 1 addition & 1 deletion src/sd/sd_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ std::vector<uint8_t> IPv4EndpointOption::serialize() const {
data.push_back(protocol_);

// Port (2 bytes, network byte order)
uint16_t network_port = someip_htons(port_);
uint16_t const network_port = someip_htons(port_);
data.push_back(static_cast<uint8_t>((static_cast<uint32_t>(network_port) >> 8U) & 0xFFU));
data.push_back(static_cast<uint8_t>(network_port & 0xFFU));

Expand Down
2 changes: 1 addition & 1 deletion src/serialization/serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ DeserializationResult<std::string> Deserializer::deserialize_string() {
* @implements REQ_SER_073
*/
bool Deserializer::set_position(size_t pos) {
bool valid = pos <= buffer_.size();
bool const valid = pos <= buffer_.size();
if (valid) {
position_ = pos;
}
Expand Down
12 changes: 6 additions & 6 deletions src/someip/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ bool Message::deserialize(const std::vector<uint8_t>& data, bool expect_e2e) {
e2e_header_.reset();
if (expect_e2e) {
constexpr size_t e2e_header_size = e2e::E2EHeader::get_header_size();
size_t remaining = data.size() - offset;
size_t const remaining = data.size() - offset;
if (remaining >= e2e_header_size && length_ >= 8 + e2e_header_size) {
e2e::E2EHeader header;
if (header.deserialize(data, offset)) {
Expand All @@ -264,9 +264,9 @@ bool Message::deserialize(const std::vector<uint8_t>& data, bool expect_e2e) {
if (length_ < 8) {
return false; // Invalid length: must be at least 8 for header
}
size_t e2e_size = e2e_header_.has_value() ? e2e::E2EHeader::get_header_size() : 0;
size_t const e2e_size = e2e_header_.has_value() ? e2e::E2EHeader::get_header_size() : 0;
size_t const expected_payload_size = length_ - 8 - e2e_size;
size_t actual_payload_size = data.size() - offset;
size_t const actual_payload_size = data.size() - offset;

if (actual_payload_size != expected_payload_size) {
return false;
Expand Down Expand Up @@ -451,8 +451,8 @@ bool Message::has_valid_header() const {
}

// Check length consistency
size_t e2e_size = e2e_header_.has_value() ? e2e::E2EHeader::get_header_size() : 0;
uint32_t expected_length = 8 + e2e_size + payload_.size();
size_t const e2e_size = e2e_header_.has_value() ? e2e::E2EHeader::get_header_size() : 0;
uint32_t const expected_length = 8 + e2e_size + payload_.size();
if (length_ != expected_length) {
return false;
}
Expand Down Expand Up @@ -509,7 +509,7 @@ void Message::update_length() {
// SOME/IP length field contains length from client_id to end of message
// client_id(2) + session_id(2) + protocol_version(1) + interface_version(1) +
// message_type(1) + return_code(1) + e2e_header_size + payload_size
size_t e2e_size = e2e_header_.has_value() ? e2e::E2EHeader::get_header_size() : 0;
size_t const e2e_size = e2e_header_.has_value() ? e2e::E2EHeader::get_header_size() : 0;
length_ = 8 + e2e_size + payload_.size();
}

Expand Down
4 changes: 2 additions & 2 deletions src/tp/tp_reassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ bool TpReassembler::get_reassembly_progress(uint32_t message_id, uint32_t& recei

// Count received bytes
received_bytes = 0;
for (bool received : buffer.received_segments) {
for (bool const received : buffer.received_segments) {
if (received) {
received_bytes += config.max_segment_size; // Approximate
}
Expand Down Expand Up @@ -364,7 +364,7 @@ bool TpReassemblyBuffer::is_complete() const {
}

// Check if all segments received
for (bool received : received_segments) {
for (bool const received : received_segments) {
if (!received) {
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions src/transport/tcp_transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ someip_socket_t TcpTransport::accept_connection() {
sockaddr_in client_addr = {};
socklen_t client_len = sizeof(client_addr);

someip_socket_t client_fd =
someip_socket_t const client_fd =
someip_accept(listen_socket_fd_, reinterpret_cast<struct sockaddr*>(&client_addr), &client_len);

if (client_fd == SOMEIP_INVALID_SOCKET) {
Expand Down Expand Up @@ -482,8 +482,8 @@ Result TcpTransport::send_data(someip_socket_t socket_fd, const std::vector<uint
const uint8_t* buffer = data.data();

while (total_sent < data.size()) {
ssize_t sent = someip_send(socket_fd, buffer + total_sent,
data.size() - total_sent, 0);
ssize_t const sent = someip_send(socket_fd, buffer + total_sent,
data.size() - total_sent, 0);

if (sent < 0) {
int const err = someip_socket_errno();
Expand Down Expand Up @@ -554,7 +554,7 @@ bool TcpTransport::parse_message_from_buffer(std::vector<uint8_t>& buffer, Messa

while (search_start + SOMEIP_HEADER_SIZE <= buffer.size()) {
// Check if this looks like a valid SOME/IP header
uint32_t potential_msg_id =
uint32_t const potential_msg_id =
(static_cast<uint32_t>(buffer[search_start]) << 24U) |
(static_cast<uint32_t>(buffer[search_start + 1]) << 16U) |
(static_cast<uint32_t>(buffer[search_start + 2]) << 8U) |
Expand Down
22 changes: 13 additions & 9 deletions src/transport/udp_transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ void UdpTransport::receive_loop() {
const Result result = receive_data(buffer, sender, bytes_received);

if (result == Result::SUCCESS && bytes_received > 0) {
MessagePtr message = platform::allocate_message();
MessagePtr const message = platform::allocate_message();
const uint8_t* begin = buffer.data();
if (message->deserialize({begin, begin + bytes_received})) {
// Add to queue
Expand Down Expand Up @@ -420,12 +420,14 @@ Result UdpTransport::send_data(const std::vector<uint8_t>& data, const Endpoint&
}

const sockaddr_in dest_addr = create_sockaddr(endpoint);
ssize_t sent = 0;
do {
ssize_t sent = someip_sendto(socket_fd_, data.data(), data.size(), 0,
reinterpret_cast<const sockaddr*>(&dest_addr),
sizeof(dest_addr));
while (sent < 0 && someip_socket_errno() == SOMEIP_EINTR) {
sent = someip_sendto(socket_fd_, data.data(), data.size(), 0,
reinterpret_cast<const sockaddr*>(&dest_addr),
sizeof(dest_addr));
} while (sent < 0 && someip_socket_errno() == SOMEIP_EINTR);
}

if (sent < 0) {
return Result::NETWORK_ERROR;
Expand All @@ -445,12 +447,14 @@ Result UdpTransport::receive_data(std::vector<uint8_t>& data, Endpoint& sender,

bytes_received = 0;

ssize_t received = 0;
do {
ssize_t received = someip_recvfrom(socket_fd_, data.data(), data.size(), 0,
reinterpret_cast<sockaddr*>(&src_addr),
&addr_len);
while (received < 0 && someip_socket_errno() == SOMEIP_EINTR) {
received = someip_recvfrom(socket_fd_, data.data(), data.size(), 0,
reinterpret_cast<sockaddr*>(&src_addr),
&addr_len);
} while (received < 0 && someip_socket_errno() == SOMEIP_EINTR);
}

if (received < 0) {
int const err = someip_socket_errno();
Expand Down Expand Up @@ -488,13 +492,13 @@ Endpoint UdpTransport::sockaddr_to_endpoint(const sockaddr_in& addr) const {
}

bool UdpTransport::is_multicast_address(const std::string& address) const {
in_addr_t addr = someip_inet_addr(address.c_str());
in_addr_t const addr = someip_inet_addr(address.c_str());
if (addr == INADDR_NONE) {
return false;
}

// Check if address is in multicast range (224.0.0.0 - 239.255.255.255)
uint32_t host_addr = ntohl(addr);
uint32_t const host_addr = ntohl(addr);
return (host_addr >= 0xE0000000) && (host_addr <= 0xEFFFFFFF);
}

Expand Down
Loading