lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [patch #9166] Fix oldest entry lookup in dns_enqueue


From: Giuseppe Andreello
Subject: [lwip-devel] [patch #9166] Fix oldest entry lookup in dns_enqueue
Date: Wed, 23 Nov 2016 00:58:25 +0000 (UTC)
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36

Follow-up Comment #3, patch #9166 (project lwip):

Hi Simon,

I did not modify the dns_can_recycle_entry() function.

My understanding is that the following boolean is always false after a
wrap-around:

(dns_seqno - pEntry->seqno) > lseq


As I understand, this happens because:
1. in C, all operands get promoted to int (if the result of the operation can
fit; larger types otherwise)
2. the result of the difference is negative
3. lseq is initialized to 0

I'm running this on a 64bit linux system using gcc.

Could you test the following example with your compiler?

#include <stdio.h>
#include <inttypes.h>

int main(const char *argv, int argc)
{   
    printf("Hello world!\n");

    uint8_t a = 5;
    uint8_t b = 7;
    uint8_t c = 0;
    uint8_t u8diff;
    int intdiff;

    if ((a - b) > c)
    {   
        printf("(5-7) > 0\n");
    }
    else
    {   
        printf("(5-7) <= 0\n");
    }

    u8diff = (uint8_t)(a-b);
    intdiff = (int)(a-b);

    printf("u8diff: %"PRIu8"\n", u8diff);
    printf("intdiff: %d\n", intdiff);

    return 0;
}


I get the output below. As you can see, the "if" statement behaves as if the
operands are converted to int.


$ gcc example.c && ./a.out
Hello world!
(5-7) <= 0
u8diff: 254
intdiff: -2

I have gcc 4.8.4 on linux x86_64


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/patch/?9166>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]