Codebase list libnice / 3e29fec
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
2 changed file(s) with 5 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
523523 {
524524 const char *str = stun_strerror (code);
525525 size_t len = strlen (str);
526 div_t d = div (code, 100);
527526
528527 uint8_t *ptr = stun_message_append (msg, STUN_ATTRIBUTE_ERROR_CODE, 4 + len);
529528 if (ptr == NULL)
530529 return STUN_MESSAGE_RETURN_NOT_ENOUGH_SPACE;
531530
532531 memset (ptr, 0, 2);
533 ptr[2] = d.quot;
534 ptr[3] = d.rem;
532 ptr[2] = code / 100;
533 ptr[3] = code % 100;
535534 memcpy (ptr + 4, str, len);
536535 return STUN_MESSAGE_RETURN_SUCCESS;
537536 }
8787
8888 static void add_delay (struct timeval *ts, unsigned delay)
8989 {
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;
9393
9494 while (ts->tv_usec > 1000000)
9595 {