This removes a feature of mounting physical CD-ROMs in DOSBox.
SDL 2.0 removed SDL_cdrom from supported libraries, so to bring this
code back, either the functionality will need to be reimplemented or
SDL_cdrom code modernized for SDL 2.0, and bundled with the repo (the
same way SDL_sound is already bundled).
Also, remove all traces of these interfaces from user manual (README
file) and man page (docs/dosbox.1).
MCI (Media Control Interface) was a primary Windows interface. Code
comments and documentation claimed, that it's only for "NT, 2000, XP"
but the code was enabled for Windows 2000 or later (version > 4.0).
DX (Digital audio eXtraction (?)) could be forced on any Windows with
autodetection working only on Vista and Windows 7 (code was disabled for
Windows 8 or later - probably unintentionally).
DIO used DeviceIoControl interface and Windows-specific ioctl calls.
All 3 interfaces depend on SDL and SDL_cdrom functionality to work.
SDL_cdrom 1.2 implementation uses MCI on Windows to provide the same
functionality.
These issues were detected by Clang static analyzer.
Calling GetCurrentPos might leave pos uninitialized, and it will result
in passing uninitialized value pos.min to msf_to_frames function.
Same situation might happen for GetAudioStatus and all variables it
misses to initialize.
Also, fix formatting in adjacent lines.
Coverity error CID 277445 says:
Out-of-bounds access (ARRAY_VS_SINGLETON).
Passing &ch to function upcase which uses it as an array. This might
corrupt or misinterpret adjacent memory locations.
ASPI was supported by Microsoft only for Windows 95, 98 and, ME.
Adaptec supported this interface going forward for Windows NT, 2000,
and XP (32-bit only).
Cleanup before replacing SDL1.2 with SDL2.
OS/2 support was introduced in DOSBox in March 2006. OS/2 reached EOL
in December 2006.
As of 2019, OS/2 is being continued by proprietary 32-bit only ArcaOS,
although there is no official SDL2 support, despite pledges from SDL2
maintainers.
- Move imageDiskList from pointer to vector of unique_ptr
- Replace string operations with size-limited versions
- Initialize members
- Eliminate unecessary casts
- Eliminate memory-leak on pointer assignment
- Limit write length into buffer, and add comment about corner-case
- Use C++11's syntax to explicitly remove private copy and assignment operators
- Use C++11 container loop syntax to shorting a cleanup function
- Fix Bitu printf format type
- Check a pointer prior to dereferencing it
- Prevent writing one-beyond the last index
- Replace strcpy with with helper safe_strcpy, provided by @dreamer - thank you!
- Replace strcat with strncat
- Add constructor intializers for scalars and arrays
- Initialize and replace 0-value pointers with nullptr
- Pass in the buffer length when strncpy'ing into a function variable
The eliminated code removes the (ch == 1) branch, which is scoped
within this if condition: `if (rtype == 2 && ch != 1)`, therefore
the (ch == 1) branch will never be taken.
In the call to decode_residue:
decode_residue(f, residue_buffers, ch, n2, r, do_not_decode);
The channel count is previously intialized as zero and incremented
based on a for-loop (f->channels) plus a conditional,
if (map->chan[j].mux == i). If this doesn't happen then 'ch'
remains zero.
Once inside decode_residue(..), the code has three branches based
on channel count: stereo (ch == 2), mono (ch == 1), and then the
exception if it's neither of those (simple 'else'). It's in here
where a zero-valued 'ch' can be used as the denominator in these
calculations:
int c_inter = z % ch
p_inter = z/ch;
Obviously this 'else' branch is meant for channel counts greater
than two an not for zero channels; so this change simply makes
that branch only valid if (ch > 2).
GCC helpfully indicates, that:
warning: this ‘if’ clause does not guard (…) this statement, but
the latter is misleadingly indented as if it were guarded by the ‘if’.
Also, improve readability while we're touching these lines.