Summary: | ASTERISK-06364: [patch] format_sln -- ignoring error returned from fseek | ||
Reporter: | Denis Smirnov (mithraen) | Labels: | |
Date Opened: | 2006-02-19 04:35:43.000-0600 | Date Closed: | 2006-02-19 11:25:16.000-0600 |
Priority: | Minor | Regression? | No |
Status: | Closed/Complete | Components: | Core/General |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ( 0) asterisk.formats.patch | |
Description: | fseek returns 0 if no error or -1 if any error. Useless division by to make return always equal to 0. int a = -1; int b = a / 2; print( "%d\n", b ); would print "0". | ||
Comments: | By: Tilghman Lesher (tilghman) 2006-02-19 10:11:12.000-0600 Fixed, but not with your patch. By: Denis Smirnov (mithraen) 2006-02-19 10:50:25.000-0600 from fseek(3) on Linux: RETURN VALUE The rewind() function returns no value. Upon successful completion, fgetpos(), fseek(), fsetpos() return 0, and ftell() returns the current offset. Otherwise, -1 is returned and the global variable errno is set to indicate the error. fseek can return only -1 and 0 on Linux. Why you need this division? Is there other platforms, where fseek can return something other then -1 or 0? By: Tilghman Lesher (tilghman) 2006-02-19 11:07:57.000-0600 Signed linear format has 2 bytes per sample, so it needs the division to properly return the number of samples. By: Denis Smirnov (mithraen) 2006-02-19 11:12:56.000-0600 If you need return _number of samples_ you need to use ftell after fseek. fseek _does not_ return number of samples. It returns '0' if seek done, or '-1', if error. And in other formats, e.g. format_gsm, *_seek returns directly result of fseek. |