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

ncx_compare_nums() has a non working optimization #143

Open
jonaslindahl opened this issue Feb 27, 2024 · 1 comment
Open

ncx_compare_nums() has a non working optimization #143

jonaslindahl opened this issue Feb 27, 2024 · 1 comment

Comments

@jonaslindahl
Copy link

jonaslindahl commented Feb 27, 2024

The following code from ncx_compare_nums() does not work

            /* check if any leading zeroes */
            if (temp1 == 0) {
                if (num1->dec.zeroes < num2->dec.zeroes) {
                    return 1;
                } else if (num1->dec.zeroes > num2->dec.zeroes) {
                    return -1;
                }  /* else need to compare fraction parts */
            }

It fails for cases where dec.zeroes == 0 due to dec.val == 0. Either tremove this code entirely or add cases to cover situations where dec.zeroes == 0 due to dec.val == 0.

Example:

leaf sample-configuration {
  type decimal64 { fraction-digits 4; range "0 .. 1.9999";}
  default 0.001;
}

yangdump will consider the default value of 0.001 invalid since num1->dec.zeroes == 2 > num2->dec-zeroes == 0 causing return -1 while comparing the lower range (0)

@vlvassilev
Copy link
Owner

Confirmed. Added testcase 707d917 . High priority issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants