Error messages from file I/O should be read from OS (non-win32)
Bug #217878 reported by
qwertitis
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
DC++ |
Fix Released
|
Undecided
|
Unassigned | ||
LinuxDC++ |
Fix Released
|
Low
|
Razzloss |
Bug Description
If there are errors while reading or otherwise working with files, make sure that the error messages are taken from the operating system, instead of just constant strings. This makes it much easier to detect full disks, etc. (No, the previous code won't do that, whatever it says.)
This is a patch originally made for Linux DC++, obviously, as the affected code is #ifndef on win32.
Related branches
Changed in dcplusplus: | |
status: | Fix Committed → Fix Released |
Changed in linuxdcpp: | |
importance: | Undecided → Low |
status: | New → Confirmed |
Changed in linuxdcpp: | |
status: | In Progress → Fix Committed |
Changed in linuxdcpp: | |
status: | Fix Committed → Fix Released |
Changed in linuxdcpp: | |
status: | Fix Released → Fix Committed |
Changed in linuxdcpp: | |
milestone: | none → 1.1.0 |
tags: | added: core |
Changed in linuxdcpp: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
On POSIX strerror_r returns an int, and on GNU it returns a char*. This will cause trouble on different systems. I understand the need for a thread safe version of strerror, but it may not be worth it if causes compilation issues. It is doubtful different threads call strerror at the exact same time and even if they did it will only affect the error's output, not some core functionality of the program.
Also, allocating so much memory on the stack will cause some flavors of *nix to fail (particularly the BSD family). If we're going to keep strerror_r, char[] needs to be changed to a boost::scoped_array (AutoArray in old dcpp cores) so that it allocates on the heap and automatically deletes itself when it goes out of scope. Because of these two issues, I recommend we keep strerror.
In the write function, "int left" needs to be of type size_t and pointer should probably be void*. They will work as is, but we should probably use the types the system call requires.