stun: Fix a use of a function with an aggregate return value
div() has an aggregate return, which GCC doesn’t like, although this
seems like a pretty pointless warning because div_t is the same size as
a pointer on 64-bit platforms (probably) and hardly going to cause
performance problems by passing it by value.
Anyway, it seems easier to simplify the code by using explicit / and %
operators inline, than it does to add pragmas and shut the warning up.
Philip Withnall authored 10 years ago
Olivier Crête committed 10 years ago
523 | 523 |
{
|
524 | 524 |
const char *str = stun_strerror (code);
|
525 | 525 |
size_t len = strlen (str);
|
526 | |
div_t d = div (code, 100);
|
527 | 526 |
|
528 | 527 |
uint8_t *ptr = stun_message_append (msg, STUN_ATTRIBUTE_ERROR_CODE, 4 + len);
|
529 | 528 |
if (ptr == NULL)
|
530 | 529 |
return STUN_MESSAGE_RETURN_NOT_ENOUGH_SPACE;
|
531 | 530 |
|
532 | 531 |
memset (ptr, 0, 2);
|
533 | |
ptr[2] = d.quot;
|
534 | |
ptr[3] = d.rem;
|
|
532 |
ptr[2] = code / 100;
|
|
533 |
ptr[3] = code % 100;
|
535 | 534 |
memcpy (ptr + 4, str, len);
|
536 | 535 |
return STUN_MESSAGE_RETURN_SUCCESS;
|
537 | 536 |
}
|
87 | 87 |
|
88 | 88 |
static void add_delay (struct timeval *ts, unsigned delay)
|
89 | 89 |
{
|
90 | |
div_t d = div (delay, 1000);
|
91 | |
ts->tv_sec += d.quot;
|
92 | |
ts->tv_usec += d.rem * 1000;
|
|
90 |
/* Delay is in ms. */
|
|
91 |
ts->tv_sec += delay / 1000;
|
|
92 |
ts->tv_usec += (delay % 1000) * 1000;
|
93 | 93 |
|
94 | 94 |
while (ts->tv_usec > 1000000)
|
95 | 95 |
{
|