Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

posix_sockets.c: Fix 2 byte int compilation errors #19946

Merged
merged 1 commit into from Sep 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion sys/posix/sockets/posix_sockets.c
Expand Up @@ -1045,7 +1045,7 @@
}
#if defined(MODULE_SOCK_IP)
if ((res = _sockaddr_to_ep(address, address_len, &ep)) < 0)
return res;

Check warning on line 1048 in sys/posix/sockets/posix_sockets.c

View workflow job for this annotation

GitHub Actions / static-tests

full block {} expected in the control structure
#endif
switch (s->type) {
#ifdef MODULE_SOCK_IP
Expand Down Expand Up @@ -1121,7 +1121,7 @@
#ifdef POSIX_SETSOCKOPT
socket_t *s;
struct timeval *tv;
const uint32_t max_timeout_secs = UINT32_MAX / (1000 * 1000);
const uint32_t max_timeout_secs = UINT32_MAX / US_PER_SEC;

if (level != SOL_SOCKET
|| option_name != SO_RCVTIMEO) {
Expand All @@ -1144,13 +1144,21 @@

tv = (struct timeval *) option_value;

#if MODULE_AVR8_COMMON
benpicco marked this conversation as resolved.
Show resolved Hide resolved
/* tv_sec is uint32_t, so never negative */
if (tv->tv_usec < 0) {
errno = EINVAL;
return -1;
}
#else /* ! MODULE_AVR8_COMMON */
if (tv->tv_sec < 0 || tv->tv_usec < 0) {
errno = EINVAL;
return -1;
}
#endif /* ! MODULE_AVR8_COMMON */

if ((uint32_t)tv->tv_sec > max_timeout_secs
|| ((uint32_t)tv->tv_sec == max_timeout_secs && (uint32_t)tv->tv_usec > UINT32_MAX - max_timeout_secs * 1000 * 1000)) {

Check warning on line 1161 in sys/posix/sockets/posix_sockets.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
errno = EDOM;
return -1;
}
Expand Down