#295 test_seeking.sh fails because of low RAND_MAX

closed-fixed
5
2014-08-23
2007-08-28
laurent
No

On Solaris 10, with flac 1.2.0, test_seeking.sh fails there:

testing small.flac:

+++ seek test: FLAC__StreamDecoder (native FLAC, read_mode=0)

stream decoder state is FLAC__STREAM_DECODER_END_OF_STREAM
file's total_samples is 393216
ERROR: must be total_samples < 32767
ERROR: during test_seeking

This because of this test in src/test_seeking/main.c:

#if !defined _MSC_VER && !defined __MINGW32__ && !defined __EMX__
if (decoder_client_data.total_samples > (FLAC__uint64)RAND_MAX) {
printf("ERROR: must be total_samples < %u\n", (unsigned)RAND_MAX);
return false;
}
#endif

RAND_MAX is 2^31 for GNU libc, but not all Unixes (and there's already the exception for some).

Discussion

  • Josh Coalson

    Josh Coalson - 2007-08-29

    Logged In: YES
    user_id=78173
    Originator: NO

    note to self, use same trick used for msvc in this case

     
  • Josh Coalson

    Josh Coalson - 2007-08-29
    • assigned_to: nobody --> jcoalson
    • status: open --> open-accepted
     
  • laurent

    laurent - 2007-08-29

    Logged In: YES
    user_id=1447460
    Originator: YES

    Maybe I'm asking a dumb question, but why not use one of the ?rand48() functions instead? They've got the huge range you're looking for, and they're standard.

     
  • Josh Coalson

    Josh Coalson - 2007-08-31

    Logged In: YES
    user_id=78173
    Originator: NO

    IIRC ?rand48() are deprecated and rand() is recommended instead

     
  • laurent

    laurent - 2007-08-31

    Logged In: YES
    user_id=1447460
    Originator: YES

    I'm not a developer, so I can't vouch for either myself, but the standard says that drand48() is at least better than rand(), along with a greater guaranteed range:
    http://www.opengroup.org/onlinepubs/7990989775/xsh/rand.html

    I'd take that for a good reference :-)

     
  • Josh Coalson

    Josh Coalson - 2007-09-09
    • status: open-accepted --> closed-fixed
     
  • Josh Coalson

    Josh Coalson - 2007-09-09

    Logged In: YES
    user_id=78173
    Originator: NO

    now I know where I saw it, the linux man page for drand48 says "These functions are declared obsolete by SVID 3, which states that rand(3) should be used instead."

    anyway I think I have hackfixed this using rand()/random(), may revisit ?rand48() in the future...

     
  • laurent

    laurent - 2007-09-09

    Logged In: YES
    user_id=1447460
    Originator: YES

    Ok, no big deal, as long as it works for the test!
    I wonder where the guy who wrote the man got this information, though. Not from the standard, AFAICT :-)

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks