Skip to content

Conversation

@guoguojia2021
Copy link
Contributor

Test code:

int compare(uint32_t x, uint32_t y) {
    return x - y;
}

void print_compare(uint32_t x, uint32_t y) {
    int ret = compare(x, y);
    if (ret < 0) {
        printf("%u < %u\n", x, y);
    } else if (ret > 0) {
        printf("%u > %u\n", x, y);
    } else {
        printf("%u = %u\n", x, y);
    }
}

int main(void) {
    uint32_t a = 2;
    uint32_t b = 0x80000001u;
    uint32_t c = 0xffffffffu;
    print_compare(a, b);
    print_compare(b, c);
    print_compare(c, a);

    uint32_t x = 7;
    uint32_t y = 0x80000007u;
    print_compare(x, y);
    print_compare(y, x);
    return 0;
}

Output:

2 < 2147483649
2147483649 < 4294967295
4294967295 < 2

Copy link
Member

@ton31337 ton31337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Jafaral
Copy link
Member

Jafaral commented Jun 19, 2025

@Mergifyio backport dev/10.4

@mergify
Copy link

mergify bot commented Jun 19, 2025

backport dev/10.4

✅ Backports have been created

Details

@Jafaral Jafaral merged commit f05eaad into FRRouting:master Jun 19, 2025
13 checks passed
ton31337 added a commit that referenced this pull request Jun 20, 2025
pathd: fix compare function overflow (backport #19050)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants