Skip to content
Closed
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 CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")

# Compiler setting
add_compile_options(-Wfatal-errors)
add_compile_options(-Wfatal-errors -Wconversion -Wsign-conversion)
find_program(CCACHE_BIN ccache)
if(CCACHE_BIN)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_BIN})
Expand Down
20 changes: 10 additions & 10 deletions examples/common/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ int calculate_avtp_time(uint32_t *avtp_time, uint32_t max_transit_time)
return -1;
}

ptime = (tspec.tv_sec * NSEC_PER_SEC) +
(max_transit_time * NSEC_PER_MSEC) + tspec.tv_nsec;
ptime = ((uint64_t)tspec.tv_sec * NSEC_PER_SEC) +
(max_transit_time * NSEC_PER_MSEC) + (uint64_t)tspec.tv_nsec;

*avtp_time = ptime % (1ULL << 32);

Expand All @@ -81,7 +81,7 @@ int get_presentation_time(uint64_t avtp_time, struct timespec *tspec)
return -1;
}

now = (tspec->tv_sec * NSEC_PER_SEC) + tspec->tv_nsec;
now = ((uint64_t)tspec->tv_sec * NSEC_PER_SEC) + (uint64_t)tspec->tv_nsec;

/* The avtp_timestamp within AAF packet is the lower part (32
* less-significant bits) from presentation time calculated by the
Expand All @@ -96,8 +96,8 @@ int get_presentation_time(uint64_t avtp_time, struct timespec *tspec)
if (ptime < now)
ptime += (1ULL << 32);

tspec->tv_sec = ptime / NSEC_PER_SEC;
tspec->tv_nsec = ptime % NSEC_PER_SEC;
tspec->tv_sec = (__time_t)(ptime / NSEC_PER_SEC);
tspec->tv_nsec = (__syscall_slong_t)(ptime % NSEC_PER_SEC);
Comment on lines +99 to +100

return 0;
}
Expand Down Expand Up @@ -147,12 +147,12 @@ int setup_socket_address(int fd, const char *ifname, uint8_t macaddr[],
}

sk_addr->sll_family = AF_PACKET;
sk_addr->sll_protocol = htons(protocol);
sk_addr->sll_protocol = htons((uint16_t)protocol);
sk_addr->sll_halen = ETH_ALEN;
sk_addr->sll_ifindex = req.ifr_ifindex;
#elif defined(__ZEPHYR__)
sk_addr->sll_family = AF_PACKET;
sk_addr->sll_protocol = htons(protocol);
sk_addr->sll_protocol = htons((uint16_t)protocol);
sk_addr->sll_halen = ETH_ALEN;
sk_addr->sll_ifindex = net_if_get_by_iface(net_if_get_default());
#endif
Expand All @@ -166,7 +166,7 @@ int setup_udp_socket_address(struct in_addr *addr, uint32_t port,

sk_addr->sin_family = AF_INET;
sk_addr->sin_addr = *addr;
sk_addr->sin_port = htons(port);
sk_addr->sin_port = htons((uint16_t)port);

return 0;

Expand Down Expand Up @@ -239,7 +239,7 @@ int create_listener_socket_udp(uint32_t udp_port) {
// Initialize the socket
memset((char *) &sk_addr, 0, sizeof(sk_addr));
sk_addr.sin_family = AF_INET;
sk_addr.sin_port = htons(udp_port);
sk_addr.sin_port = htons((uint16_t)udp_port);
sk_addr.sin_addr.s_addr = htonl(INADDR_ANY);

res = bind(fd, (struct sockaddr *) &sk_addr, sizeof(sk_addr));
Expand All @@ -260,7 +260,7 @@ int create_listener_socket(char *ifname, uint8_t* macaddr, int protocol)
int fd, res;
struct sockaddr_ll sk_addr;

fd = socket(AF_PACKET, SOCK_DGRAM, htons(protocol));
fd = socket(AF_PACKET, SOCK_DGRAM, htons((uint16_t)protocol));
if (fd < 0) {
perror("Failed to open socket");
return -1;
Expand Down
32 changes: 16 additions & 16 deletions include/avtp/acf/Abb.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static inline void Avtp_Abb_Init(Avtp_Abb_t* msg) {
* @returns The value of the pad field.
*/
static inline uint8_t Avtp_Abb_GetPad(const Avtp_Abb_t* msg) {
return __Avtp_Abb_GetField(AVTP_ABB_FIELD_PAD);
return (uint8_t) __Avtp_Abb_GetField(AVTP_ABB_FIELD_PAD);
}

/**
Expand All @@ -156,7 +156,7 @@ static inline uint8_t Avtp_Abb_GetPad(const Avtp_Abb_t* msg) {
* @returns The value of the mtv flag.
*/
static inline bool Avtp_Abb_IsMtv(const Avtp_Abb_t* msg) {
return __Avtp_Abb_GetField(AVTP_ABB_FIELD_MTV);
return (bool) __Avtp_Abb_GetField(AVTP_ABB_FIELD_MTV);
}

/**
Expand All @@ -166,7 +166,7 @@ static inline bool Avtp_Abb_IsMtv(const Avtp_Abb_t* msg) {
* @returns The value of the byte_bus_id field.
*/
static inline uint16_t Avtp_Abb_GetByteBusId(const Avtp_Abb_t* msg) {
return __Avtp_Abb_GetField(AVTP_ABB_FIELD_BYTE_BUS_ID);
return (uint16_t) __Avtp_Abb_GetField(AVTP_ABB_FIELD_BYTE_BUS_ID);
}

/**
Expand All @@ -176,7 +176,7 @@ static inline uint16_t Avtp_Abb_GetByteBusId(const Avtp_Abb_t* msg) {
* @returns The value of the evt field.
*/
static inline uint8_t Avtp_Abb_GetEvt(const Avtp_Abb_t* msg) {
return __Avtp_Abb_GetField(AVTP_ABB_FIELD_EVT);
return (uint8_t) __Avtp_Abb_GetField(AVTP_ABB_FIELD_EVT);
}

/**
Expand All @@ -186,7 +186,7 @@ static inline uint8_t Avtp_Abb_GetEvt(const Avtp_Abb_t* msg) {
* @returns The value of the hs field.
*/
static inline bool Avtp_Abb_IsHs(const Avtp_Abb_t* msg) {
return __Avtp_Abb_GetField(AVTP_ABB_FIELD_HS);
return (bool) __Avtp_Abb_GetField(AVTP_ABB_FIELD_HS);
}

/**
Expand All @@ -196,7 +196,7 @@ static inline bool Avtp_Abb_IsHs(const Avtp_Abb_t* msg) {
* @returns The value of the cs field.
*/
static inline bool Avtp_Abb_IsCs(const Avtp_Abb_t* msg) {
return __Avtp_Abb_GetField(AVTP_ABB_FIELD_CS);
return (bool) __Avtp_Abb_GetField(AVTP_ABB_FIELD_CS);
}

/**
Expand All @@ -207,7 +207,7 @@ static inline bool Avtp_Abb_IsCs(const Avtp_Abb_t* msg) {
* @returns The value of the transaction_num field.
*/
static inline uint8_t Avtp_Abb_GetTransactionNum(const Avtp_Abb_t* msg) {
return __Avtp_Abb_GetField(AVTP_ABB_FIELD_TRANSACTION_NUM);
return (uint8_t) __Avtp_Abb_GetField(AVTP_ABB_FIELD_TRANSACTION_NUM);
}

/**
Expand All @@ -217,7 +217,7 @@ static inline uint8_t Avtp_Abb_GetTransactionNum(const Avtp_Abb_t* msg) {
* @returns The value of the op flag.
*/
static inline bool Avtp_Abb_IsOp(const Avtp_Abb_t* msg) {
return __Avtp_Abb_GetField(AVTP_ABB_FIELD_OP);
return (bool) __Avtp_Abb_GetField(AVTP_ABB_FIELD_OP);
}

/**
Expand All @@ -227,7 +227,7 @@ static inline bool Avtp_Abb_IsOp(const Avtp_Abb_t* msg) {
* @returns The value of the rsp flag.
*/
static inline bool Avtp_Abb_IsRsp(const Avtp_Abb_t* msg) {
return __Avtp_Abb_GetField(AVTP_ABB_FIELD_RSP);
return (bool) __Avtp_Abb_GetField(AVTP_ABB_FIELD_RSP);
}

/**
Expand All @@ -237,7 +237,7 @@ static inline bool Avtp_Abb_IsRsp(const Avtp_Abb_t* msg) {
* @returns The value of the err flag.
*/
static inline bool Avtp_Abb_IsErr(const Avtp_Abb_t* msg) {
return __Avtp_Abb_GetField(AVTP_ABB_FIELD_ERR);
return (bool) __Avtp_Abb_GetField(AVTP_ABB_FIELD_ERR);
}

/**
Expand All @@ -247,7 +247,7 @@ static inline bool Avtp_Abb_IsErr(const Avtp_Abb_t* msg) {
* @returns The value of the ms flag.
*/
static inline bool Avtp_Abb_IsMs(const Avtp_Abb_t* msg) {
return __Avtp_Abb_GetField(AVTP_ABB_FIELD_MS);
return (bool) __Avtp_Abb_GetField(AVTP_ABB_FIELD_MS);
}

/**
Expand All @@ -258,7 +258,7 @@ static inline bool Avtp_Abb_IsMs(const Avtp_Abb_t* msg) {
* @returns The value of the read_size/segment_num field.
*/
static inline uint16_t Avtp_Abb_GetReadSize(const Avtp_Abb_t* msg) {
return __Avtp_Abb_GetField(AVTP_ABB_FIELD_READ_SIZE_SEGMENT_NUM);
return (uint16_t) __Avtp_Abb_GetField(AVTP_ABB_FIELD_READ_SIZE_SEGMENT_NUM);
}

/**
Expand All @@ -269,7 +269,7 @@ static inline uint16_t Avtp_Abb_GetReadSize(const Avtp_Abb_t* msg) {
* @returns The value of the read_size/segment_num field.
*/
static inline uint16_t Avtp_Abb_GetSegmentNum(const Avtp_Abb_t* msg) {
return __Avtp_Abb_GetField(AVTP_ABB_FIELD_READ_SIZE_SEGMENT_NUM);
return (uint16_t) __Avtp_Abb_GetField(AVTP_ABB_FIELD_READ_SIZE_SEGMENT_NUM);
}

/**
Expand All @@ -281,9 +281,9 @@ static inline uint16_t Avtp_Abb_GetSegmentNum(const Avtp_Abb_t* msg) {
* @returns The payload length in bytes.
*/
static inline uint16_t Avtp_Abb_GetPayloadLen(const Avtp_Abb_t* msg) {
return __Avtp_Abb_GetField(AVTP_ABB_FIELD_ACF_MSG_LENGTH) * AVTP_QUADLET_SIZE
return (uint16_t) (__Avtp_Abb_GetField(AVTP_ABB_FIELD_ACF_MSG_LENGTH) * AVTP_QUADLET_SIZE
- AVTP_ABB_HEADER_LEN
- __Avtp_Abb_GetField(AVTP_ABB_FIELD_PAD);
- __Avtp_Abb_GetField(AVTP_ABB_FIELD_PAD));
}

/**
Expand All @@ -294,7 +294,7 @@ static inline uint16_t Avtp_Abb_GetPayloadLen(const Avtp_Abb_t* msg) {
* @returns The total message length in bytes.
*/
static inline uint16_t Avtp_Abb_GetLen(const Avtp_Abb_t* msg) {
return __Avtp_Abb_GetField(AVTP_ABB_FIELD_ACF_MSG_LENGTH) * AVTP_QUADLET_SIZE;
return (uint16_t) (__Avtp_Abb_GetField(AVTP_ABB_FIELD_ACF_MSG_LENGTH) * AVTP_QUADLET_SIZE);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion include/avtp/acf/AcfCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ static inline Avtp_AcfMsgType_t Avtp_AcfCommon_GetAcfMsgType(const Avtp_AcfCommo
* @returns Returns the ACF message length field of the PDU.
*/
static inline uint16_t Avtp_AcfCommon_GetAcfMsgLength(const Avtp_AcfCommon_t* const pdu) {
return GET_ACF_COMMON_FIELD(AVTP_ACF_FIELD_ACF_MSG_LENGTH);
return (uint16_t) GET_ACF_COMMON_FIELD(AVTP_ACF_FIELD_ACF_MSG_LENGTH);
}

/**
Expand Down
22 changes: 11 additions & 11 deletions include/avtp/acf/Can.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static const Avtp_FieldDescriptor_t Avtp_CanFieldDesc[AVTP_CAN_FIELD_MAX] =
* @returns Value of the ACF message type field.
*/
static inline uint8_t Avtp_Can_GetAcfMsgType(const Avtp_Can_t* const pdu) {
return GET_CAN_FIELD(AVTP_CAN_FIELD_ACF_MSG_TYPE);
return (uint8_t) GET_CAN_FIELD(AVTP_CAN_FIELD_ACF_MSG_TYPE);
}

/**
Expand All @@ -121,7 +121,7 @@ static inline uint8_t Avtp_Can_GetAcfMsgType(const Avtp_Can_t* const pdu) {
* @returns Value of the ACF message length field.
*/
static inline uint16_t Avtp_Can_GetAcfMsgLength(const Avtp_Can_t* const pdu) {
return GET_CAN_FIELD(AVTP_CAN_FIELD_ACF_MSG_LENGTH);
return (uint16_t) GET_CAN_FIELD(AVTP_CAN_FIELD_ACF_MSG_LENGTH);
}

/**
Expand All @@ -131,7 +131,7 @@ static inline uint16_t Avtp_Can_GetAcfMsgLength(const Avtp_Can_t* const pdu) {
* @returns Value of the ACF padding field.
*/
static inline uint8_t Avtp_Can_GetPad(const Avtp_Can_t* const pdu) {
return GET_CAN_FIELD(AVTP_CAN_FIELD_PAD);
return (uint8_t) GET_CAN_FIELD(AVTP_CAN_FIELD_PAD);
}

/**
Expand All @@ -141,7 +141,7 @@ static inline uint8_t Avtp_Can_GetPad(const Avtp_Can_t* const pdu) {
* @returns Value of the ACF CAN PDU MTV field.
*/
static inline uint8_t Avtp_Can_GetMtv(const Avtp_Can_t* const pdu) {
return GET_CAN_FIELD(AVTP_CAN_FIELD_MTV);
return (uint8_t) GET_CAN_FIELD(AVTP_CAN_FIELD_MTV);
}

/**
Expand All @@ -151,7 +151,7 @@ static inline uint8_t Avtp_Can_GetMtv(const Avtp_Can_t* const pdu) {
* @returns Value of the ACF CAN PDU RTR field.
*/
static inline uint8_t Avtp_Can_GetRtr(const Avtp_Can_t* const pdu) {
return GET_CAN_FIELD(AVTP_CAN_FIELD_RTR);
return (uint8_t) GET_CAN_FIELD(AVTP_CAN_FIELD_RTR);
}

/**
Expand All @@ -161,7 +161,7 @@ static inline uint8_t Avtp_Can_GetRtr(const Avtp_Can_t* const pdu) {
* @returns Value of the ACF CAN PDU EFF field.
*/
static inline uint8_t Avtp_Can_GetEff(const Avtp_Can_t* const pdu) {
return GET_CAN_FIELD(AVTP_CAN_FIELD_EFF);
return (uint8_t) GET_CAN_FIELD(AVTP_CAN_FIELD_EFF);
}

/**
Expand All @@ -171,7 +171,7 @@ static inline uint8_t Avtp_Can_GetEff(const Avtp_Can_t* const pdu) {
* @returns Value of the ACF CAN PDU BRS field.
*/
static inline uint8_t Avtp_Can_GetBrs(const Avtp_Can_t* const pdu) {
return GET_CAN_FIELD(AVTP_CAN_FIELD_BRS);
return (uint8_t) GET_CAN_FIELD(AVTP_CAN_FIELD_BRS);
}

/**
Expand All @@ -181,7 +181,7 @@ static inline uint8_t Avtp_Can_GetBrs(const Avtp_Can_t* const pdu) {
* @returns Value of the ACF CAN PDU FDF field.
*/
static inline uint8_t Avtp_Can_GetFdf(const Avtp_Can_t* const pdu) {
return GET_CAN_FIELD(AVTP_CAN_FIELD_FDF);
return (uint8_t) GET_CAN_FIELD(AVTP_CAN_FIELD_FDF);
}

/**
Expand All @@ -191,7 +191,7 @@ static inline uint8_t Avtp_Can_GetFdf(const Avtp_Can_t* const pdu) {
* @returns Value of the ACF CAN PDU ESI field.
*/
static inline uint8_t Avtp_Can_GetEsi(const Avtp_Can_t* const pdu) {
return GET_CAN_FIELD(AVTP_CAN_FIELD_ESI);
return (uint8_t) GET_CAN_FIELD(AVTP_CAN_FIELD_ESI);
}

/**
Expand All @@ -201,7 +201,7 @@ static inline uint8_t Avtp_Can_GetEsi(const Avtp_Can_t* const pdu) {
* @returns Value of the ACF CAN PDU CAN Bus ID field.
*/
static inline uint8_t Avtp_Can_GetCanBusId(const Avtp_Can_t* const pdu) {
return GET_CAN_FIELD(AVTP_CAN_FIELD_CAN_BUS_ID);
return (uint8_t) GET_CAN_FIELD(AVTP_CAN_FIELD_CAN_BUS_ID);
}

/**
Expand All @@ -221,7 +221,7 @@ static inline uint64_t Avtp_Can_GetMessageTimestamp(const Avtp_Can_t* const pdu)
* @returns Value of the ACF CAN PDU CAN Identifier field.
*/
static inline uint32_t Avtp_Can_GetCanIdentifier(const Avtp_Can_t* const pdu) {
return GET_CAN_FIELD(AVTP_CAN_FIELD_CAN_IDENTIFIER);
return (uint32_t) GET_CAN_FIELD(AVTP_CAN_FIELD_CAN_IDENTIFIER);
}

/**
Expand Down
Loading