fixlet for tests/tests.h
Marco Trudel
marco at mtsystems.ch
Thu Oct 13 12:13:34 CEST 2011
Let me add some more explanation to show why I think the code is wrong.
Two excerpts from "tests/tests.h":
count = strtol (argv[1], &end, 0);
if (*end || count <= 0)
{
fprintf (stderr, "Invalid test count: %s.\n", argv[1]);
exit (1);
}
char *envval = getenv ("GMP_CHECK_REPFACTOR");
long repfactor = strtol (envval, &end, 0);
if (*end || repfactor <= 0)
{
fprintf (stderr, "Invalid repfactor: %ld.\n", repfactor);
exit (1);
}
The first excerpt tries to parse "argv[1]" into "count". If it fails
"argv[1]" is printed. The second excerpt tries to do exactly the same
for "envval". But there was a little error in gmp-5.0.1:
fprintf (stderr, "Invalid repfactor: %s.\n", repfactor);
It was changed in gmp-5.0.2 to
fprintf (stderr, "Invalid repfactor: %ld.\n", repfactor);
instead of
fprintf (stderr, "Invalid repfactor: %s.\n", envval);
So now it outputs the meaningless "repfactor" instead of the string for
which parsing failed. If this ever fails, the user doesn't get a very
helpful explanation of the problem.
Cheers!
Marco
On 07.10.2011 18:44, Marco Trudel wrote:
> Dear all
>
> This has been wrong in gmp-5.0.1 [1] and has been fixed the wrong way
> for gmp-5.0.2 [2]. I guess it makes more sense to have it the same way
> as the test count evaluation just above it (the information is in
> "envval", not in the meaningless "repfactor").
>
> Hope that's correct and helps
> Marco
>
> [1] fprintf (stderr, "Invalid repfactor: %s.\n", repfactor);
> [2] fprintf (stderr, "Invalid repfactor: %ld.\n", repfactor);
More information about the gmp-bugs
mailing list